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
pull/1/head
Tatsuhiro Tsujikawa 2010-08-07 15:04:21 +00:00
parent 15b29bed15
commit ef393dba74
4 changed files with 27 additions and 12 deletions

View File

@ -1,3 +1,10 @@
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
2010-08-07 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net> 2010-08-07 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Updated malformed message handling. Updated malformed message handling.

View File

@ -58,6 +58,7 @@
#include "ServerStatMan.h" #include "ServerStatMan.h"
#include "a2io.h" #include "a2io.h"
#include "DownloadContext.h" #include "DownloadContext.h"
#include "array_fun.h"
#ifdef HAVE_EPOLL #ifdef HAVE_EPOLL
# include "EpollEventPoll.h" # include "EpollEventPoll.h"
#endif // HAVE_EPOLL #endif // HAVE_EPOLL
@ -169,14 +170,17 @@ DownloadEngineFactory::newDownloadEngine
} }
#ifdef ENABLE_XML_RPC #ifdef ENABLE_XML_RPC
if(op->getAsBool(PREF_ENABLE_XML_RPC)) { if(op->getAsBool(PREF_ENABLE_XML_RPC)) {
static int families[] = { AF_INET, AF_INET6 };
for(size_t i = 0; i < A2_ARRAY_LEN(families); ++i) {
HttpListenCommand* httpListenCommand = HttpListenCommand* httpListenCommand =
new HttpListenCommand(e->newCUID(), e.get()); new HttpListenCommand(e->newCUID(), e.get(), families[i]);
if(httpListenCommand->bindPort(op->getAsInt(PREF_XML_RPC_LISTEN_PORT))){ if(httpListenCommand->bindPort(op->getAsInt(PREF_XML_RPC_LISTEN_PORT))){
e->addRoutineCommand(httpListenCommand); e->addRoutineCommand(httpListenCommand);
} else { } else {
delete httpListenCommand; delete httpListenCommand;
} }
} }
}
#endif // ENABLE_XML_RPC #endif // ENABLE_XML_RPC
return e; return e;
} }

View File

@ -48,11 +48,13 @@
#include "ServerStatMan.h" #include "ServerStatMan.h"
#include "FileAllocationEntry.h" #include "FileAllocationEntry.h"
#include "CheckIntegrityEntry.h" #include "CheckIntegrityEntry.h"
#include "A2STR.h"
namespace aria2 { namespace aria2 {
HttpListenCommand::HttpListenCommand(cuid_t cuid, DownloadEngine* e): HttpListenCommand::HttpListenCommand
Command(cuid),e_(e) {} (cuid_t cuid, DownloadEngine* e, int family):
Command(cuid), e_(e), family_(family) {}
HttpListenCommand::~HttpListenCommand() HttpListenCommand::~HttpListenCommand()
{ {
@ -98,15 +100,16 @@ bool HttpListenCommand::bindPort(uint16_t port)
} }
serverSocket_.reset(new SocketCore()); serverSocket_.reset(new SocketCore());
if(getLogger()->info()) { if(getLogger()->info()) {
getLogger()->info("CUID#%s - Setting up HttpListenCommand", getLogger()->info("CUID#%s - Setting up HttpListenCommand for IPv%d",
util::itos(getCuid()).c_str()); util::itos(getCuid()).c_str(),
family_ == AF_INET?4:6);
} }
try { try {
int flags = 0; int flags = 0;
if(e_->getOption()->getAsBool(PREF_XML_RPC_LISTEN_ALL)) { if(e_->getOption()->getAsBool(PREF_XML_RPC_LISTEN_ALL)) {
flags = AI_PASSIVE; flags = AI_PASSIVE;
} }
serverSocket_->bind(port, flags); serverSocket_->bind(A2STR::NIL, port, family_, flags);
serverSocket_->beginListen(); serverSocket_->beginListen();
serverSocket_->setNonBlockingMode(); serverSocket_->setNonBlockingMode();
if(getLogger()->info()) { if(getLogger()->info()) {

View File

@ -46,9 +46,10 @@ class SocketCore;
class HttpListenCommand : public Command { class HttpListenCommand : public Command {
private: private:
DownloadEngine* e_; DownloadEngine* e_;
int family_;
SharedHandle<SocketCore> serverSocket_; SharedHandle<SocketCore> serverSocket_;
public: public:
HttpListenCommand(cuid_t cuid, DownloadEngine* e); HttpListenCommand(cuid_t cuid, DownloadEngine* e, int family);
virtual ~HttpListenCommand(); virtual ~HttpListenCommand();