diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2010-08-07 15:04:21 +0000 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2010-08-07 15:04:21 +0000 |
| commit | ef393dba742c2b88286286b2cae9e248576a3b96 (patch) | |
| tree | 434152ae42502c2980143ddf69484d52f52bc486 /src | |
| parent | 15b29bed15af6fa3e362afc4a869e6e7becf55fd (diff) | |
2010-08-08 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Listen both IPv4 and IPv6 for xml-rpc request.
* src/DownloadEngineFactory.cc
* src/HttpListenCommand.cc
* src/HttpListenCommand.h
Diffstat (limited to 'src')
| -rw-r--r-- | src/DownloadEngineFactory.cc | 16 | ||||
| -rw-r--r-- | src/HttpListenCommand.cc | 13 | ||||
| -rw-r--r-- | src/HttpListenCommand.h | 3 |
3 files changed, 20 insertions, 12 deletions
diff --git a/src/DownloadEngineFactory.cc b/src/DownloadEngineFactory.cc index cbf10bef..67ba8116 100644 --- a/src/DownloadEngineFactory.cc +++ b/src/DownloadEngineFactory.cc @@ -58,6 +58,7 @@ #include "ServerStatMan.h" #include "a2io.h" #include "DownloadContext.h" +#include "array_fun.h" #ifdef HAVE_EPOLL # include "EpollEventPoll.h" #endif // HAVE_EPOLL @@ -169,12 +170,15 @@ DownloadEngineFactory::newDownloadEngine } #ifdef ENABLE_XML_RPC if(op->getAsBool(PREF_ENABLE_XML_RPC)) { - HttpListenCommand* httpListenCommand = - new HttpListenCommand(e->newCUID(), e.get()); - if(httpListenCommand->bindPort(op->getAsInt(PREF_XML_RPC_LISTEN_PORT))){ - e->addRoutineCommand(httpListenCommand); - } else { - delete httpListenCommand; + static int families[] = { AF_INET, AF_INET6 }; + for(size_t i = 0; i < A2_ARRAY_LEN(families); ++i) { + HttpListenCommand* httpListenCommand = + new HttpListenCommand(e->newCUID(), e.get(), families[i]); + if(httpListenCommand->bindPort(op->getAsInt(PREF_XML_RPC_LISTEN_PORT))){ + e->addRoutineCommand(httpListenCommand); + } else { + delete httpListenCommand; + } } } #endif // ENABLE_XML_RPC diff --git a/src/HttpListenCommand.cc b/src/HttpListenCommand.cc index 701abfc6..9fc167e1 100644 --- a/src/HttpListenCommand.cc +++ b/src/HttpListenCommand.cc @@ -48,11 +48,13 @@ #include "ServerStatMan.h" #include "FileAllocationEntry.h" #include "CheckIntegrityEntry.h" +#include "A2STR.h" namespace aria2 { -HttpListenCommand::HttpListenCommand(cuid_t cuid, DownloadEngine* e): - Command(cuid),e_(e) {} +HttpListenCommand::HttpListenCommand +(cuid_t cuid, DownloadEngine* e, int family): + Command(cuid), e_(e), family_(family) {} HttpListenCommand::~HttpListenCommand() { @@ -98,15 +100,16 @@ bool HttpListenCommand::bindPort(uint16_t port) } serverSocket_.reset(new SocketCore()); if(getLogger()->info()) { - getLogger()->info("CUID#%s - Setting up HttpListenCommand", - util::itos(getCuid()).c_str()); + getLogger()->info("CUID#%s - Setting up HttpListenCommand for IPv%d", + util::itos(getCuid()).c_str(), + family_ == AF_INET?4:6); } try { int flags = 0; if(e_->getOption()->getAsBool(PREF_XML_RPC_LISTEN_ALL)) { flags = AI_PASSIVE; } - serverSocket_->bind(port, flags); + serverSocket_->bind(A2STR::NIL, port, family_, flags); serverSocket_->beginListen(); serverSocket_->setNonBlockingMode(); if(getLogger()->info()) { diff --git a/src/HttpListenCommand.h b/src/HttpListenCommand.h index 6adf60ff..b60c408c 100644 --- a/src/HttpListenCommand.h +++ b/src/HttpListenCommand.h @@ -46,9 +46,10 @@ class SocketCore; class HttpListenCommand : public Command { private: DownloadEngine* e_; + int family_; SharedHandle<SocketCore> serverSocket_; public: - HttpListenCommand(cuid_t cuid, DownloadEngine* e); + HttpListenCommand(cuid_t cuid, DownloadEngine* e, int family); virtual ~HttpListenCommand(); |
