commit
b0112086d6
|
@ -522,12 +522,13 @@ func configureClientListeners(cfg *Config) (sctxs map[string]*serveCtx, err erro
|
||||||
return nil, fmt.Errorf("TLS key/cert (--cert-file, --key-file) must be provided for client url %s with HTTPs scheme", u.String())
|
return nil, fmt.Errorf("TLS key/cert (--cert-file, --key-file) must be provided for client url %s with HTTPs scheme", u.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
proto := "tcp"
|
network := "tcp"
|
||||||
addr := u.Host
|
addr := u.Host
|
||||||
if u.Scheme == "unix" || u.Scheme == "unixs" {
|
if u.Scheme == "unix" || u.Scheme == "unixs" {
|
||||||
proto = "unix"
|
network = "unix"
|
||||||
addr = u.Host + u.Path
|
addr = u.Host + u.Path
|
||||||
}
|
}
|
||||||
|
sctx.network = network
|
||||||
|
|
||||||
sctx.secure = u.Scheme == "https" || u.Scheme == "unixs"
|
sctx.secure = u.Scheme == "https" || u.Scheme == "unixs"
|
||||||
sctx.insecure = !sctx.secure
|
sctx.insecure = !sctx.secure
|
||||||
|
@ -537,7 +538,7 @@ func configureClientListeners(cfg *Config) (sctxs map[string]*serveCtx, err erro
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if sctx.l, err = net.Listen(proto, addr); err != nil {
|
if sctx.l, err = net.Listen(network, addr); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
// net.Listener will rewrite ipv4 0.0.0.0 to ipv6 [::], breaking
|
// net.Listener will rewrite ipv4 0.0.0.0 to ipv6 [::], breaking
|
||||||
|
@ -559,8 +560,8 @@ func configureClientListeners(cfg *Config) (sctxs map[string]*serveCtx, err erro
|
||||||
sctx.l = transport.LimitListener(sctx.l, int(fdLimit-reservedInternalFDNum))
|
sctx.l = transport.LimitListener(sctx.l, int(fdLimit-reservedInternalFDNum))
|
||||||
}
|
}
|
||||||
|
|
||||||
if proto == "tcp" {
|
if network == "tcp" {
|
||||||
if sctx.l, err = transport.NewKeepAliveListener(sctx.l, "tcp", nil); err != nil {
|
if sctx.l, err = transport.NewKeepAliveListener(sctx.l, network, nil); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,6 +50,7 @@ type serveCtx struct {
|
||||||
lg *zap.Logger
|
lg *zap.Logger
|
||||||
l net.Listener
|
l net.Listener
|
||||||
addr string
|
addr string
|
||||||
|
network string
|
||||||
secure bool
|
secure bool
|
||||||
insecure bool
|
insecure bool
|
||||||
|
|
||||||
|
@ -217,7 +218,14 @@ type registerHandlerFunc func(context.Context, *gw.ServeMux, *grpc.ClientConn) e
|
||||||
|
|
||||||
func (sctx *serveCtx) registerGateway(opts []grpc.DialOption) (*gw.ServeMux, error) {
|
func (sctx *serveCtx) registerGateway(opts []grpc.DialOption) (*gw.ServeMux, error) {
|
||||||
ctx := sctx.ctx
|
ctx := sctx.ctx
|
||||||
conn, err := grpc.DialContext(ctx, sctx.addr, opts...)
|
|
||||||
|
addr := sctx.addr
|
||||||
|
// explictly define unix network for gRPC socket support
|
||||||
|
if network := sctx.network; network == "unix" {
|
||||||
|
addr = fmt.Sprintf("%s://%s", network, addr)
|
||||||
|
}
|
||||||
|
|
||||||
|
conn, err := grpc.DialContext(ctx, addr, opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue