mirror of https://github.com/aria2/aria2
2010-03-12 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Use global option for DHTSetup. * src/DHTSetup.cc * src/DHTSetup.h * src/RequestGroup.ccpull/1/head
parent
dc059bfc29
commit
542a06de6d
|
@ -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>
|
2010-03-12 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
Added bt-enable-lpt, reuse-uri
|
Added bt-enable-lpt, reuse-uri
|
||||||
|
|
|
@ -81,8 +81,7 @@ DHTSetup::DHTSetup():_logger(LogFactory::getInstance()) {}
|
||||||
|
|
||||||
DHTSetup::~DHTSetup() {}
|
DHTSetup::~DHTSetup() {}
|
||||||
|
|
||||||
void DHTSetup::setup(std::vector<Command*>& commands,
|
void DHTSetup::setup(std::vector<Command*>& commands, DownloadEngine* e)
|
||||||
DownloadEngine* e, const Option* option)
|
|
||||||
{
|
{
|
||||||
if(_initialized) {
|
if(_initialized) {
|
||||||
return;
|
return;
|
||||||
|
@ -94,7 +93,7 @@ void DHTSetup::setup(std::vector<Command*>& commands,
|
||||||
SharedHandle<DHTNode> localNode;
|
SharedHandle<DHTNode> localNode;
|
||||||
|
|
||||||
DHTRoutingTableDeserializer deserializer;
|
DHTRoutingTableDeserializer deserializer;
|
||||||
std::string dhtFile = option->get(PREF_DHT_FILE_PATH);
|
std::string dhtFile = e->option->get(PREF_DHT_FILE_PATH);
|
||||||
try {
|
try {
|
||||||
std::ifstream in(dhtFile.c_str(), std::ios::binary);
|
std::ifstream in(dhtFile.c_str(), std::ios::binary);
|
||||||
if(!in) {
|
if(!in) {
|
||||||
|
@ -112,7 +111,8 @@ void DHTSetup::setup(std::vector<Command*>& commands,
|
||||||
|
|
||||||
SharedHandle<DHTConnectionImpl> connection(new DHTConnectionImpl());
|
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;
|
uint16_t port;
|
||||||
if(!connection->bind(port, seq)) {
|
if(!connection->bind(port, seq)) {
|
||||||
throw DL_ABORT_EX("Error occurred while binding port for DHT");
|
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);
|
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),
|
std::pair<std::string, uint16_t> addr
|
||||||
option->getAsInt(PREF_DHT_ENTRY_POINT_PORT));
|
(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;
|
std::vector<std::pair<std::string, uint16_t> > entryPoints;
|
||||||
entryPoints.push_back(addr);
|
entryPoints.push_back(addr);
|
||||||
DHTEntryPointNameResolveCommand* command =
|
DHTEntryPointNameResolveCommand* command =
|
||||||
|
|
|
@ -40,7 +40,6 @@
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
class Logger;
|
class Logger;
|
||||||
class Option;
|
|
||||||
class DownloadEngine;
|
class DownloadEngine;
|
||||||
class Command;
|
class Command;
|
||||||
|
|
||||||
|
@ -55,8 +54,7 @@ public:
|
||||||
|
|
||||||
~DHTSetup();
|
~DHTSetup();
|
||||||
|
|
||||||
void setup(std::vector<Command*>& commands,
|
void setup(std::vector<Command*>& commands, DownloadEngine* e);
|
||||||
DownloadEngine* e, const Option* option);
|
|
||||||
|
|
||||||
static bool initialized();
|
static bool initialized();
|
||||||
};
|
};
|
||||||
|
|
|
@ -274,7 +274,7 @@ void RequestGroup::createInitialCommand
|
||||||
if(metadataGetMode) {
|
if(metadataGetMode) {
|
||||||
if(_option->getAsBool(PREF_ENABLE_DHT)) {
|
if(_option->getAsBool(PREF_ENABLE_DHT)) {
|
||||||
std::vector<Command*> dhtCommands;
|
std::vector<Command*> dhtCommands;
|
||||||
DHTSetup().setup(dhtCommands, e, _option.get());
|
DHTSetup().setup(dhtCommands, e);
|
||||||
e->addCommand(dhtCommands);
|
e->addCommand(dhtCommands);
|
||||||
} else {
|
} else {
|
||||||
_logger->notice("For BitTorrent Magnet URI, enabling DHT is strongly"
|
_logger->notice("For BitTorrent Magnet URI, enabling DHT is strongly"
|
||||||
|
@ -335,7 +335,7 @@ void RequestGroup::createInitialCommand
|
||||||
if(torrentAttrs[bittorrent::PRIVATE].i() == 0 &&
|
if(torrentAttrs[bittorrent::PRIVATE].i() == 0 &&
|
||||||
_option->getAsBool(PREF_ENABLE_DHT)) {
|
_option->getAsBool(PREF_ENABLE_DHT)) {
|
||||||
std::vector<Command*> dhtCommands;
|
std::vector<Command*> dhtCommands;
|
||||||
DHTSetup().setup(dhtCommands, e, _option.get());
|
DHTSetup().setup(dhtCommands, e);
|
||||||
e->addCommand(dhtCommands);
|
e->addCommand(dhtCommands);
|
||||||
if(!torrentAttrs[bittorrent::NODES].empty() && DHTSetup::initialized()) {
|
if(!torrentAttrs[bittorrent::NODES].empty() && DHTSetup::initialized()) {
|
||||||
std::vector<std::pair<std::string, uint16_t> > entryPoints;
|
std::vector<std::pair<std::string, uint16_t> > entryPoints;
|
||||||
|
|
Loading…
Reference in New Issue