@@ -69,22 +69,23 @@ func LookupSRVCustom(name string, dnsResolver string, recurse bool) ([]*dns.SRV,
69
69
}
70
70
var records []* dns.SRV
71
71
for _ , ans := range r .Answer {
72
- srvRecord := * ans .(* dns.SRV )
73
- if recurse && net .ParseIP (srvRecord .Target ) == nil {
74
- m2 := dns.Msg {}
75
- m2 .SetQuestion (srvRecord .Target , dns .TypeA )
76
- m2 .RecursionDesired = true
77
- r2 , _ , err := c .Exchange (& m2 , dnsResolver )
78
- if err != nil {
79
- fmt .Fprintf (os .Stderr , "error: %v\n " , err )
80
- return nil , err
81
- }
82
- if len (r2 .Answer ) != 0 {
83
- aRecord := r2 .Answer [0 ].(* dns.A )
84
- srvRecord .Target = aRecord .A .String ()
72
+ if srvRecord , ok := ans .(* dns.SRV ); ok && srvRecord != nil {
73
+ if recurse && net .ParseIP (srvRecord .Target ) == nil {
74
+ m2 := dns.Msg {}
75
+ m2 .SetQuestion (srvRecord .Target , dns .TypeA )
76
+ m2 .RecursionDesired = true
77
+ r2 , _ , err := c .Exchange (& m2 , dnsResolver )
78
+ if err != nil {
79
+ fmt .Fprintf (os .Stderr , "error: %v\n " , err )
80
+ return nil , err
81
+ }
82
+ if len (r2 .Answer ) != 0 {
83
+ aRecord := r2 .Answer [0 ].(* dns.A )
84
+ srvRecord .Target = aRecord .A .String ()
85
+ }
85
86
}
87
+ records = append (records , srvRecord )
86
88
}
87
- records = append (records , & srvRecord )
88
89
}
89
90
return records , nil
90
91
}
0 commit comments