summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/man/1/torrent11
-rw-r--r--sys/src/cmd/ip/torrent.c10
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;