Merge pull request #9354 from hexfusion/u_sock

embed: explicitly define unix proto
This commit is contained in:
Gyuho Lee
2018-04-19 08:16:38 -07:00
committed by GitHub
2 changed files with 15 additions and 6 deletions

View File

@@ -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
}
}