Add wireformat binary for format dns ask answer

This commit is contained in:
Antoine 2020-11-08 23:16:49 +01:00
parent f970c19946
commit 39d496cf7e
Signed by: antoine
GPG Key ID: 098FB66FC0475E70
8 changed files with 92 additions and 4 deletions

4
.gitignore vendored
View File

@ -5,6 +5,8 @@
*.dll *.dll
*.so *.so
*.dylib *.dylib
bin/*
!bin/.gitkeep
# Test binary, built with `go test -c` # Test binary, built with `go test -c`
*.test *.test
@ -13,5 +15,5 @@
*.out *.out
# Dependency directories (remove the comment below to include it) # Dependency directories (remove the comment below to include it)
# vendor/ vendor/

10
Makefile Normal file
View File

@ -0,0 +1,10 @@
.PHONY: wireformat
bin_path=./bin
wireformat:
go build -o $(bin_path)/wireformat cmd/wireformat/wireformat.go
fmt:
go fmt ./...

View File

@ -1,3 +0,0 @@
# dns-tools
dns relative tools like lookup or wireformat converter

0
bin/.gitkeep Normal file
View File

View File

@ -0,0 +1,38 @@
package main
import (
"errors"
"flag"
"io/ioutil"
"log"
"github.com/miekg/dns"
)
func main() {
file := flag.String("f", "", "file path to read hexa decimal wireformat data")
flag.Parse()
var body []byte
var err error
if *file != "" {
if *file == "-" {
*file = "/dev/stdin"
}
body, err = ioutil.ReadFile(*file)
if err != nil {
log.Fatalln(err)
}
msg := &dns.Msg{}
err = msg.Unpack(body)
if err != nil {
log.Fatalln(err)
}
log.Println(msg)
} else {
log.Println(errors.New("Too few argument pass"))
flag.Usage()
}
}

5
go.mod Normal file
View File

@ -0,0 +1,5 @@
module antoine-roux.ml/projects/go/dns-tools
go 1.15
require github.com/miekg/dns v1.1.35

18
go.sum Normal file
View File

@ -0,0 +1,18 @@
github.com/miekg/dns v1.1.35 h1:oTfOaDH+mZkdcgdIjH6yBajRGtIwcwcaR+rt23ZSrJs=
github.com/miekg/dns v1.1.35/go.mod h1:KNUDUusw/aVsxyTYZM1oqvCicbwhgbNgztCETuNZ7xM=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550 h1:ObdrDkeb4kJdCP557AjRjq69pTHfNouLtWZG7j9rPN8=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20190923162816-aa69164e4478 h1:l5EDrHhldLYb3ZRHDUhXF7Om7MvYXnkV9/iQNo1lX6g=
golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190924154521-2837fb4f24fe h1:6fAMxZRR6sl1Uq8U61gxU+kPTs2tR8uOySCbBP7BN/M=
golang.org/x/sys v0.0.0-20190924154521-2837fb4f24fe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/tools v0.0.0-20191216052735-49a3e744a425/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=

18
readme.md Normal file
View File

@ -0,0 +1,18 @@
# dns-tools
dns relative tools like lookup or wireformat converter
## build
`make wireformat`
## run
With get resolution
`echo -n 'q80BAAABAAAAAAAAA3d3dwdleGFtcGxlA2NvbQAAAQAB' | base64 -d | curl -sH 'content-type: application/dns-message' --data-binary @- https://cloudflare-dns.com/dns-query -o - | ./bin/wireformat -f -`
With post resolution
`curl -s -H accept: application/dns-message https://cloudflare-dns.com/dns-query?dns=q80BAAABAAAAAAAAA3d3dwdleGFtcGxlA2NvbQAAAQAB | ./bin/wireformat -f -`