cmd/dockerd: use strings.Cut()
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
19cd5ff164
commit
5008409b5c
1 changed files with 3 additions and 5 deletions
|
@ -662,13 +662,11 @@ func loadListeners(cli *DaemonCli, serverConfig *apiserver.Config) ([]string, er
|
|||
|
||||
for i := 0; i < len(serverConfig.Hosts); i++ {
|
||||
protoAddr := serverConfig.Hosts[i]
|
||||
protoAddrParts := strings.SplitN(serverConfig.Hosts[i], "://", 2)
|
||||
if len(protoAddrParts) != 2 {
|
||||
proto, addr, ok := strings.Cut(protoAddr, "://")
|
||||
if !ok || addr == "" {
|
||||
return nil, fmt.Errorf("bad format %s, expected PROTO://ADDR", protoAddr)
|
||||
}
|
||||
|
||||
proto, addr := protoAddrParts[0], protoAddrParts[1]
|
||||
|
||||
// It's a bad idea to bind to TCP without tlsverify.
|
||||
authEnabled := serverConfig.TLSConfig != nil && serverConfig.TLSConfig.ClientAuth == tls.RequireAndVerifyClientCert
|
||||
if proto == "tcp" && !authEnabled {
|
||||
|
@ -719,7 +717,7 @@ func loadListeners(cli *DaemonCli, serverConfig *apiserver.Config) ([]string, er
|
|||
return nil, err
|
||||
}
|
||||
logrus.Debugf("Listener created for HTTP on %s (%s)", proto, addr)
|
||||
hosts = append(hosts, protoAddrParts[1])
|
||||
hosts = append(hosts, addr)
|
||||
cli.api.Accept(addr, ls...)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue