mirror of
https://github.com/go-micro/go-micro.git
synced 2025-05-31 21:59:42 +02:00
IPV6 too many colons in address net.SplitHostPort need ipv6 address in [host]:port format
This commit is contained in:
parent
e155029a4b
commit
ed690ed838
@ -13,6 +13,7 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
proto "github.com/asim/go-micro/plugins/broker/grpc/v4/proto"
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"go-micro.dev/v4/broker"
|
"go-micro.dev/v4/broker"
|
||||||
"go-micro.dev/v4/cmd"
|
"go-micro.dev/v4/cmd"
|
||||||
@ -23,7 +24,6 @@ import (
|
|||||||
maddr "go-micro.dev/v4/util/addr"
|
maddr "go-micro.dev/v4/util/addr"
|
||||||
mnet "go-micro.dev/v4/util/net"
|
mnet "go-micro.dev/v4/util/net"
|
||||||
mls "go-micro.dev/v4/util/tls"
|
mls "go-micro.dev/v4/util/tls"
|
||||||
proto "github.com/asim/go-micro/plugins/broker/grpc/v4/proto"
|
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
"google.golang.org/grpc/credentials"
|
"google.golang.org/grpc/credentials"
|
||||||
)
|
)
|
||||||
@ -505,7 +505,7 @@ func (h *grpcBroker) Subscribe(topic string, handler broker.Handler, opts ...bro
|
|||||||
// register service
|
// register service
|
||||||
node := ®istry.Node{
|
node := ®istry.Node{
|
||||||
Id: id,
|
Id: id,
|
||||||
Address: fmt.Sprintf("%s:%d", addr, port),
|
Address: net.JoinHostPort(addr, fmt.Sprint(port)),
|
||||||
Metadata: map[string]string{
|
Metadata: map[string]string{
|
||||||
"secure": fmt.Sprintf("%t", secure),
|
"secure": fmt.Sprintf("%t", secure),
|
||||||
},
|
},
|
||||||
|
@ -2,12 +2,13 @@ package consul
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"go-micro.dev/v4/registry"
|
|
||||||
regutil "go-micro.dev/v4/util/registry"
|
|
||||||
"github.com/hashicorp/consul/api"
|
"github.com/hashicorp/consul/api"
|
||||||
"github.com/hashicorp/consul/api/watch"
|
"github.com/hashicorp/consul/api/watch"
|
||||||
|
"go-micro.dev/v4/registry"
|
||||||
|
regutil "go-micro.dev/v4/util/registry"
|
||||||
)
|
)
|
||||||
|
|
||||||
type consulWatcher struct {
|
type consulWatcher struct {
|
||||||
@ -44,7 +45,7 @@ func newConsulWatcher(cr *consulRegistry, opts ...registry.WatchOption) (registr
|
|||||||
}
|
}
|
||||||
|
|
||||||
wp.Handler = cw.handle
|
wp.Handler = cw.handle
|
||||||
go wp.RunWithClientAndHclog(cr.Client(),wp.Logger)
|
go wp.RunWithClientAndHclog(cr.Client(), wp.Logger)
|
||||||
cw.wp = wp
|
cw.wp = wp
|
||||||
|
|
||||||
return cw, nil
|
return cw, nil
|
||||||
@ -102,7 +103,7 @@ func (cw *consulWatcher) serviceHandler(idx uint64, data interface{}) {
|
|||||||
|
|
||||||
svc.Nodes = append(svc.Nodes, ®istry.Node{
|
svc.Nodes = append(svc.Nodes, ®istry.Node{
|
||||||
Id: id,
|
Id: id,
|
||||||
Address: fmt.Sprintf("%s:%d", address, e.Service.Port),
|
Address: net.JoinHostPort(address, fmt.Sprint(e.Service.Port)),
|
||||||
Metadata: decodeMetadata(e.Service.Tags),
|
Metadata: decodeMetadata(e.Service.Tags),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -48,12 +48,12 @@ func appToService(app *fargo.Application) []*registry.Service {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
host, _, _ := net.SplitHostPort(addr)
|
host, _, _ := net.SplitHostPort(addr)
|
||||||
|
|
||||||
// append node
|
// append node
|
||||||
service.Nodes = append(service.Nodes, ®istry.Node{
|
service.Nodes = append(service.Nodes, ®istry.Node{
|
||||||
Id: id,
|
Id: id,
|
||||||
Address: fmt.Sprintf("%s:%d", host, port),
|
Address: net.JoinHostPort(host, fmt.Sprint(port)),
|
||||||
Metadata: metadata,
|
Metadata: metadata,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ func (d *dnsSelector) Select(service string, opts ...selector.SelectOption) (sel
|
|||||||
for _, node := range srv {
|
for _, node := range srv {
|
||||||
nodes = append(nodes, ®istry.Node{
|
nodes = append(nodes, ®istry.Node{
|
||||||
Id: node.Target,
|
Id: node.Target,
|
||||||
Address: fmt.Sprintf("%s:%d", node.Target, node.Port),
|
Address: net.JoinHostPort(node.Target, fmt.Sprint(node.Port)),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ package http
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@ -36,7 +37,7 @@ func serviceDef(opts server.Options) *registry.Service {
|
|||||||
|
|
||||||
node := ®istry.Node{
|
node := ®istry.Node{
|
||||||
Id: opts.Name + "-" + opts.Id,
|
Id: opts.Name + "-" + opts.Id,
|
||||||
Address: fmt.Sprintf("%s:%d", addr, port),
|
Address: net.JoinHostPort(addr, fmt.Sprint(port)),
|
||||||
Metadata: opts.Metadata,
|
Metadata: opts.Metadata,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,9 +15,9 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
"go-micro.dev/v4/logger"
|
"go-micro.dev/v4/logger"
|
||||||
"go-micro.dev/v4/util/mdns"
|
"go-micro.dev/v4/util/mdns"
|
||||||
"github.com/google/uuid"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -366,7 +366,7 @@ func (m *mdnsRegistry) GetService(service string, opts ...GetOption) ([]*Service
|
|||||||
}
|
}
|
||||||
s.Nodes = append(s.Nodes, &Node{
|
s.Nodes = append(s.Nodes, &Node{
|
||||||
Id: strings.TrimSuffix(e.Name, "."+p.Service+"."+p.Domain+"."),
|
Id: strings.TrimSuffix(e.Name, "."+p.Service+"."+p.Domain+"."),
|
||||||
Address: fmt.Sprintf("%s:%d", addr, e.Port),
|
Address: net.JoinHostPort(addr, fmt.Sprint(e.Port)),
|
||||||
Metadata: txt.Metadata,
|
Metadata: txt.Metadata,
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -593,7 +593,7 @@ func (m *mdnsWatcher) Next() (*Result, error) {
|
|||||||
|
|
||||||
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", addr, e.Port),
|
Address: net.JoinHostPort(addr, fmt.Sprint(e.Port)),
|
||||||
Metadata: txt.Metadata,
|
Metadata: txt.Metadata,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@ package web
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"fmt"
|
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
@ -13,6 +12,7 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/urfave/cli/v2"
|
||||||
"go-micro.dev/v4"
|
"go-micro.dev/v4"
|
||||||
"go-micro.dev/v4/logger"
|
"go-micro.dev/v4/logger"
|
||||||
"go-micro.dev/v4/registry"
|
"go-micro.dev/v4/registry"
|
||||||
@ -22,7 +22,6 @@ import (
|
|||||||
mnet "go-micro.dev/v4/util/net"
|
mnet "go-micro.dev/v4/util/net"
|
||||||
signalutil "go-micro.dev/v4/util/signal"
|
signalutil "go-micro.dev/v4/util/signal"
|
||||||
mls "go-micro.dev/v4/util/tls"
|
mls "go-micro.dev/v4/util/tls"
|
||||||
"github.com/urfave/cli/v2"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type service struct {
|
type service struct {
|
||||||
@ -85,7 +84,7 @@ func (s *service) genSrv() *registry.Service {
|
|||||||
Version: s.opts.Version,
|
Version: s.opts.Version,
|
||||||
Nodes: []*registry.Node{{
|
Nodes: []*registry.Node{{
|
||||||
Id: s.opts.Id,
|
Id: s.opts.Id,
|
||||||
Address: fmt.Sprintf("%s:%s", addr, port),
|
Address: net.JoinHostPort(addr, port),
|
||||||
Metadata: s.opts.Metadata,
|
Metadata: s.opts.Metadata,
|
||||||
}},
|
}},
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user