registry/mdns: fix nil host bug (#1703)
This commit is contained in:
parent
0327f30e3c
commit
cca8826a1f
@ -563,9 +563,7 @@ func (m *mdnsWatcher) Next() (*Result, error) {
|
|||||||
if len(m.wo.Service) > 0 && txt.Service != m.wo.Service {
|
if len(m.wo.Service) > 0 && txt.Service != m.wo.Service {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
var action string
|
var action string
|
||||||
|
|
||||||
if e.TTL == 0 {
|
if e.TTL == 0 {
|
||||||
action = "delete"
|
action = "delete"
|
||||||
} else {
|
} else {
|
||||||
@ -584,9 +582,18 @@ func (m *mdnsWatcher) Next() (*Result, error) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var addr string
|
||||||
|
if len(e.AddrV4) > 0 {
|
||||||
|
addr = e.AddrV4.String()
|
||||||
|
} else if len(e.AddrV6) > 0 {
|
||||||
|
addr = "[" + e.AddrV6.String() + "]"
|
||||||
|
} else {
|
||||||
|
addr = e.Addr.String()
|
||||||
|
}
|
||||||
|
|
||||||
service.Nodes = append(service.Nodes, &Node{
|
service.Nodes = append(service.Nodes, &Node{
|
||||||
Id: strings.TrimSuffix(e.Name, suffix),
|
Id: strings.TrimSuffix(e.Name, suffix),
|
||||||
Address: fmt.Sprintf("%s:%d", e.AddrV4.String(), e.Port),
|
Address: fmt.Sprintf("%s:%d", addr, e.Port),
|
||||||
Metadata: txt.Metadata,
|
Metadata: txt.Metadata,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user