libeech

BitTorrent library
git clone git://z3bra.org/libeech.git
Log | Files | Refs | README | LICENSE

commit a4a521c672ec7664c591e2fc30fde889300e9496
parent 4616e4a455bc12ababe1bf987375cdfb89327654
Author: z3bra <contactatz3bradotorg>
Date:   Fri Jun 29 21:03:32 +0200

Send INTERESTED message when leeching

Diffstat:
libeech.c | 22++++++++++++++++++++++
1 file changed, 22 insertions(+), 0 deletions(-)
diff --git a/libeech.c b/libeech.c @@ -421,6 +421,22 @@ pwpbf(struct torrent *t, struct peer *p) return send(p->fd, m, l + 5, MSG_NOSIGNAL); } +static ssize_t +pwpinterest(struct peer *p, int interested) +{ + char m[MSGSIZ]; + + memset(m, 0, MSGSIZ); + + /* Message length */ + m[3] = 1; + + /* Message type */ + m[4] = interested ? 2 : 3; + + return send(p->fd, m, 5, MSG_NOSIGNAL); +} + static int pwptx(struct torrent *t, struct peer *p) { @@ -430,6 +446,12 @@ pwptx(struct torrent *t, struct peer *p) pwpbf(t, p); p->state |= HANDSHAKESENT; } + + if (p->state & LEECHING && !(p->state & AMINTERESTED)) { + pwpinterest(p, 1); + p->state |= AMINTERESTED; + } + return 0; }