2010-03-12 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

Use global option for DHTSetup.
	* src/DHTSetup.cc
	* src/DHTSetup.h
	* src/RequestGroup.cc
pull/1/head
Tatsuhiro Tsujikawa 2010-03-11 16:04:50 +00:00
parent dc059bfc29
commit 542a06de6d
4 changed files with 18 additions and 12 deletions

View File

@ -1,3 +1,10 @@
2010-03-12 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Use global option for DHTSetup.
* src/DHTSetup.cc
* src/DHTSetup.h
* src/RequestGroup.cc
2010-03-12 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Added bt-enable-lpt, reuse-uri

View File

@ -81,8 +81,7 @@ DHTSetup::DHTSetup():_logger(LogFactory::getInstance()) {}
DHTSetup::~DHTSetup() {}
void DHTSetup::setup(std::vector<Command*>& commands,
DownloadEngine* e, const Option* option)
void DHTSetup::setup(std::vector<Command*>& commands, DownloadEngine* e)
{
if(_initialized) {
return;
@ -94,7 +93,7 @@ void DHTSetup::setup(std::vector<Command*>& commands,
SharedHandle<DHTNode> localNode;
DHTRoutingTableDeserializer deserializer;
std::string dhtFile = option->get(PREF_DHT_FILE_PATH);
std::string dhtFile = e->option->get(PREF_DHT_FILE_PATH);
try {
std::ifstream in(dhtFile.c_str(), std::ios::binary);
if(!in) {
@ -112,7 +111,8 @@ void DHTSetup::setup(std::vector<Command*>& commands,
SharedHandle<DHTConnectionImpl> connection(new DHTConnectionImpl());
{
IntSequence seq = util::parseIntRange(option->get(PREF_DHT_LISTEN_PORT));
IntSequence seq =
util::parseIntRange(e->option->get(PREF_DHT_LISTEN_PORT));
uint16_t port;
if(!connection->bind(port, seq)) {
throw DL_ABORT_EX("Error occurred while binding port for DHT");
@ -195,10 +195,11 @@ void DHTSetup::setup(std::vector<Command*>& commands,
taskQueue->addPeriodicTask1(task);
}
if(!option->get(PREF_DHT_ENTRY_POINT_HOST).empty()) {
if(!e->option->get(PREF_DHT_ENTRY_POINT_HOST).empty()) {
{
std::pair<std::string, uint16_t> addr(option->get(PREF_DHT_ENTRY_POINT_HOST),
option->getAsInt(PREF_DHT_ENTRY_POINT_PORT));
std::pair<std::string, uint16_t> addr
(e->option->get(PREF_DHT_ENTRY_POINT_HOST),
e->option->getAsInt(PREF_DHT_ENTRY_POINT_PORT));
std::vector<std::pair<std::string, uint16_t> > entryPoints;
entryPoints.push_back(addr);
DHTEntryPointNameResolveCommand* command =

View File

@ -40,7 +40,6 @@
namespace aria2 {
class Logger;
class Option;
class DownloadEngine;
class Command;
@ -55,8 +54,7 @@ public:
~DHTSetup();
void setup(std::vector<Command*>& commands,
DownloadEngine* e, const Option* option);
void setup(std::vector<Command*>& commands, DownloadEngine* e);
static bool initialized();
};

View File

@ -274,7 +274,7 @@ void RequestGroup::createInitialCommand
if(metadataGetMode) {
if(_option->getAsBool(PREF_ENABLE_DHT)) {
std::vector<Command*> dhtCommands;
DHTSetup().setup(dhtCommands, e, _option.get());
DHTSetup().setup(dhtCommands, e);
e->addCommand(dhtCommands);
} else {
_logger->notice("For BitTorrent Magnet URI, enabling DHT is strongly"
@ -335,7 +335,7 @@ void RequestGroup::createInitialCommand
if(torrentAttrs[bittorrent::PRIVATE].i() == 0 &&
_option->getAsBool(PREF_ENABLE_DHT)) {
std::vector<Command*> dhtCommands;
DHTSetup().setup(dhtCommands, e, _option.get());
DHTSetup().setup(dhtCommands, e);
e->addCommand(dhtCommands);
if(!torrentAttrs[bittorrent::NODES].empty() && DHTSetup::initialized()) {
std::vector<std::pair<std::string, uint16_t> > entryPoints;