ip/torrent: print tracker errors/warnings in debug mode and allow setting peerid
This commit is contained in:
parent
ed9e9f98e9
commit
abb4bad701
2 changed files with 29 additions and 2 deletions
|
@ -23,6 +23,9 @@ torrent \- bittorrent client
|
||||||
] [
|
] [
|
||||||
.B -c
|
.B -c
|
||||||
] [
|
] [
|
||||||
|
.B -i
|
||||||
|
.I peer-id
|
||||||
|
] [
|
||||||
.I file
|
.I file
|
||||||
]
|
]
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
|
@ -104,6 +107,17 @@ To monitor the download progress, the
|
||||||
option can be given to cause the completed and total number of
|
option can be given to cause the completed and total number of
|
||||||
pieces written as a line of text to standard-output in one
|
pieces written as a line of text to standard-output in one
|
||||||
second intervals.
|
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
|
.SH EXAMPLES
|
||||||
Create new torrent file
|
Create new torrent file
|
||||||
.EX
|
.EX
|
||||||
|
|
|
@ -853,6 +853,15 @@ webtracker(char *url)
|
||||||
bparse(p, p+n, &d);
|
bparse(p, p+n, &d);
|
||||||
free(p);
|
free(p);
|
||||||
} else if(debug) fprint(2, "tracker %s: %r\n", url);
|
} 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 = dlook(d, "peers")){
|
||||||
if(l->typ == 's')
|
if(l->typ == 's')
|
||||||
clients4((uchar*)l->str, l->len);
|
clients4((uchar*)l->str, l->len);
|
||||||
|
@ -1206,6 +1215,9 @@ main(int argc, char *argv[])
|
||||||
case 'd':
|
case 'd':
|
||||||
debug++;
|
debug++;
|
||||||
break;
|
break;
|
||||||
|
case 'i':
|
||||||
|
strncpy((char*)peerid, EARGF(usage()), sizeof(peerid));
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
usage();
|
usage();
|
||||||
} ARGEND;
|
} ARGEND;
|
||||||
|
@ -1339,8 +1351,9 @@ main(int argc, char *argv[])
|
||||||
case -1:
|
case -1:
|
||||||
sysfatal("fork: %r");
|
sysfatal("fork: %r");
|
||||||
case 0:
|
case 0:
|
||||||
memmove(peerid, "-NF9001-", 8);
|
if(peerid[0] == 0)
|
||||||
for(i=8; i<sizeof(peerid); i++)
|
strncpy((char*)peerid, "-NF9001-", 9);
|
||||||
|
for(i=sizeof(peerid)-1; i >= 0 && peerid[i] == 0; i--)
|
||||||
peerid[i] = nrand(10)+'0';
|
peerid[i] = nrand(10)+'0';
|
||||||
server();
|
server();
|
||||||
for(; alist; alist = alist->next)
|
for(; alist; alist = alist->next)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue