about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMarq Schneider <queueRAM@gmail.com>2010-08-12 21:14:06 -0500
committerMarq Schneider <queueRAM@gmail.com>2010-08-12 21:14:06 -0500
commit9667cf0694245ead296a4d79a1579448a625fd60 (patch)
treef86fa1a71912e97f02cc2b3a1118b52f4f4e610f
parent64060294ab58dfd07a95a24a1500602421748da9 (diff)
downloadbtpd-9667cf0694245ead296a4d79a1579448a625fd60.tar.gz
btpd-9667cf0694245ead296a4d79a1579448a625fd60.zip
Added 'numwant' to the tracker request parameters.
This specifies the number of wanted peers to the tracker and is
configurable from the commandline flag "--numwant".

Closes GH-5
-rw-r--r--btpd/http_tr_if.c4
-rw-r--r--btpd/main.c7
-rw-r--r--btpd/opts.c1
-rw-r--r--btpd/opts.h1
4 files changed, 11 insertions, 2 deletions
diff --git a/btpd/http_tr_if.c b/btpd/http_tr_if.c
index f7fd551..fabf1b7 100644
--- a/btpd/http_tr_if.c
+++ b/btpd/http_tr_if.c
@@ -215,11 +215,11 @@ httptr_req(struct torrent *tp, struct tr_tier *tr, const char *aurl,
 
     snprintf(url, sizeof(url),
         "%s%cinfo_hash=%s&peer_id=%s&key=%ld%s%s&port=%d&uploaded=%llu"
-        "&downloaded=%llu&left=%llu&compact=1%s%s",
+        "&downloaded=%llu&left=%llu&compact=1&numwant=%u%s%s",
         aurl, qc, e_hash, e_id, tr_key,
         tr_ip_arg == NULL ? "" : "&ip=", tr_ip_arg == NULL ? "" : tr_ip_arg,
         net_port, tp->net->uploaded, tp->net->downloaded,
-        (long long)tp->total_length - cm_content(tp),
+        (long long)tp->total_length - cm_content(tp), net_numwant,
         event == TR_EV_EMPTY ? "" : "&event=", m_tr_events[event]);
 
     struct httptr_req *treq = btpd_calloc(1, sizeof(*treq));
diff --git a/btpd/main.c b/btpd/main.c
index 3946592..55bb73e 100644
--- a/btpd/main.c
+++ b/btpd/main.c
@@ -159,6 +159,9 @@ usage(void)
         "\tPreallocate disk space in chunks of n kB. Default is 2048.\n"
         "\tNote that n will be rounded up to the closest multiple of the\n"
         "\ttorrent piece size. If n is zero no preallocation will be done.\n"
+        "\n"
+        "--numwant n\n"
+        "\tSet the number of peers to fetch on each request. Default is 50.\n"
         "\n");
     exit(1);
 }
@@ -178,6 +181,7 @@ static struct option longopts[] = {
     { "empty-start", no_argument,       &longval,       9 },
     { "ip", required_argument,          &longval,       10 },
     { "logmask", required_argument,     &longval,       11 },
+    { "numwant", required_argument,     &longval,       12 },
     { "help",   no_argument,            &longval,       128 },
     { NULL,     0,                      NULL,           0 }
 };
@@ -239,6 +243,9 @@ main(int argc, char **argv)
             case 11:
                 btpd_logmask = atoi(optarg);
                 break;
+            case 12:
+                net_numwant = (unsigned)atoi(optarg);
+                break;
             default:
                 usage();
             }
diff --git a/btpd/opts.c b/btpd/opts.c
index 05fb8e2..1b92bc4 100644
--- a/btpd/opts.c
+++ b/btpd/opts.c
@@ -13,3 +13,4 @@ int empty_start = 0;
 const char *tr_ip_arg;
 int net_ipv4 = 1;
 int net_ipv6 = 0;
+unsigned net_numwant = 50;
diff --git a/btpd/opts.h b/btpd/opts.h
index 04c3a36..d06e731 100644
--- a/btpd/opts.h
+++ b/btpd/opts.h
@@ -13,5 +13,6 @@ extern int ipcprot;
 extern int empty_start;
 extern const char *tr_ip_arg;
 extern int net_ipv4, net_ipv6;
+extern unsigned net_numwant;
 
 #endif