handle ipv6 addresses
This commit is contained in:
@@ -2,6 +2,8 @@ package util
|
||||
|
||||
import (
|
||||
"net"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/chrislusf/seaweedfs/weed/glog"
|
||||
)
|
||||
@@ -33,3 +35,11 @@ func DetectedHostAddress() string {
|
||||
|
||||
return "localhost"
|
||||
}
|
||||
|
||||
func JoinHostPort(host string, port int) string {
|
||||
portStr := strconv.Itoa(port)
|
||||
if strings.HasPrefix(host, "[") && strings.HasSuffix(host, "]") {
|
||||
return host + ":" + portStr
|
||||
}
|
||||
return net.JoinHostPort(host, portStr)
|
||||
}
|
||||
Reference in New Issue
Block a user