mirror of https://github.com/aria2/aria2
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.hpull/1/head
parent
15b29bed15
commit
ef393dba74
|
@ -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>
|
||||
|
||||
Updated malformed message handling.
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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()) {
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
Loading…
Reference in New Issue