summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2009-08-30 12:25:04 +0000
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2009-08-30 12:25:04 +0000
commitd182b380c244a3e4d966b04bbe89ccb9783ffa52 (patch)
treef920bcf1c29290d4fc8e14394ebc4d97782702a9
parentbe10231175cfaaf531727aaf5d90e49c44e29112 (diff)
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
-rw-r--r--ChangeLog14
-rw-r--r--src/HttpListenCommand.cc8
-rw-r--r--src/OptionHandlerFactory.cc9
-rw-r--r--src/SocketCore.cc4
-rw-r--r--src/SocketCore.h3
-rw-r--r--src/prefs.cc2
-rw-r--r--src/prefs.h2
-rw-r--r--src/usage_text.h4
8 files changed, 42 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index e4988b17..0fb5b635 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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>
* Release 1.5.2
diff --git a/src/HttpListenCommand.cc b/src/HttpListenCommand.cc
index 381aa1fa..4fd8b3e6 100644
--- a/src/HttpListenCommand.cc
+++ b/src/HttpListenCommand.cc
@@ -42,6 +42,8 @@
#include "CUIDCounter.h"
#include "RequestGroupMan.h"
#include "FileEntry.h"
+#include "prefs.h"
+#include "Option.h"
namespace aria2 {
@@ -91,7 +93,11 @@ bool HttpListenCommand::bindPort(uint16_t port)
_serverSocket.reset(new SocketCore());
logger->info("CUID#%d - Setting up HttpListenCommand", cuid);
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->setNonBlockingMode();
logger->info(MSG_LISTENING_PORT, cuid, port);
diff --git a/src/OptionHandlerFactory.cc b/src/OptionHandlerFactory.cc
index 343e6423..a714bae2 100644
--- a/src/OptionHandlerFactory.cc
+++ b/src/OptionHandlerFactory.cc
@@ -393,6 +393,15 @@ OptionHandlers OptionHandlerFactory::createOptionHandlers()
}
#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
(PREF_XML_RPC_LISTEN_PORT,
TEXT_XML_RPC_LISTEN_PORT,
diff --git a/src/SocketCore.cc b/src/SocketCore.cc
index f459c650..88340e1b 100644
--- a/src/SocketCore.cc
+++ b/src/SocketCore.cc
@@ -159,7 +159,7 @@ std::string uitos(T value)
return str;
}
-void SocketCore::bind(uint16_t port)
+void SocketCore::bind(uint16_t port, int flags)
{
closeConnection();
@@ -168,7 +168,7 @@ void SocketCore::bind(uint16_t port)
memset(&hints, 0, sizeof(hints));
hints.ai_family = _protocolFamily;
hints.ai_socktype = _sockType;
- hints.ai_flags = AI_PASSIVE;
+ hints.ai_flags = flags;
hints.ai_protocol = 0;
int s;
s = getaddrinfo(0, uitos(port).c_str(), &hints, &res);
diff --git a/src/SocketCore.h b/src/SocketCore.h
index 4cdaa473..896c1f63 100644
--- a/src/SocketCore.h
+++ b/src/SocketCore.h
@@ -145,10 +145,11 @@ public:
/**
* 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
* choose avaiable port.
*/
- void bind(uint16_t port);
+ void bind(uint16_t port, int flags = AI_PASSIVE);
/**
* Listens form connection on it.
diff --git a/src/prefs.cc b/src/prefs.cc
index 6d732985..4881cad2 100644
--- a/src/prefs.cc
+++ b/src/prefs.cc
@@ -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_COMPLETE("on-download-complete");
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
diff --git a/src/prefs.h b/src/prefs.h
index 17c70727..fc3b4cfe 100644
--- a/src/prefs.h
+++ b/src/prefs.h
@@ -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_COMPLETE;
extern const std::string PREF_ON_DOWNLOAD_ERROR;
+// value: true | false
+extern const std::string PREF_XML_RPC_LISTEN_ALL;
/**
* FTP related preferences
diff --git a/src/usage_text.h b/src/usage_text.h
index cbaefd40..a7af5da5 100644
--- a/src/usage_text.h
+++ b/src/usage_text.h
@@ -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"\
" consecutive SEC seconds. If 0 is given, this\n"\
" 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.")