From 215f6f5bd3946888537df6130111dcc5f407673d Mon Sep 17 00:00:00 2001 From: P2P-Next Date: Wed, 18 Aug 2010 13:12:27 +0300 Subject: [PATCH] instrumentation/hrktorrent: add support for maximum connections --- instrumentation/hrktorrent/core.cpp | 3 +++ instrumentation/hrktorrent/main.cpp | 8 +++++++- instrumentation/hrktorrent/settings.cpp | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/instrumentation/hrktorrent/core.cpp b/instrumentation/hrktorrent/core.cpp index 013dd4d..b85cad7 100644 --- a/instrumentation/hrktorrent/core.cpp +++ b/instrumentation/hrktorrent/core.cpp @@ -309,6 +309,9 @@ CCore::Run() if(Settings->GetI("maxdown") > 0) { _session->set_download_rate_limit(Settings->GetI("maxdown")*1024); } + if(Settings->GetI("maxconnections") > 0) { + _session->set_max_connections(Settings->GetI("maxconnections")); + } try { libtorrent::add_torrent_params parms; diff --git a/instrumentation/hrktorrent/main.cpp b/instrumentation/hrktorrent/main.cpp index 9546d76..dca85d0 100644 --- a/instrumentation/hrktorrent/main.cpp +++ b/instrumentation/hrktorrent/main.cpp @@ -20,6 +20,8 @@ printusage(const char *argv0) std::cout << "\t-d, --maxdown \t\tdownload speed limit (in kb/s) (default: unlimited)\n"; std::cout << "\t-u, --maxup \t\tupload speed limit (in kb/s) (default: unlimited)\n"; + std::cout << "\t-c, --maxconnections \t\tlimit numer of connections (default: unlimited)\n"; + std::cout << "\t-l, --limitlocal\t\tlimit local network (default: off)\n"; std::cout << "\t-t, --nodht\t\t\tdisable dht (default: on)\n"; std::cout << "\t-n, --noupnp\t\t\tdisable upnp (default: on)\n"; @@ -55,13 +57,14 @@ parseargs(int argc, char** argv) {"maxport", 1, NULL, 'P'}, {"maxdown", 1, NULL, 'd'}, {"maxup", 1, NULL, 'u'}, + {"maxconnections", 1, NULL, 'c'}, {"forcereannounce", 1, NULL, 'f'}, {"outputdir", 1, NULL, 'o'}, {NULL, 0, NULL, 0} }; while (1) { - opt = getopt_long(argc, argv, "hiltnsvVp:P:d:u:f:o:", + opt = getopt_long(argc, argv, "hiltnsvVp:P:d:u:c:f:o:", long_options, &option_index); if (opt == -1) break; @@ -105,6 +108,9 @@ parseargs(int argc, char** argv) case 'u': Settings->Set("maxup", atoi(optarg)); break; + case 'c': + Settings->Set("maxconnections", atoi(optarg)); + break; case 'f': Settings->Set("forcereannounce", atoi(optarg)); break; diff --git a/instrumentation/hrktorrent/settings.cpp b/instrumentation/hrktorrent/settings.cpp index 5c3fa7e..8166139 100644 --- a/instrumentation/hrktorrent/settings.cpp +++ b/instrumentation/hrktorrent/settings.cpp @@ -12,6 +12,7 @@ CSettings::CSettings() Set("maxup", 0); Set("maxdown", 0); + Set("maxconnections", -1); Set("dht", 1); Set("upnp", 1); -- 2.20.1