Discussion:
[libtorrent] Graceful disruption of libtorrent by plugin
Bedeho Mender
2016-07-02 13:13:41 UTC
Permalink
Suppose a peer_plugin requires sending and receiving data to a peer,
but also wants to prevent libtorrent itself from sending and receiving
pieces to this peer.

We are currently using the following approach to achieve this:

Obstruct libtorrent uploading:
* send CHOCKED message in order to discourage inbound requests.
* cancel inbound requests in peer_plugin::on_request to make libtorrent
blind
to peer requests

Obstruct libtorrent downloading:
* send NOT-INTERESTED and CHOCKED message in order to discourage unchocking.
* cancel on_write_request to prevent libtorrent from requesting data.
* cancel on_piece to make libtorrent blind to inbound pieces.

Does this approach seem like the simplest and most efficient approach?

Arvid Norberg
2016-07-24 23:43:58 UTC
Permalink
to prevent downloading, you can set a torrent to upload-only mode.

to prevent handling incoming requests you can handle on_request() and
return true, this will tell libtorrent that your plugin already handled
this message and disable the default action.

to prevent libtorrent from sending requests, you could do the same thing to
on_unchoke(). Just do nothing and return true, this will effectively filter
any unchoke message you may receive. You have to keep in mind though that
this may make the two peers be in an inconsistent state. For instance the
peer sending the unchoke will still believe that you are unchoked, and may
have a more aggressive time-out in case you aren't sending any requests. If
you control both peers, having them never send an unchoke in the first
place might be a better approach, by setting both ends in upload-only mode.

If you intend to use the peer connection for transferring payload through
some extension message, it's probably better to still leverage the
choking/unchoking mechanism, and just implement write_request(). You can
send your extension message there and return true. In fact, to prevent
requests to go out (without affecting the choking/unchoking) you could also
just implement write_request() and just return true.
Post by Bedeho Mender
Suppose a peer_plugin requires sending and receiving data to a peer,
but also wants to prevent libtorrent itself from sending and receiving
pieces to this peer.
* send CHOCKED message in order to discourage inbound requests.
* cancel inbound requests in peer_plugin::on_request to make libtorrent
blind
to peer requests
* send NOT-INTERESTED and CHOCKED message in order to discourage unchocking.
* cancel on_write_request to prevent libtorrent from requesting data.
* cancel on_piece to make libtorrent blind to inbound pieces.
Does this approach seem like the simplest and most efficient approach?

------------------------------------------------------------------------------
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape
_______________________________________________
Libtorrent-discuss mailing list
https://lists.sourceforge.net/lists/listinfo/libtorrent-discuss
--
Arvid Norberg
Loading...