picotorrent / picotorrent

A tiny, hackable BitTorrent client.
https://picotorrent.org
MIT License
2.62k stars 183 forks source link

Change User agent from `PicoTorrent/x.y.z` to `PicoTorrent x.y.z` #786

Open rakleed opened 4 years ago

rakleed commented 4 years ago

Why are you using a slash between the name of the application and its version in the User agent? It seems to me that it is worth using a space in this case.

vktr commented 4 years ago

Do you have any evidence to support your claim that it is worth switching? Quoting the libtorrent documentation,

The recommended format of this string is: "client-name/client-version libtorrent/libtorrent-version"

So if anything we should add libtorrent/libtorrent-version to our user agent as well.

A quick look at the qBittorrent sources (which also uses libtorrent) will also reaffirm that we are currently using the correct format for our user agent.

https://github.com/qbittorrent/qBittorrent/blob/1e4c837d6c70a1ca0a738ed884357425bae9dcb1/src/base/bittorrent/session.cpp#L102

Arcitec commented 4 years ago

@vktr You are correct. User-agents always have a slash in it.

But it's definitely worth adding libtorrent to the string. Because certain trackers blacklist unknown torrent clients, or whitelist things like libtorrent-based clients. So it's very important.

vktr commented 4 years ago

I'm open for suggestions but my current opinion is that we should keep the user agent as-is since it is conforming to some standard at least. Regarding white/blacklists the only real solution is to contact the trackers that blocks PicoTorrent, have a discussion to see why it's blacklisted and then work from there to have our standards conforming user agent whitelisted.

Arcitec commented 4 years ago

@vktr For sure, but there are so many trackers that just use old, lazy lists of black/white-listed clients. So setting it to PicoTorrent/0.18.0 libtorrent/x.y.z would help compatibility. Can't expect old platforms to change. Most of them barely know what they're doing and just use the defaults in whatever tracker server they've installed.

It's correct to add libtorrent to the agent. That's the standard way to create new applications. Just look at what your own browser is sending: https://ipecho.net/extra (in my case Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36). That's because user agents should contain both the GUI (like Chrome or PicoTorrent) and the engine (like libtorrent or Safari).

Adding libtorrent should help compatibility. Otherwise we can expect PicoTorrent to be usable in maybe 5-10 years, which is how long it should take people to add its specific user-agent to all trackers. xD

Arcitec commented 4 years ago

For example, look at the Chrome user agent, which even has a (KHTML, like Gecko) section. Why the "like Gecko"? Precisely because of the issue that PicoTorrent is now facing: Inertia in the outside world, forcing Chrome to emulate other packages in their user agent to get compatibility.

This would be an improvement in compatibility and correctness:

PicoTorrent/0.18.0 libtorrent/x.y.z

This would be a silly (but massive) compatibility boost:

PicoTorrent/0.18.0 libtorrent/x.y.z (like qBitTorrent/x.y.z blabla) (but don't do that; just an example, that's nasty, and I'd rather people whitelist you than piggybacking off others).

Right now I might consider trying to build PicoTorrent myself and setting a different user agent. But just adding libtorrent to the string should already be enough to work in a lot more trackers.

vktr commented 4 years ago

Are you currently running into an issue with PicoTorrent being blacklisted? Would you mind sending me the tracker name at viktor@viktorelofsson.se? I'll be happy to open a discussion with the tracker people in order to have it whitelisted.

I know we had some blacklisting issues in the beginning (like 2015-16 when PicoTorrent was new) but I haven't had any issues reported about that in a long time now, and this issue is not talking about that either.

I'm somewhat open to adding some sort of compatibility option which would set the user agent to PicoTorrent/x.y.z libtorrent/x.y.z but I'd like some evidence on the user agent being an issue first, and also on adding the libtorrent/x.y.z solving that issue.

rakleed commented 4 years ago

@vktr, @VideoPlayerCode

Do you have any evidence to support your claim that it is worth switching? Use Space instead of a slash, such clients as uTorrent, Transmission, Tixati, MediaGet.

Screenshots

2020-03-07_22-06-42 2020-03-07_22-07-07

And usually developers write the name of the application, then a space, then a version. For example, in the Releases section of your application this is exactly what is written.

vktr commented 4 years ago

@Rakleed I think you're confusing things. That list seems to be taken from the Client column of some peer list, and that column usually comes from the Peer ID, not the User Agent.

rakleed commented 4 years ago

@vktr I do not fully understand some of the terms, so maybe I initially made the request incorrectly. But PicoTorrent in the Client list appears as PicoTorrent/x.y.z, and I would like it to appear as PicoTorrent x.y.z, like most other clients.

hvonw commented 3 years ago

@Rakleed you got it wrong. Peer ID and User-agent isn't the same thing. Also Peer ID is identifier is clientside.

https://github.com/picotorrent/picotorrent/blob/master/src/picotorrent/bittorrent/session.cpp#L182 As you can see, it already is as you want.

Peer ID is used for client identification. Most of the time, this identification is handled by the client-side. A UDP/HTTP tracker also can identify you by looking up your Peer ID,

http://bittorrent.org/beps/bep_0020.html + https://github.com/transmission/transmission/blob/master/libtransmission/clients.c#L600 https://github.com/arvidn/libtorrent/blob/RC_2_0/src/identify_client.cpp#L147 ..

User-agent is also an identifier. But it is used in HTTP(S) requests. In our case, it is used for BitTorrent tracker requests. (HTTP(S)) Check "http://bittorrent.org/beps/bep_0000.html" specifications for more info.