diff --git a/connection_handler.go b/connection_handler.go index e8dbc6d..e1350a7 100644 --- a/connection_handler.go +++ b/connection_handler.go @@ -73,7 +73,7 @@ func HandleConnection(conn *net.TCPConn) { conn.Close() return } - ipaddr := dns.Field(dnsRR, 1) + ipaddr := dns.Field(dnsRR[1], 1) log.Println("Client claims to be: ", ipaddr) log.Println("Serving to IPv6 client:", ipv6client) diff --git a/dnstrace.go b/dnstrace.go index 39282cb..7e71cab 100644 --- a/dnstrace.go +++ b/dnstrace.go @@ -38,7 +38,7 @@ func colorize(s interface{}, color int, enabled bool) string { return fmt.Sprintf("\x1b[%dm%v\x1b[0m", color, s) } -func Dnstrace(hostname string, qtypestr string) dns.RR { +func Dnstrace(hostname string, qtypestr string) []dns.RR { // color := flag.Bool("color", true, "Enable/disable colors") color := true @@ -63,7 +63,7 @@ func Dnstrace(hostname string, qtypestr string) dns.RR { o.SetUDPSize(dns.DefaultMsgSize) m.Extra = append(m.Extra, o) - c := client.New() + c := client.New(1) c.Client.Timeout = 500 * time.Millisecond t := client.Tracer{ GotIntermediaryResponse: func(i int, m *dns.Msg, rs client.Responses, rtype client.ResponseType) { @@ -142,18 +142,22 @@ func Dnstrace(hostname string, qtypestr string) dns.RR { log.Println() log.Printf(col(";; Cold best path time: %s\n\n", cGray), rtt) - for _, rr := range r.Answer { - log.Println(rr) + for i, rr := range r.Answer { + log.Println("r.Answer =", i, rr) } - for _, rr := range r.Answer { - return rr - } - return nil + return r.Answer + // for _, rr := range r.Answer { + // return rr + // } + // return nil } func ResolveIPv6hostname(hostname string) *net.TCPAddr { dnsRR := Dnstrace(hostname, "AAAA") - aaaa := dns.Field(dnsRR, 1) + if (dnsRR == nil) { + return nil + } + aaaa := dns.Field(dnsRR[1], 1) localTCPAddr, _ := net.ResolveTCPAddr("tcp", aaaa) return localTCPAddr }