mirror of
https://github.com/go-micro/go-micro.git
synced 2025-06-12 22:07:47 +02:00
bunch of other ipv6 fixes
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
@ -18,6 +18,7 @@ import (
|
||||
"github.com/micro/go-micro/transport"
|
||||
"github.com/micro/go-micro/util/addr"
|
||||
log "github.com/micro/go-micro/util/log"
|
||||
mnet "github.com/micro/go-micro/util/net"
|
||||
)
|
||||
|
||||
type rpcServer struct {
|
||||
@ -293,15 +294,12 @@ func (s *rpcServer) Register() error {
|
||||
advt = config.Address
|
||||
}
|
||||
|
||||
if idx := strings.Count(advt, ":"); idx > 1 {
|
||||
if cnt := strings.Count(advt, ":"); cnt >= 1 {
|
||||
// ipv6 address in format [host]:port or ipv4 host:port
|
||||
host, port, err = net.SplitHostPort(advt)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if host == "::" {
|
||||
host = fmt.Sprintf("[%s]", host)
|
||||
}
|
||||
} else {
|
||||
host = advt
|
||||
}
|
||||
@ -320,7 +318,7 @@ func (s *rpcServer) Register() error {
|
||||
// register service
|
||||
node := ®istry.Node{
|
||||
Id: config.Name + "-" + config.Id,
|
||||
Address: fmt.Sprintf("%s:%s", addr, port),
|
||||
Address: mnet.HostPort(addr, port),
|
||||
Metadata: md,
|
||||
}
|
||||
|
||||
@ -434,15 +432,12 @@ func (s *rpcServer) Deregister() error {
|
||||
advt = config.Address
|
||||
}
|
||||
|
||||
if idx := strings.Count(advt, ":"); idx > 1 {
|
||||
if cnt := strings.Count(advt, ":"); cnt >= 1 {
|
||||
// ipv6 address in format [host]:port or ipv4 host:port
|
||||
host, port, err = net.SplitHostPort(advt)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if host == "::" {
|
||||
host = fmt.Sprintf("[%s]", host)
|
||||
}
|
||||
} else {
|
||||
host = advt
|
||||
}
|
||||
@ -454,7 +449,7 @@ func (s *rpcServer) Deregister() error {
|
||||
|
||||
node := ®istry.Node{
|
||||
Id: config.Name + "-" + config.Id,
|
||||
Address: fmt.Sprintf("%s:%s", addr, port),
|
||||
Address: mnet.HostPort(addr, port),
|
||||
}
|
||||
|
||||
service := ®istry.Service{
|
||||
|
Reference in New Issue
Block a user