feat: Trace #162

Merged
sam merged 8 commits from trace into master 2022-12-10 17:51:50 +00:00
Showing only changes of commit a38a03c959 - Show all commits

16
main.go
View file

@ -91,12 +91,12 @@ func run(args []string) (opts *util.Options, code int, err error) {
fmt.Println(str)
if keepTracing {
var nothing []dns.RR
var records []dns.RR
if opts.Request.Name == "." {
nothing = resp.DNS.Answer
records = resp.DNS.Answer
} else {
nothing = resp.DNS.Ns
records = resp.DNS.Ns
}
want := func(rr dns.RR) bool {
@ -107,17 +107,17 @@ func run(args []string) (opts *util.Options, code int, err error) {
i := 0
for _, x := range nothing {
for _, x := range records {
if want(x) {
nothing[i] = x
records[i] = x
i++
}
}
nothing = nothing[:i]
nothing2 := nothing[r.Intn(len(nothing))]
records = records[:i]
randomRR := records[r.Intn(len(records))]
v := strings.Split(nothing2.String(), "\t")
v := strings.Split(randomRR.String(), "\t")
opts.Request.Server = strings.TrimSuffix(v[len(v)-1], ".")
opts.TLS = false