Merge pull request #1660 from micro/bugfix/mdns_nil_host
Check ipv4 or ipv6 address is valid before assigning
This commit is contained in:
commit
1da8a640da
@ -353,10 +353,10 @@ func (m *mdnsRegistry) GetService(service string, opts ...GetOption) ([]*Service
|
|||||||
}
|
}
|
||||||
addr := ""
|
addr := ""
|
||||||
// prefer ipv4 addrs
|
// prefer ipv4 addrs
|
||||||
if e.AddrV4 != nil {
|
if len(e.AddrV4) > 0 {
|
||||||
addr = e.AddrV4.String()
|
addr = e.AddrV4.String()
|
||||||
// else use ipv6
|
// else use ipv6
|
||||||
} else if e.AddrV6 != nil {
|
} else if len(e.AddrV6) > 0 {
|
||||||
addr = "[" + e.AddrV6.String() + "]"
|
addr = "[" + e.AddrV6.String() + "]"
|
||||||
} else {
|
} else {
|
||||||
if logger.V(logger.InfoLevel, logger.DefaultLogger) {
|
if logger.V(logger.InfoLevel, logger.DefaultLogger) {
|
||||||
|
@ -34,7 +34,7 @@ type ServiceEntry struct {
|
|||||||
|
|
||||||
// complete is used to check if we have all the info we need
|
// complete is used to check if we have all the info we need
|
||||||
func (s *ServiceEntry) complete() bool {
|
func (s *ServiceEntry) complete() bool {
|
||||||
return (s.AddrV4 != nil || s.AddrV6 != nil || s.Addr != nil) && s.Port != 0 && s.hasTXT
|
return (len(s.AddrV4) > 0 || len(s.AddrV6) > 0 || len(s.Addr) > 0) && s.Port != 0 && s.hasTXT
|
||||||
}
|
}
|
||||||
|
|
||||||
// QueryParam is used to customize how a Lookup is performed
|
// QueryParam is used to customize how a Lookup is performed
|
||||||
|
Loading…
x
Reference in New Issue
Block a user