arvidn / libtorrent

an efficient feature complete C++ bittorrent implementation

Home Page:http://libtorrent.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Custom flag of peer

master255 opened this issue · comments

commented

@arvidn I want to add a flag (extension) for a peer that the peer can be url-seeded.
I already have a Java Pipeline Web Server. It remains to change the logic of the library so that it will automatically add some peers to url-seeds, according to the flag in the response.

Where can I find free flags in the library and which one should I use? I only need a binary flag.

commented

Okay. I found where to add my flag.
For the indication that the peer, can be url-seeded - I use the 17th bit.

*(ptr + 5) |= 0x10;

commented

In the end I decided not to use it.

Instead, I added a new parameter up in handshake. u is urlseed, p is port.

int const port = m_settings.get_int(settings_pack::urlseed_port);
if (port != 0) handshake["up"] = port;

It's as flexible and efficient as possible, and I would add that to the release (libtorrent).
It's only about 20 lines of code that don't really affect anything, but allows to transfer data via https protocol.