diff --git a/ChangeLog b/ChangeLog index 87fdd8ba..d803e4e0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2008-06-04 Tatsuhiro Tsujikawa + + Added --bt-request-peer-speed-limit option, which was a constant + SLOW_SPEED_THRESHOLD. + * src/ActivePeerConnectionCommand.cc + * src/ActivePeerConnectionCommand.h + * src/BtConstants.h + * src/HelpItemFactory.cc + * src/OptionHandlerFactory.cc + * src/PeerReceiveHandshakeCommand.cc + * src/option_processing.cc + * src/prefs.cc + * src/prefs.h + * src/usage_text.h + 2008-06-03 Tatsuhiro Tsujikawa Removed repeated call of getTopDirPath(). Instead, call it once and diff --git a/src/ActivePeerConnectionCommand.cc b/src/ActivePeerConnectionCommand.cc index a1249d91..a7b16aa4 100644 --- a/src/ActivePeerConnectionCommand.cc +++ b/src/ActivePeerConnectionCommand.cc @@ -60,7 +60,7 @@ ActivePeerConnectionCommand::ActivePeerConnectionCommand(int cuid, RequestGroupAware(requestGroup), interval(interval), e(e), - _thresholdSpeed(SLOW_SPEED_THRESHOLD), + _thresholdSpeed(e->option->getAsInt(PREF_BT_REQUEST_PEER_SPEED_LIMIT)), _numNewConnection(5) { unsigned int maxDownloadSpeed = e->option->getAsInt(PREF_MAX_DOWNLOAD_LIMIT); diff --git a/src/ActivePeerConnectionCommand.h b/src/ActivePeerConnectionCommand.h index cd8ad694..39b03380 100644 --- a/src/ActivePeerConnectionCommand.h +++ b/src/ActivePeerConnectionCommand.h @@ -68,11 +68,6 @@ public: void connectToPeer(const SharedHandle& peer); - void setThresholdSpeed(unsigned int speed) - { - _thresholdSpeed = speed; - } - void setNumNewConnection(size_t numNewConnection) { _numNewConnection = numNewConnection; diff --git a/src/BtConstants.h b/src/BtConstants.h index 10b932d4..53057f5f 100644 --- a/src/BtConstants.h +++ b/src/BtConstants.h @@ -51,6 +51,4 @@ typedef std::map Extensions; #define DEFAULT_LATENCY 1500 -#define SLOW_SPEED_THRESHOLD (50*1024) - #endif // _D_BT_CONSTANTS_ diff --git a/src/HelpItemFactory.cc b/src/HelpItemFactory.cc index 0a878461..7326ac23 100644 --- a/src/HelpItemFactory.cc +++ b/src/HelpItemFactory.cc @@ -374,6 +374,13 @@ TagContainerHandle HelpItemFactory::createHelpItems(const Option* op) item->addTag(TAG_BITTORRENT); tc->addItem(item); } + { + HelpItemHandle item(new HelpItem(PREF_BT_REQUEST_PEER_SPEED_LIMIT, + TEXT_BT_REQUEST_PEER_SPEED_LIMIT, + op->get(PREF_BT_REQUEST_PEER_SPEED_LIMIT))); + item->addTag(TAG_BITTORRENT); + tc->addItem(item); + } #endif // ENABLE_BITTORRENT #ifdef ENABLE_METALINK { diff --git a/src/OptionHandlerFactory.cc b/src/OptionHandlerFactory.cc index a68b4ed0..bd92f2db 100644 --- a/src/OptionHandlerFactory.cc +++ b/src/OptionHandlerFactory.cc @@ -126,6 +126,7 @@ OptionHandlers OptionHandlerFactory::createOptionHandlers() handlers.push_back(SH(new NumberOptionHandler(PREF_STOP, 0, INT32_MAX))); handlers.push_back(SH(new ParameterOptionHandler(PREF_BT_MIN_CRYPTO_LEVEL, V_PLAIN, V_ARC4))); handlers.push_back(SH(new BooleanOptionHandler(PREF_BT_REQUIRE_CRYPTO))); + handlers.push_back(SH(new NumberOptionHandler(PREF_BT_REQUEST_PEER_SPEED_LIMIT, 0))); handlers.push_back(SH(new CumulativeOptionHandler(PREF_HEADER, "\n"))); handlers.push_back(SH(new BooleanOptionHandler(PREF_QUIET))); #ifdef ENABLE_ASYNC_DNS diff --git a/src/PeerReceiveHandshakeCommand.cc b/src/PeerReceiveHandshakeCommand.cc index 3c4e411f..b275ae56 100644 --- a/src/PeerReceiveHandshakeCommand.cc +++ b/src/PeerReceiveHandshakeCommand.cc @@ -63,7 +63,7 @@ PeerReceiveHandshakeCommand::PeerReceiveHandshakeCommand(int32_t cuid, const SharedHandle& peerConnection): PeerAbstractCommand(cuid, peer, e, s), _peerConnection(peerConnection), - _thresholdSpeed(SLOW_SPEED_THRESHOLD) + _thresholdSpeed(e->option->getAsInt(PREF_BT_REQUEST_PEER_SPEED_LIMIT)) { if(_peerConnection.isNull()) { _peerConnection.reset(new PeerConnection(cuid, socket, e->option)); diff --git a/src/option_processing.cc b/src/option_processing.cc index e7603bb3..e0bcff6e 100644 --- a/src/option_processing.cc +++ b/src/option_processing.cc @@ -143,6 +143,7 @@ Option* createDefaultOption() op->put(PREF_DHT_FILE_PATH, Util::getHomeDir()+"/.aria2/dht.dat"); op->put(PREF_BT_MIN_CRYPTO_LEVEL, V_PLAIN); op->put(PREF_BT_REQUIRE_CRYPTO, V_FALSE); + op->put(PREF_BT_REQUEST_PEER_SPEED_LIMIT, "51200"); op->put(PREF_QUIET, V_FALSE); op->put(PREF_STOP, "0"); #ifdef ENABLE_ASYNC_DNS @@ -252,6 +253,7 @@ Option* option_processing(int argc, char* const argv[]) { PREF_DHT_ENTRY_POINT.c_str(), required_argument, &lopt, 29 }, { PREF_BT_MIN_CRYPTO_LEVEL.c_str(), required_argument, &lopt, 30 }, { PREF_BT_REQUIRE_CRYPTO.c_str(), required_argument, &lopt, 31 }, + { PREF_BT_REQUEST_PEER_SPEED_LIMIT.c_str(), required_argument, &lopt, 32 }, #endif // ENABLE_BITTORRENT #ifdef ENABLE_METALINK { PREF_METALINK_FILE.c_str(), required_argument, NULL, 'M' }, @@ -362,6 +364,9 @@ Option* option_processing(int argc, char* const argv[]) case 31: cmdstream << PREF_BT_REQUIRE_CRYPTO << "=" << optarg << "\n"; break; + case 32: + cmdstream << PREF_BT_REQUEST_PEER_SPEED_LIMIT << "=" << optarg << "\n"; + break; case 100: cmdstream << PREF_METALINK_VERSION << "=" << optarg << "\n"; break; diff --git a/src/prefs.cc b/src/prefs.cc index 03880234..d1327f62 100644 --- a/src/prefs.cc +++ b/src/prefs.cc @@ -247,6 +247,8 @@ const std::string V_PLAIN("plain"); const std::string V_ARC4("arc4"); // values:: true | false const std::string PREF_BT_REQUIRE_CRYPTO("bt-require-crypto"); +// values: 1*digit +const std::string PREF_BT_REQUEST_PEER_SPEED_LIMIT("bt-request-peer-speed-limit"); /** * Metalink related preferences diff --git a/src/prefs.h b/src/prefs.h index 9f8c9ac4..c72a9da5 100644 --- a/src/prefs.h +++ b/src/prefs.h @@ -251,6 +251,8 @@ extern const std::string V_PLAIN; extern const std::string V_ARC4; // values:: true | false extern const std::string PREF_BT_REQUIRE_CRYPTO; +// values: 1*digit +extern const std::string PREF_BT_REQUEST_PEER_SPEED_LIMIT; /** * Metalink related preferences diff --git a/src/usage_text.h b/src/usage_text.h index df853c37..d6451dfd 100644 --- a/src/usage_text.h +++ b/src/usage_text.h @@ -274,6 +274,11 @@ _(" --bt-require-crypto=true|false If true is given, aria2 doesn't accept and\n" " establish connection with legacy BitTorrent\n"\ " handshake. Thus aria2 always uses Obfuscation\n"\ " handshake.") +#define TEXT_BT_REQUEST_PEER_SPEED_LIMIT \ +_(" --bt-request-peer-speed-limit=SPEED In BitTorrent downloads, if the download\n"\ + " speed is lower than SPEED, aria2 initiates and\n"\ + " accepts connections ignoring max peer cap.\n"\ + " You can append K or M(1K = 1024, 1M = 1024K).") #define TEXT_METALINK_FILE \ _(" -M, --metalink-file=METALINK_FILE The file path to the .metalink file.") #define TEXT_METALINK_SERVERS \