@@ -662,13 +662,11 @@ func loadListeners(cli *DaemonCli, serverConfig *apiserver.Config) ([]string, er
662662
663663 for i := 0 ; i < len (serverConfig .Hosts ); i ++ {
664664 protoAddr := serverConfig .Hosts [i ]
665- protoAddrParts := strings .SplitN ( serverConfig . Hosts [ i ] , "://" , 2 )
666- if len ( protoAddrParts ) != 2 {
665+ proto , addr , ok := strings .Cut ( protoAddr , "://" )
666+ if ! ok || addr == "" {
667667 return nil , fmt .Errorf ("bad format %s, expected PROTO://ADDR" , protoAddr )
668668 }
669669
670- proto , addr := protoAddrParts [0 ], protoAddrParts [1 ]
671-
672670 // It's a bad idea to bind to TCP without tlsverify.
673671 authEnabled := serverConfig .TLSConfig != nil && serverConfig .TLSConfig .ClientAuth == tls .RequireAndVerifyClientCert
674672 if proto == "tcp" && ! authEnabled {
@@ -719,7 +717,7 @@ func loadListeners(cli *DaemonCli, serverConfig *apiserver.Config) ([]string, er
719717 return nil , err
720718 }
721719 logrus .Debugf ("Listener created for HTTP on %s (%s)" , proto , addr )
722- hosts = append (hosts , protoAddrParts [ 1 ] )
720+ hosts = append (hosts , addr )
723721 cli .api .Accept (addr , ls ... )
724722 }
725723
0 commit comments