ref: 1055b951f37e4424f8c759f8cca4677e4fd8f02f
parent: c994152a90f479a5f3165590f72b749017b6af3e
author: cinap_lenrek <[email protected]>
date: Mon May 19 19:23:08 EDT 2014
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.
--- a/sys/man/1/torrent
+++ b/sys/man/1/torrent
@@ -26,6 +26,9 @@
.B -i
.I peer-id
] [
+.B -A
+.I user-agent
+] [
.I file
]
.SH DESCRIPTION
@@ -114,9 +117,15 @@
.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
--- a/sys/src/cmd/ip/torrent.c
+++ b/sys/src/cmd/ip/torrent.c
@@ -54,6 +54,7 @@
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 @@
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 @@
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");
}
@@ -1216,6 +1221,9 @@
break;
case 'i':
strncpy((char*)peerid, EARGF(usage()), sizeof(peerid));
+ break;
+ case 'A':
+ useragent = EARGF(usage());
break;
default:
usage();