pass all the ip addresses back
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
a138364227
commit
d53d4f1647
|
@ -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)
|
||||
|
||||
|
|
22
dnstrace.go
22
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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue