qbittorrent / qBittorrent

qBittorrent BitTorrent client
https://www.qbittorrent.org
Other
28.24k stars 3.97k forks source link

PEX peers connecting with disabled PEX #10574

Open black-cerberon opened 5 years ago

black-cerberon commented 5 years ago

When PEX is disabled by settings, peers from PEX anyway connects to me. Please add autoban for peers from PEX. Thanks.

qBittorrent v.4.1.6 x64 (Win7) (6.1.760x)

Seeker2 commented 5 years ago

How do you know the peers are from Peer EXchange if you have PEX disabled?

black-cerberon commented 5 years ago

1 2

Seeker2 commented 5 years ago

Does the same thing happen if PEX is always disabled before adding the torrent to qBitTorrent?

Or did you previously have PEX enabled, then disabled it?

black-cerberon commented 5 years ago

DHT, PEX and LPD disabled in main settings for all torrents.

Seeker2 commented 5 years ago

So the bug, if indeed there is one (instead of working as designed), is in PEX itself?

Possible reason you see the PEX peer in your screenshot: An incoming peer that's presumably self-reporting as being a peer from PEX could be getting your qBitTorrent's ip:port from another peer's/seed's PEX list. In which case, they don't have PEX disabled even if you do.

black-cerberon commented 5 years ago

So the bug, if indeed there is one (instead of working as designed), is in PEX itself?

If peer Alice (with enabled PEX) connects to peer Bob (w/o PEX), she share Bob's IP:port over PEX to other peers and they connects to him "from PEX". I think it works that way.

Seeker2 commented 5 years ago

A problem arises if firewalled peers and seeds are also on the same tracker. They are part of the tracker's torrent swarm but cannot easily connect to each other. PEX plus uTP can sometimes let 2 firewalled peers connect to each other as long as they're "introduced" by a 3rd peer.

Even whether a peer first gets your ip from the tracker/s (typical only updates every 30 or 60 minutes) or PEX/DHT/LPD (updates as fast as once a min per peer/seed) can change whether it's a "PEX peer".

Piccirello commented 4 years ago

1 2

DHT, PEX and LPD disabled in main settings for all torrents.

@arvidn Is this in fact possible? Note that this woud've been libtorrent 1.1, though I'm more curious about 1.2.

arvidn commented 4 years ago

Hi. This is the first I hear about this. The way PEX is enabled (or disabled) in libtorrent is by constructing a "plugin" object that handles all PEX messages. This includes advertising support for it, parsing peers' advertised support, parsing incoming PEX messages and sending PEX messages. If this object is not constructed, any incoming advertise of support is ignored, and any incoming PEX message would probably lead to disconnect, but possibly just ignoring the message (worst case).

There is no message to, as a peer, declare yourself to have the X flag there. The only way is to have been received and parsed out of a PEX message.

I notice there is no flag for peers received over local-service-discovery. Does qbt, by any chance, max LSD peers with PEX peers? or is LSD also disabled in this case?

arvidn commented 4 years ago

oh, I see there's a row below referring to LSD

FranciscoPombal commented 4 years ago

This shouldn't be labled/titled "Feature Request". This is really a bug, and it is better to fix the underlying cause than to add a feature to attempt working around it.

@thalieht @black-cerberon can you change the titile/tags please?

Seeker2 commented 4 years ago

uTP hole-punching might be mislabeled as PEX even if PEX is disabled.

Also, the screenshot example shows the peer was an INCOMING connection, qBitTorrent may only be the receiver of the peer...not making outgoing connection attempts to ip:port values it received by PEX.

arvidn commented 4 years ago

does this happen when PEX is disabled on startup or just when it's disabled after starting a torrent?

The reason I ask is because whether a peer supports pex or not depends on whether the torrent it belongs to was started with PEX enabled. I don't think there's any way to turn off PEX for a torrent once it has started.

black-cerberon commented 4 years ago

@arvidn DHT/PEX/LSD disabled in my settings always.

ryannathans commented 4 years ago

@arvidn this is definitely occurring when PEX has been disabled for a very long time and new torrents are added yesterday where this issue is occurring

ryannathans commented 4 years ago

@Seeker2 this is occurring on incoming TCP connections in my screenshot

PEX not disabling

Seeker2 commented 4 years ago

In that screenshot, the connection is via TCP (BT connection type). This rules out uTP NAT hole-punching!

It's also an INCOMING connection -- qBitTorrent didn't initiate/create that connection. If it's a public torrent, where PEX, DHT, and LPD are all typically enabled for BitTorrent clients...everyone else's PEX is probably very active.

The big oddity/question here (which likely only people who read the source code can answer): How/why does qBitTorrent "think" the connection is from PEX?

philou-felin commented 3 years ago

As a "dumb" end-user, I find this "bug"(?) confusing.