diff options
| author | Chris Lu <chris.lu@gmail.com> | 2021-09-07 16:43:54 -0700 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2021-09-07 16:43:54 -0700 |
| commit | 0128239c0f8829bb20edd1df257840dcbfa37c0e (patch) | |
| tree | 4bf3d7a7ffc313d2c8a8547326204a632d48c4a4 /weed/util | |
| parent | 35c8ea495fd21f7f10343717a5e1275782b7cae0 (diff) | |
| download | seaweedfs-0128239c0f8829bb20edd1df257840dcbfa37c0e.tar.xz seaweedfs-0128239c0f8829bb20edd1df257840dcbfa37c0e.zip | |
handle ipv6 addresses
Diffstat (limited to 'weed/util')
| -rw-r--r-- | weed/util/network.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/weed/util/network.go b/weed/util/network.go index 55a123667..f9fad7771 100644 --- a/weed/util/network.go +++ b/weed/util/network.go @@ -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) +}
\ No newline at end of file |
