From 2c43b24d7df01e615276cfa556178a800591a9fb Mon Sep 17 00:00:00 2001 From: Dmytro Vovk Date: Thu, 5 Dec 2024 16:17:16 +0000 Subject: [PATCH] Revert "Enabled peers connection" --- torrent.go | 18 +++--------------- ut-holepunching_test.go | 2 +- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/torrent.go b/torrent.go index 20adc2353e..940f76d9f3 100644 --- a/torrent.go +++ b/torrent.go @@ -1746,7 +1746,7 @@ func (t *Torrent) openNewConns(lock bool) (initiated int) { receivedHolepunchConnect: false, HeaderObfuscationPolicy: t.cl.config.HeaderObfuscationPolicy, } - initiateConn(opts, false, false, false) + initiateConn(opts, false, false) initiated++ } @@ -2533,10 +2533,6 @@ func (t *Torrent) wantOutgoingConns(lock bool) bool { conns := t.peerConnsAsSlice(lock) defer conns.free() - if len(conns) < t.maxEstablishedConns { - return true - } - numOutgoingConns := conns.numOutgoingConns() numIncomingConns := len(conns) - numOutgoingConns @@ -3113,15 +3109,9 @@ func (t *Torrent) addHalfOpen(addrStr string, attemptKey *PeerInfo, lock bool) { // Start the process of connecting to the given peer for the given torrent if appropriate. I'm not // sure all the PeerInfo fields are being used. -func initiateConn(opts outgoingConnOpts, ignoreLimits bool, lock bool, lockCLient bool) { +func initiateConn(opts outgoingConnOpts, ignoreLimits bool, lock bool) { t := opts.t peer := opts.peerInfo - - if lockCLient { - t.cl.rLock() - defer t.cl.rUnlock() - } - if peer.Id == t.cl.peerID { return } @@ -3661,14 +3651,12 @@ func (t *Torrent) handleReceivedUtHolepunchMsg(msg utHolepunch.Msg, sender *Peer case utHolepunch.Connect: holepunchAddr := msg.AddrPort t.logger.Printf("got holepunch connect request for %v from %p", holepunchAddr, sender) - t.cl.lock() if g.MapContains(t.cl.undialableWithoutHolepunch, holepunchAddr) { setAdd(&t.cl.undialableWithoutHolepunchDialedAfterHolepunchConnect, holepunchAddr) if g.MapContains(t.cl.accepted, holepunchAddr) { setAdd(&t.cl.probablyOnlyConnectedDueToHolepunch, holepunchAddr) } } - t.cl.unlock() opts := outgoingConnOpts{ peerInfo: PeerInfo{ Addr: msg.AddrPort, @@ -3683,7 +3671,7 @@ func (t *Torrent) handleReceivedUtHolepunchMsg(msg utHolepunch.Msg, sender *Peer // encryption. So we will act normally. HeaderObfuscationPolicy: t.cl.config.HeaderObfuscationPolicy, } - initiateConn(opts, true, true, true) + initiateConn(opts, true, true) return nil case utHolepunch.Error: torrent.Add("holepunch error messages received", 1) diff --git a/ut-holepunching_test.go b/ut-holepunching_test.go index 4d98ece394..5e80a61774 100644 --- a/ut-holepunching_test.go +++ b/ut-holepunching_test.go @@ -119,7 +119,7 @@ func TestHolepunchConnect(t *testing.T) { requireRendezvous: true, skipHolepunchRendezvous: false, HeaderObfuscationPolicy: llg.cl.config.HeaderObfuscationPolicy, - }, true, true, true) + }, true, true) llg.cl.unlock() wg.Wait()