]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Treat PORT messages with port of 0 to mean on the remote port
authorMatt Joiner <anacrolix@gmail.com>
Sat, 13 Sep 2014 17:59:31 +0000 (03:59 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Sat, 13 Sep 2014 17:59:31 +0000 (03:59 +1000)
client.go

index 66667e2be1ef01ff49d09a31b1f1d55225555e02..406f5dde6820694850ae6272bf8c154fa27cf9e1 100644 (file)
--- a/client.go
+++ b/client.go
@@ -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)