diff options
-rw-r--r-- | server/server.go | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/server/server.go b/server/server.go index a6d663a7..9d59684f 100644 --- a/server/server.go +++ b/server/server.go @@ -132,11 +132,10 @@ func listenAndAccept(address string, port uint32, ch chan *net.TCPConn) (*net.TC proto := "tcp4" if ip := net.ParseIP(address); ip == nil { return nil, fmt.Errorf("can't listen on %s", address) - } else if strings.Contains(address, ":") { - address = fmt.Sprintf("[%s]", address) + } else if ip.To4() == nil { proto = "tcp6" } - addr, err := net.ResolveTCPAddr(proto, fmt.Sprintf("%s:%d", address, port)) + addr, err := net.ResolveTCPAddr(proto, net.JoinHostPort(address, strconv.Itoa(int(port)))) if err != nil { return nil, err } |