diff options
author | mischief <mischief@offblast.org> | 2014-02-01 12:04:30 -0800 |
---|---|---|
committer | mischief <mischief@offblast.org> | 2014-02-01 12:04:30 -0800 |
commit | abb4bad701e25836ebff6d8c8797710eb2a5ac27 (patch) | |
tree | 47c41013da91d529ed43553eb8117b5a929c8bc0 /sys | |
parent | ed9e9f98e9cc502c72b27c68612e9e187ec11e10 (diff) |
ip/torrent: print tracker errors/warnings in debug mode and allow setting peerid
Diffstat (limited to 'sys')
-rw-r--r-- | sys/man/1/torrent | 14 | ||||
-rw-r--r-- | sys/src/cmd/ip/torrent.c | 17 |
2 files changed, 29 insertions, 2 deletions
diff --git a/sys/man/1/torrent b/sys/man/1/torrent index 31cc848a6..d94623049 100644 --- a/sys/man/1/torrent +++ b/sys/man/1/torrent @@ -23,6 +23,9 @@ torrent \- bittorrent client ] [ .B -c ] [ +.B -i +.I peer-id +] [ .I file ] .SH DESCRIPTION @@ -104,6 +107,17 @@ To monitor the download progress, the option can be given to cause the completed and total number of pieces written as a line of text to standard-output in one second intervals. +.PP +The +.B -i +option allows you to set the 20-byte +.I peer-id +that is sent to trackers and peers. If less than 20 bytes, the +.I peer-id +will be padded on the right with random ASCII numbers. This is +useful to fool trackers that filter clients based on the +.I peer-id +. .SH EXAMPLES Create new torrent file .EX diff --git a/sys/src/cmd/ip/torrent.c b/sys/src/cmd/ip/torrent.c index 96d3d524a..f8b834c5f 100644 --- a/sys/src/cmd/ip/torrent.c +++ b/sys/src/cmd/ip/torrent.c @@ -853,6 +853,15 @@ webtracker(char *url) bparse(p, p+n, &d); free(p); } else if(debug) fprint(2, "tracker %s: %r\n", url); + /* check errors and warnings */ + if(p = dstr(dlook(d, "failure reason"))) { + if(debug) + fprint(2, "tracker failure: %s\n", p); + exits(0); + } + if(p = dstr(dlook(d, "warning message"))) + if(debug) + fprint(2, "tracker warning: %s\n", p); if(l = dlook(d, "peers")){ if(l->typ == 's') clients4((uchar*)l->str, l->len); @@ -1206,6 +1215,9 @@ main(int argc, char *argv[]) case 'd': debug++; break; + case 'i': + strncpy((char*)peerid, EARGF(usage()), sizeof(peerid)); + break; default: usage(); } ARGEND; @@ -1339,8 +1351,9 @@ main(int argc, char *argv[]) case -1: sysfatal("fork: %r"); case 0: - memmove(peerid, "-NF9001-", 8); - for(i=8; i<sizeof(peerid); i++) + if(peerid[0] == 0) + strncpy((char*)peerid, "-NF9001-", 9); + for(i=sizeof(peerid)-1; i >= 0 && peerid[i] == 0; i--) peerid[i] = nrand(10)+'0'; server(); for(; alist; alist = alist->next) |