From: Matt Joiner Date: Tue, 12 Jul 2022 00:41:56 +0000 (+1000) Subject: Fix webrtcNetAddr.String for IPv6 X-Git-Tag: v1.47.0~6 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=a5877a938cac30031a8c9c2bf7e0c3eba14017c6;p=btrtrc.git Fix webrtcNetAddr.String for IPv6 (cherry picked from commit d37354e6743e905d42689e88068058dd45e5be43) --- diff --git a/webrtc.go b/webrtc.go index c217a510..4a86e892 100644 --- a/webrtc.go +++ b/webrtc.go @@ -1,8 +1,8 @@ package torrent import ( - "fmt" "net" + "strconv" "time" "github.com/anacrolix/torrent/webtorrent" @@ -30,9 +30,7 @@ func (webrtcNetAddr) Network() string { } func (me webrtcNetAddr) String() string { - // Probably makes sense to return the IP:port expected of most net.Addrs. I'm not sure if - // Address would be quoted for IPv6 already. If not, net.JoinHostPort might be appropriate. - return fmt.Sprintf("%s:%d", me.Address, me.Port) + return net.JoinHostPort(me.Address, strconv.FormatUint(uint64(me.Port), 10)) } func (me webrtcNetConn) LocalAddr() net.Addr {