2009-08-30 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

Added --xml-rpc-listen-all option. If true is given to this
	option, aria2 listens incoming XML-RPC requests on all network
	interfaces. If false is given, listens only on local loopback
	interface. The default value is false.
	* src/HttpListenCommand.cc
	* src/OptionHandlerFactory.cc
	* src/SocketCore.cc
	* src/SocketCore.h
	* src/prefs.cc
	* src/prefs.h
	* src/usage_text.h
pull/1/head
Tatsuhiro Tsujikawa 2009-08-30 12:25:04 +00:00
parent be10231175
commit d182b380c2
8 changed files with 42 additions and 4 deletions

View File

@ -1,3 +1,17 @@
2009-08-30 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Added --xml-rpc-listen-all option. If true is given to this
option, aria2 listens incoming XML-RPC requests on all network
interfaces. If false is given, listens only on local loopback
interface. The default value is false.
* src/HttpListenCommand.cc
* src/OptionHandlerFactory.cc
* src/SocketCore.cc
* src/SocketCore.h
* src/prefs.cc
* src/prefs.h
* src/usage_text.h
2009-08-21 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net> 2009-08-21 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
* Release 1.5.2 * Release 1.5.2

View File

@ -42,6 +42,8 @@
#include "CUIDCounter.h" #include "CUIDCounter.h"
#include "RequestGroupMan.h" #include "RequestGroupMan.h"
#include "FileEntry.h" #include "FileEntry.h"
#include "prefs.h"
#include "Option.h"
namespace aria2 { namespace aria2 {
@ -91,7 +93,11 @@ bool HttpListenCommand::bindPort(uint16_t port)
_serverSocket.reset(new SocketCore()); _serverSocket.reset(new SocketCore());
logger->info("CUID#%d - Setting up HttpListenCommand", cuid); logger->info("CUID#%d - Setting up HttpListenCommand", cuid);
try { try {
_serverSocket->bind(port); int flags = 0;
if(_e->option->getAsBool(PREF_XML_RPC_LISTEN_ALL)) {
flags = AI_PASSIVE;
}
_serverSocket->bind(port, flags);
_serverSocket->beginListen(); _serverSocket->beginListen();
_serverSocket->setNonBlockingMode(); _serverSocket->setNonBlockingMode();
logger->info(MSG_LISTENING_PORT, cuid, port); logger->info(MSG_LISTENING_PORT, cuid, port);

View File

@ -392,6 +392,15 @@ OptionHandlers OptionHandlerFactory::createOptionHandlers()
handlers.push_back(op); handlers.push_back(op);
} }
#ifdef ENABLE_XML_RPC #ifdef ENABLE_XML_RPC
{
SharedHandle<OptionHandler> op(new BooleanOptionHandler
(PREF_XML_RPC_LISTEN_ALL,
TEXT_XML_RPC_LISTEN_ALL,
V_FALSE,
OptionHandler::OPT_ARG));
op->addTag(TAG_ADVANCED);
handlers.push_back(op);
}
{ {
SharedHandle<OptionHandler> op(new NumberOptionHandler SharedHandle<OptionHandler> op(new NumberOptionHandler
(PREF_XML_RPC_LISTEN_PORT, (PREF_XML_RPC_LISTEN_PORT,

View File

@ -159,7 +159,7 @@ std::string uitos(T value)
return str; return str;
} }
void SocketCore::bind(uint16_t port) void SocketCore::bind(uint16_t port, int flags)
{ {
closeConnection(); closeConnection();
@ -168,7 +168,7 @@ void SocketCore::bind(uint16_t port)
memset(&hints, 0, sizeof(hints)); memset(&hints, 0, sizeof(hints));
hints.ai_family = _protocolFamily; hints.ai_family = _protocolFamily;
hints.ai_socktype = _sockType; hints.ai_socktype = _sockType;
hints.ai_flags = AI_PASSIVE; hints.ai_flags = flags;
hints.ai_protocol = 0; hints.ai_protocol = 0;
int s; int s;
s = getaddrinfo(0, uitos(port).c_str(), &hints, &res); s = getaddrinfo(0, uitos(port).c_str(), &hints, &res);

View File

@ -145,10 +145,11 @@ public:
/** /**
* Creates a socket and bind it with locahost's address and port. * Creates a socket and bind it with locahost's address and port.
* flags is set to struct addrinfo's ai_flags.
* @param port port to listen. If 0 is specified, os automaticaly * @param port port to listen. If 0 is specified, os automaticaly
* choose avaiable port. * choose avaiable port.
*/ */
void bind(uint16_t port); void bind(uint16_t port, int flags = AI_PASSIVE);
/** /**
* Listens form connection on it. * Listens form connection on it.

View File

@ -172,6 +172,8 @@ const std::string PREF_ON_DOWNLOAD_START("on-download-start");
const std::string PREF_ON_DOWNLOAD_STOP("on-download-stop"); const std::string PREF_ON_DOWNLOAD_STOP("on-download-stop");
const std::string PREF_ON_DOWNLOAD_COMPLETE("on-download-complete"); const std::string PREF_ON_DOWNLOAD_COMPLETE("on-download-complete");
const std::string PREF_ON_DOWNLOAD_ERROR("on-download-error"); const std::string PREF_ON_DOWNLOAD_ERROR("on-download-error");
// value: true | false
const std::string PREF_XML_RPC_LISTEN_ALL("xml-rpc-listen-all");
/** /**
* FTP related preferences * FTP related preferences

View File

@ -176,6 +176,8 @@ extern const std::string PREF_ON_DOWNLOAD_START;
extern const std::string PREF_ON_DOWNLOAD_STOP; extern const std::string PREF_ON_DOWNLOAD_STOP;
extern const std::string PREF_ON_DOWNLOAD_COMPLETE; extern const std::string PREF_ON_DOWNLOAD_COMPLETE;
extern const std::string PREF_ON_DOWNLOAD_ERROR; extern const std::string PREF_ON_DOWNLOAD_ERROR;
// value: true | false
extern const std::string PREF_XML_RPC_LISTEN_ALL;
/** /**
* FTP related preferences * FTP related preferences

View File

@ -562,3 +562,7 @@ _(" --on-download-stop=COMMAND Set the command to be executed when download\n"
_(" --bt-stop-timeout=SEC Stop BitTorrent download if download speed is 0 in\n"\ _(" --bt-stop-timeout=SEC Stop BitTorrent download if download speed is 0 in\n"\
" consecutive SEC seconds. If 0 is given, this\n"\ " consecutive SEC seconds. If 0 is given, this\n"\
" feature is disabled.") " feature is disabled.")
#define TEXT_XML_RPC_LISTEN_ALL \
_(" --xml-rpc-listen-all[=true|false] Listen incoming XML-RPC requests on all\n"\
" network interfaces. If false is given, listen only\n"\
" on local loopback interface.")