mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #9354 from hexfusion/u_sock
embed: explicitly define unix proto
This commit is contained in:
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())
|
||||
}
|
||||
|
||||
proto := "tcp"
|
||||
network := "tcp"
|
||||
addr := u.Host
|
||||
if u.Scheme == "unix" || u.Scheme == "unixs" {
|
||||
proto = "unix"
|
||||
network = "unix"
|
||||
addr = u.Host + u.Path
|
||||
}
|
||||
sctx.network = network
|
||||
|
||||
sctx.secure = u.Scheme == "https" || u.Scheme == "unixs"
|
||||
sctx.insecure = !sctx.secure
|
||||
@ -537,7 +538,7 @@ func configureClientListeners(cfg *Config) (sctxs map[string]*serveCtx, err erro
|
||||
continue
|
||||
}
|
||||
|
||||
if sctx.l, err = net.Listen(proto, addr); err != nil {
|
||||
if sctx.l, err = net.Listen(network, addr); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// 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))
|
||||
}
|
||||
|
||||
if proto == "tcp" {
|
||||
if sctx.l, err = transport.NewKeepAliveListener(sctx.l, "tcp", nil); err != nil {
|
||||
if network == "tcp" {
|
||||
if sctx.l, err = transport.NewKeepAliveListener(sctx.l, network, nil); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
@ -50,6 +50,7 @@ type serveCtx struct {
|
||||
lg *zap.Logger
|
||||
l net.Listener
|
||||
addr string
|
||||
network string
|
||||
secure 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) {
|
||||
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 {
|
||||
return nil, err
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user