mirror of
https://github.com/go-micro/go-micro.git
synced 2024-12-18 08:26:38 +02:00
parent
356448017f
commit
c6d352c832
@ -354,10 +354,10 @@ func (m *mdnsRegistry) GetService(service string, opts ...GetOption) ([]*Service
|
||||
addr := ""
|
||||
// prefer ipv4 addrs
|
||||
if len(e.AddrV4) > 0 {
|
||||
addr = e.AddrV4.String()
|
||||
addr = net.JoinHostPort(e.AddrV4.String(), fmt.Sprint(e.Port))
|
||||
// else use ipv6
|
||||
} else if len(e.AddrV6) > 0 {
|
||||
addr = "[" + e.AddrV6.String() + "]"
|
||||
addr = net.JoinHostPort(e.AddrV6.String(), fmt.Sprint(e.Port))
|
||||
} else {
|
||||
if logger.V(logger.InfoLevel, logger.DefaultLogger) {
|
||||
logger.Infof("[mdns]: invalid endpoint received: %v", e)
|
||||
@ -366,7 +366,7 @@ func (m *mdnsRegistry) GetService(service string, opts ...GetOption) ([]*Service
|
||||
}
|
||||
s.Nodes = append(s.Nodes, &Node{
|
||||
Id: strings.TrimSuffix(e.Name, "."+p.Service+"."+p.Domain+"."),
|
||||
Address: net.JoinHostPort(addr, fmt.Sprint(e.Port)),
|
||||
Address: addr,
|
||||
Metadata: txt.Metadata,
|
||||
})
|
||||
|
||||
@ -584,16 +584,16 @@ func (m *mdnsWatcher) Next() (*Result, error) {
|
||||
|
||||
var addr string
|
||||
if len(e.AddrV4) > 0 {
|
||||
addr = e.AddrV4.String()
|
||||
addr = net.JoinHostPort(e.AddrV4.String(), fmt.Sprint(e.Port))
|
||||
} else if len(e.AddrV6) > 0 {
|
||||
addr = "[" + e.AddrV6.String() + "]"
|
||||
addr = net.JoinHostPort(e.AddrV6.String(), fmt.Sprint(e.Port))
|
||||
} else {
|
||||
addr = e.Addr.String()
|
||||
}
|
||||
|
||||
service.Nodes = append(service.Nodes, &Node{
|
||||
Id: strings.TrimSuffix(e.Name, suffix),
|
||||
Address: net.JoinHostPort(addr, fmt.Sprint(e.Port)),
|
||||
Address: addr,
|
||||
Metadata: txt.Metadata,
|
||||
})
|
||||
|
||||
|
@ -52,6 +52,19 @@ func TestMDNS(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "test4",
|
||||
Version: "1.0.4",
|
||||
Nodes: []*Node{
|
||||
{
|
||||
Id: "test4-1",
|
||||
Address: "[::]:10004",
|
||||
Metadata: map[string]string{
|
||||
"foo4": "bar4",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
travis := os.Getenv("TRAVIS")
|
||||
@ -243,6 +256,19 @@ func TestWatcher(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "test4",
|
||||
Version: "1.0.4",
|
||||
Nodes: []*Node{
|
||||
{
|
||||
Id: "test4-1",
|
||||
Address: "[::]:10004",
|
||||
Metadata: map[string]string{
|
||||
"foo4": "bar4",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
testFn := func(service, s *Service) {
|
||||
|
Loading…
Reference in New Issue
Block a user