This specifies the number of wanted peers to the tracker and is configurable from the commandline flag "--numwant". Closes GH-5master
@@ -215,11 +215,11 @@ httptr_req(struct torrent *tp, struct tr_tier *tr, const char *aurl, | |||||
snprintf(url, sizeof(url), | snprintf(url, sizeof(url), | ||||
"%s%cinfo_hash=%s&peer_id=%s&key=%ld%s%s&port=%d&uploaded=%llu" | "%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, | aurl, qc, e_hash, e_id, tr_key, | ||||
tr_ip_arg == NULL ? "" : "&ip=", tr_ip_arg == NULL ? "" : tr_ip_arg, | tr_ip_arg == NULL ? "" : "&ip=", tr_ip_arg == NULL ? "" : tr_ip_arg, | ||||
net_port, tp->net->uploaded, tp->net->downloaded, | 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]); | event == TR_EV_EMPTY ? "" : "&event=", m_tr_events[event]); | ||||
struct httptr_req *treq = btpd_calloc(1, sizeof(*treq)); | struct httptr_req *treq = btpd_calloc(1, sizeof(*treq)); | ||||
@@ -159,6 +159,9 @@ usage(void) | |||||
"\tPreallocate disk space in chunks of n kB. Default is 2048.\n" | "\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" | "\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" | "\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"); | "\n"); | ||||
exit(1); | exit(1); | ||||
} | } | ||||
@@ -178,6 +181,7 @@ static struct option longopts[] = { | |||||
{ "empty-start", no_argument, &longval, 9 }, | { "empty-start", no_argument, &longval, 9 }, | ||||
{ "ip", required_argument, &longval, 10 }, | { "ip", required_argument, &longval, 10 }, | ||||
{ "logmask", required_argument, &longval, 11 }, | { "logmask", required_argument, &longval, 11 }, | ||||
{ "numwant", required_argument, &longval, 12 }, | |||||
{ "help", no_argument, &longval, 128 }, | { "help", no_argument, &longval, 128 }, | ||||
{ NULL, 0, NULL, 0 } | { NULL, 0, NULL, 0 } | ||||
}; | }; | ||||
@@ -239,6 +243,9 @@ main(int argc, char **argv) | |||||
case 11: | case 11: | ||||
btpd_logmask = atoi(optarg); | btpd_logmask = atoi(optarg); | ||||
break; | break; | ||||
case 12: | |||||
net_numwant = (unsigned)atoi(optarg); | |||||
break; | |||||
default: | default: | ||||
usage(); | usage(); | ||||
} | } | ||||
@@ -13,3 +13,4 @@ int empty_start = 0; | |||||
const char *tr_ip_arg; | const char *tr_ip_arg; | ||||
int net_ipv4 = 1; | int net_ipv4 = 1; | ||||
int net_ipv6 = 0; | int net_ipv6 = 0; | ||||
unsigned net_numwant = 50; |
@@ -13,5 +13,6 @@ extern int ipcprot; | |||||
extern int empty_start; | extern int empty_start; | ||||
extern const char *tr_ip_arg; | extern const char *tr_ip_arg; | ||||
extern int net_ipv4, net_ipv6; | extern int net_ipv4, net_ipv6; | ||||
extern unsigned net_numwant; | |||||
#endif | #endif |