feat: Trace #162
3 changed files with 37 additions and 10 deletions
|
@ -57,14 +57,14 @@ func ParseCLI(args []string, version string) (*util.Options, error) {
|
|||
|
||||
if opts.Trace {
|
||||
if opts.TLS || opts.HTTPS || opts.QUIC {
|
||||
opts.Logger.Warn("Every query after the root query will only use UDP.")
|
||||
opts.Logger.Warn("Every query after the root query will only use UDP/TCP")
|
||||
}
|
||||
|
||||
if opts.Reverse {
|
||||
opts.Logger.Error("Reverse queries are not currently supported")
|
||||
}
|
||||
|
||||
opts.RD = false
|
||||
opts.RD = true
|
||||
}
|
||||
|
||||
opts.Logger.Info("Options fully populated")
|
||||
|
|
10
cmd/dig.go
10
cmd/dig.go
|
@ -27,6 +27,16 @@ func ParseDig(arg string, opts *util.Options) error {
|
|||
switch arg {
|
||||
case "trace", "notrace":
|
||||
opts.Trace = isNo
|
||||
if isNo == true {
|
||||
opts.DNSSEC = true
|
||||
opts.Display.Comments = false
|
||||
opts.Display.Question = false
|
||||
opts.Display.Opt = false
|
||||
opts.Display.Answer = true
|
||||
opts.Display.Authority = true
|
||||
opts.Display.Additional = false
|
||||
opts.Display.Statistics = false
|
||||
}
|
||||
// Set DNS query flags
|
||||
case "aa", "aaflag", "aaonly":
|
||||
opts.AA = isNo
|
||||
|
|
33
main.go
33
main.go
|
@ -91,23 +91,40 @@ func run(args []string) (opts *util.Options, code int, err error) {
|
|||
fmt.Println(str)
|
||||
|
||||
if keepTracing {
|
||||
// This part is the part that is broken
|
||||
/*
|
||||
this needs to be a random answer that comes from the DNS answers.
|
||||
Since there is no recursion, and the answers are never recursive. The records should all be NS records.
|
||||
var nothing []dns.RR
|
||||
|
||||
https://pkg.go.dev/github.com/miekg/dns@v1.1.50
|
||||
*/
|
||||
if opts.Request.Name == "." {
|
||||
opts.Request.Server = resp.DNS.Answer[r.Intn(len(resp.DNS.Answer))].Header().Name
|
||||
nothing = resp.DNS.Answer
|
||||
} else {
|
||||
opts.Request.Server = resp.DNS.Answer[r.Intn(len(resp.DNS.Ns))].Header().Name
|
||||
nothing = resp.DNS.Ns
|
||||
}
|
||||
|
||||
want := func(rr dns.RR) bool {
|
||||
temp := strings.Split(rr.String(), "\t")
|
||||
|
||||
return temp[len(temp)-2] == "NS"
|
||||
}
|
||||
|
||||
i := 0
|
||||
|
||||
for _, x := range nothing {
|
||||
if want(x) {
|
||||
nothing[i] = x
|
||||
i++
|
||||
}
|
||||
}
|
||||
|
||||
nothing = nothing[:i]
|
||||
nothing2 := nothing[r.Intn(len(nothing))]
|
||||
|
||||
v := strings.Split(nothing2.String(), "\t")
|
||||
opts.Request.Server = strings.TrimSuffix(v[len(v)-1], ".")
|
||||
|
||||
opts.TLS = false
|
||||
opts.HTTPS = false
|
||||
opts.QUIC = false
|
||||
|
||||
opts.RD = false
|
||||
opts.Request.Port = 53
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue