instrumentation/hrktorrent: set local network limits in core if --limitlocal option...
authorP2P-Next <p2p-next@cs.pub.ro>
Mon, 9 Aug 2010 19:22:17 +0000 (22:22 +0300)
committerP2P-Next <p2p-next@cs.pub.ro>
Mon, 9 Aug 2010 19:22:17 +0000 (22:22 +0300)
instrumentation/hrktorrent/core.cpp

index c21bb64..f06f403 100644 (file)
@@ -240,23 +240,26 @@ CCore::Run()
 \r
        _session = new libtorrent::session(libtorrent::fingerprint("HT", MAJOR, MINOR, REVISION, TAG));\r
 \r
+       libtorrent::session_settings ss;\r
+\r
        if(Settings->GetI("upnp") > 0)\r
                _session->start_upnp();\r
 \r
        _session->listen_on(std::make_pair(Settings->GetI("minport"), Settings->GetI("maxport")));\r
+       if (Settings->GetI("limitlocal") > 0) {\r
+               ss.ignore_limits_on_local_network = false;\r
+       }\r
        if(Settings->GetI("maxup") > 0) {\r
                _session->set_upload_rate_limit(Settings->GetI("maxup")*1024);\r
-               _session->set_local_upload_rate_limit(Settings->GetI("maxup")*1024);\r
        }\r
-       if(Settings->GetI("maxdown") > 0){\r
+       if(Settings->GetI("maxdown") > 0) {\r
                _session->set_download_rate_limit(Settings->GetI("maxdown")*1024);\r
-               _session->set_local_download_rate_limit(Settings->GetI("maxdown")*1024);\r
        }\r
        try {\r
                libtorrent::add_torrent_params parms;\r
 \r
                boost::intrusive_ptr<libtorrent::torrent_info> info = new libtorrent::torrent_info(_argv[_argc-1]);\r
-               boost::filesystem::path p(Settings->GetS("downloaddir"));\r
+               boost::filesystem::path p(Settings->GetS("outputdir"));\r
                boost::filesystem::create_directory(p);\r
                if(!boost::filesystem::exists(p)) {\r
                        std::cerr << "Download directory does not exist/could not be created." << std::endl;\r
@@ -290,6 +293,9 @@ CCore::Run()
                _session->set_ip_filter(IPFilter->getFilter());\r
        }\r
 \r
+       /* add settings */\r
+       _session->set_settings(ss);\r
+\r
        ScheduleSignal(SIGINT);\r
        std::cout << "\"CTRL-C\" shuts hrktorrent down.\n" <<  std::endl;\r
 \r
@@ -318,4 +324,3 @@ CCore::VerbosePrint(std::string source, std::string message)
        std::cout << "[" << source << "] ";\r
        std::cout << message << std::endl;\r
 }\r
-\r