Log which peer contributed what to a piece. Do not try to download the
same piece from the same peers. Don't download at all from peers implicated
in 3 bad pieces. When a previously bad piece has been downloaded successfully
the bad peer(s) can be found and banned.
struct peer is now peer and meta_peer. meta_peer can be used as
a handle that won't be affected if a peer vanishes. The meta_peers
are kept in a hash table to enable fast lookup by peer id.
Btpd can now use both ipv4 and ipv6. The new options -4 and -6 toggles
use of ip v4 and v6 respectively. They are both used by default.
Remove restrictions on the --ip option since the spec allows to be a
dns name. Ultimately this option may need to be changed on a per
tracker/torrent basis.
Strangely such connections are not entirely uncommon. Added a hand shake
time out of 60 seconds to resolve this.
Added a peer_on_tick function which is used to monitor peers for different
timeouts. Timestamps are compared against the reborn btpd_seconds.
The issue has been reported by Ludvig Omholt and Arnaud Bergeron.
network buffers for requests are now allocated as they're needed. Before
they were allocated at the same time as their corresponding piece. This
lowers btpd's memory consumption.
* Renamed the policy* files to upload* and download*.
* The upload (un)choker is now global instead of per torrent. The algorithm
is not yet implemented however.
To be continued...
* The peer rates are now only updated when data transfer is enabled
in the corresponding direction. They are also computed differently
from before. The rates are computed in the bw callback once a second.
This facilitates later improvements in the choke algorithm.
message when we no longer have any pending requests. This fixes a bug
where two uniterest messages were sent to a peer that was no longer
wanted in endgame.
be shared by several peers. At least in end game.
* Link blocks with the peers we are loading them from and vice versa.
* Limit the number of requests / peer in end game too.
* Improve end game by using some sort of round robin for block requests.
writing to a peer. If more requests arrive they will be ignored.
When all pieces have been sent to the peer, in order for it not to
wait on the ignored requests, its state will be reset by a choke
followed by an unchoke message.
Without this limit there was no bound on how much memory btpd would
consume to satisfy a greedy peer.
* Use the new net_bufs where it makes sense.
* Take advantage of the reference count on net_bufs and only allocate
the (un)choke and (un)interest messages once.
information on what data they hold, making it unnecessary to have
other lists tracking that information. Also they now have a reference
count, making it possible to use the same buffer on many peers.
This is only a start though. I've just done enough for btpd to work,
I haven't taken advantage of the reference count yet.
The net code now calls the peer code when it has read a full message.
This has mostly involved moving code from net.c to peer.c.
* Added torrent_piece_size helper function.