diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2014-05-19 23:23:08 +0200 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2014-05-19 23:23:08 +0200 |
commit | 1055b951f37e4424f8c759f8cca4677e4fd8f02f (patch) | |
tree | 834962cc24af75bebc47ccf739af69ece8148d54 /sys | |
parent | c994152a90f479a5f3165590f72b749017b6af3e (diff) |
ip/torrent: fix usage, add -A option to set user-agent
trackers do like the new default Mozilla/5.0 (compatible)
user agent. so force useragent to hjdicks and give option
to override it in case trackers get even more clever in
the future.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/man/1/torrent | 11 | ||||
-rw-r--r-- | sys/src/cmd/ip/torrent.c | 10 |
2 files changed, 19 insertions, 2 deletions
diff --git a/sys/man/1/torrent b/sys/man/1/torrent index f7708a4ae..e71964e86 100644 --- a/sys/man/1/torrent +++ b/sys/man/1/torrent @@ -26,6 +26,9 @@ torrent \- bittorrent client .B -i .I peer-id ] [ +.B -A +.I user-agent +] [ .I file ] .SH DESCRIPTION @@ -114,9 +117,15 @@ 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 +will be padded on the right with random ASCII numbers. The +.B -A +option allows setting the http +.I user-agent +string that is used to contact the tracker. These options are useful to fool trackers that filter clients based on the .I peer-id +or +.I user-agent . .SH EXAMPLES Create new torrent file diff --git a/sys/src/cmd/ip/torrent.c b/sys/src/cmd/ip/torrent.c index 36e437f21..d84ea4fb2 100644 --- a/sys/src/cmd/ip/torrent.c +++ b/sys/src/cmd/ip/torrent.c @@ -54,6 +54,7 @@ int killgroup = -1; int port = 6881; char *deftrack = "http://exodus.desync.com/announce"; char *mntweb = "/mnt/web"; +char *useragent = "hjdicks"; uchar infohash[20]; uchar peerid[20]; int blocksize; @@ -726,6 +727,10 @@ hopen(char *url, ...) close(ctlfd); return -1; } + if(useragent != nil && useragent[0] != '\0'){ + n = snprint(buf, sizeof buf, "useragent %s", useragent); + write(ctlfd, buf, n); + } snprint(buf, sizeof buf, "%s/%d/body", mntweb, conn); if((fd = open(buf, OREAD)) < 0) goto ErrOut; @@ -1157,7 +1162,7 @@ void usage(void) { fprint(2, "usage: %s [ -vsdpc ] [ -m mtpt ] [ -t tracker-url ] " - "[ -w webseed-url ] [ file ]\n", argv0); + "[ -w webseed-url ] [ -i peerid ] [ -A useragent ] [ file ]\n", argv0); exits("usage"); } @@ -1217,6 +1222,9 @@ main(int argc, char *argv[]) case 'i': strncpy((char*)peerid, EARGF(usage()), sizeof(peerid)); break; + case 'A': + useragent = EARGF(usage()); + break; default: usage(); } ARGEND; |