commit c58661dfe92d768c48bdbbac424bf6eadc039ebc
parent 86cd60370886168aaae24b2dcb13da237de12f97
Author: sin <sin@2f30.org>
Date: Mon, 21 Dec 2015 17:40:17 +0000
tracker updates
Diffstat:
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/tracker.c b/tracker.c
@@ -7,14 +7,14 @@
#include "storrent.h"
int
-tracker_get_peers(struct torrent *t, struct ben **peers)
+tracker_get_peers(struct torrent *t, struct ben **reply)
{
char *url, *host, *port, *path;
char *infohash, *id;
char buf[8192], *p;
int r, s;
- *peers = NULL;
+ *reply = NULL;
if ((url = parseurl(t->announcers[0].urls[0], &host, &port, &path)) < 0)
return -1;
@@ -36,13 +36,16 @@ tracker_get_peers(struct torrent *t, struct ben **peers)
if ((p = strnstr(buf, "\r\n\r\n", r))) {
p += 4;
r -= 4;
+ } else if ((p = strnstr(buf, "\n\n", r))) {
+ p += 2;
+ r -= 2;
} else {
p = buf;
}
- if (!bdecode(p, p + r, peers))
+ if (!bdecode(p, p + r, reply))
goto err0;
- bprint(*peers, 0);
+ bprint(*reply, 0);
free(url);
free(infohash);