summaryrefslogtreecommitdiffhomepage
path: root/pkg/server/grpc_server.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/server/grpc_server.go')
-rw-r--r--pkg/server/grpc_server.go11
1 files changed, 10 insertions, 1 deletions
diff --git a/pkg/server/grpc_server.go b/pkg/server/grpc_server.go
index 89bbb497..2d25734a 100644
--- a/pkg/server/grpc_server.go
+++ b/pkg/server/grpc_server.go
@@ -64,8 +64,9 @@ func (s *server) serve() error {
l := []net.Listener{}
var err error
for _, host := range strings.Split(s.hosts, ",") {
+ network, address := parseHost(host)
var lis net.Listener
- lis, err = net.Listen("tcp", host)
+ lis, err = net.Listen(network, address)
if err != nil {
log.WithFields(log.Fields{
"Topic": "grpc",
@@ -101,6 +102,14 @@ func (s *server) serve() error {
return nil
}
+func parseHost(host string) (string, string) {
+ const unixScheme = "unix://"
+ if strings.HasPrefix(host, unixScheme) {
+ return "unix", host[len(unixScheme):]
+ }
+ return "tcp", host
+}
+
func (s *server) ListPeer(r *api.ListPeerRequest, stream api.GobgpApi_ListPeerServer) error {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()