Treat PORT messages with port of 0 to mean on the remote port

This commit is contained in:
Matt Joiner 2014-09-14 03:59:31 +10:00
parent bea5c1a502
commit 979192cbfd
1 changed files with 6 additions and 1 deletions

View File

@ -964,7 +964,12 @@ func (me *Client) connectionLoop(t *torrent, c *connection) error {
_, err = me.dHT.Ping(&net.UDPAddr{
IP: addr.IP,
Zone: addr.Zone,
Port: int(msg.Port),
Port: func() int {
if msg.Port == 0 {
return addr.Port
}
return int(msg.Port)
}(),
})
default:
err = fmt.Errorf("received unknown message type: %#v", msg.Type)