From: Matt Joiner Date: Tue, 2 Dec 2014 05:35:39 +0000 (-0600) Subject: Update to use utp package redesign X-Git-Tag: v1.0.0~1439 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=351bc3e50452e772315ffec6f5d3fa27cee0606f;p=btrtrc.git Update to use utp package redesign --- diff --git a/client.go b/client.go index 24af34da..6ac5a229 100644 --- a/client.go +++ b/client.go @@ -426,9 +426,15 @@ func NewClient(cfg *Config) (cl *Client, err error) { cl.listeners = append(cl.listeners, l) go cl.acceptConnections(l, false) } - var utpL *utp.UTPListener + var utpL *utp.Listener if !cfg.DisableUTP { - utpL, err = utp.Listen("utp", listenAddr()) + var utpAddr *utp.Addr + utpAddr, err = utp.ResolveAddr("utp", listenAddr()) + if err != nil { + err = fmt.Errorf("error resolving utp listen addr: %s", err) + return + } + utpL, err = utp.Listen("utp", utpAddr) if err != nil { return } @@ -881,10 +887,9 @@ func (me *Client) runConnection(sock net.Conn, torrent *torrent, discovery peerS }) } if conn.PeerExtensionBytes[7]&0x01 != 0 && me.dHT != nil { - addr, _ := me.dHT.LocalAddr().(*net.UDPAddr) conn.Post(pp.Message{ Type: pp.Port, - Port: uint16(addr.Port), + Port: uint16(AddrPort(me.dHT.LocalAddr())), }) } if torrent.haveInfo() {