libeech

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

commit 84e77364f46895cec2614f767a013028611f9962
parent e93c18236b4d74ace9d237ffaf1ec75b7c17ea72
Author: z3bra <contactatz3bradotorg>
Date:   Sat Feb 10 13:51:30 +0100

Factorize handshake checks functions

Diffstat:
libeech.c | 8+++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/libeech.c b/libeech.c @@ -346,12 +346,14 @@ netloop(struct torrent *t, int timeout) if (pfds.fds[i].revents & POLLIN) { /* receive and verify handshake */ if (!(pfds.p[i]->state & HANDSHAKERCVD)) { - if (pwphsrecv(pfds.p[i]) >= 68) + if (pwphsrecv(pfds.p[i]) >= 68 && !pwphsck(t, pfds.p[i]->buf, pfds.p[i]->buflen)) pfds.p[i]->state |= HANDSHAKERCVD; - if (!pwphsck(t, pfds.p[i]->buf, pfds.p[i]->buflen)) - pfds.p[i]->state |= CONNECTED; } } + + /* peer is now ready to exchange data */ + if (pfds.p[i]->state & HANDSHAKESENT && pfds.p[i]->state & HANDSHAKERCVD) + pfds.p[i]->state |= CONNECTED|SEEDING|LEECHING|AMCHOKING; } return npeer;