]> Sergey Matveev's repositories - btrtrc.git/blobdiff - torrent.go
Attribute accepted connection to holepunching when connect message is late
[btrtrc.git] / torrent.go
index 6cc2e87f1e6db865410a512c9125d631b3ed9e43..42a62fc1f3c99cbaa91508c97e85cd027eec930c 100644 (file)
@@ -2825,7 +2825,14 @@ func (t *Torrent) handleReceivedUtHolepunchMsg(msg utHolepunch.Msg, sender *Peer
                }
                return nil
        case utHolepunch.Connect:
-               t.logger.Printf("got holepunch connect request for %v from %p", msg.AddrPort, sender)
+               holepunchAddr := msg.AddrPort
+               t.logger.Printf("got holepunch connect request for %v from %p", holepunchAddr, sender)
+               if g.MapContains(t.cl.undialableWithoutHolepunch, holepunchAddr) {
+                       setAdd(&t.cl.undialableWithoutHolepunchDialedAfterHolepunchConnect, holepunchAddr)
+                       if g.MapContains(t.cl.accepted, holepunchAddr) {
+                               setAdd(&t.cl.probablyOnlyConnectedDueToHolepunch, holepunchAddr)
+                       }
+               }
                opts := outgoingConnOpts{
                        peerInfo: PeerInfo{
                                Addr:         msg.AddrPort,