summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2008-11-04 14:57:05 +0000
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2008-11-04 14:57:05 +0000
commit7513095042eab655db052a7d2b2d0a934fc68261 (patch)
tree362c1b677ffedef1d157cd1ad3ffa5eb37b1362f
parentbd2ead4763282d037f3ce5671cba96177d9ce96c (diff)
2008-11-04 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Added support for following envrionment variables: http_proxy, https_proxy, ftp_proxy and all_proxy. Each variable is equivalent to the aria2 option whose name is the variable name with '_' replaced with '-'. They overrides options specified in aria2.conf file. The envrionment variables can be overrode using command-line option. * src/option_processing.cc
-rw-r--r--ChangeLog10
-rw-r--r--src/option_processing.cc23
2 files changed, 33 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index faf9ea9b..90db5e13 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
2008-11-04 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
+ Added support for following envrionment variables: http_proxy,
+ https_proxy, ftp_proxy and all_proxy.
+ Each variable is equivalent to the aria2 option whose name is the
+ variable name with '_' replaced with '-'.
+ They overrides options specified in aria2.conf file.
+ The envrionment variables can be overrode using command-line option.
+ * src/option_processing.cc
+
+2008-11-04 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
+
Renamed --http-proxy-method as --proxy-method.
* src/AbstractCommand.cc
* src/FtpInitiateConnectionCommand.cc
diff --git a/src/option_processing.cc b/src/option_processing.cc
index 9fc1cc01..ef323151 100644
--- a/src/option_processing.cc
+++ b/src/option_processing.cc
@@ -72,6 +72,23 @@ static std::string toBoolArg(const char* optarg)
return arg;
}
+static void overrideWithEnv(Option* op, const OptionParser& optionParser,
+ const std::string& pref,
+ const std::string& envName)
+{
+ char* value = getenv(envName.c_str());
+ if(value) {
+ try {
+ optionParser.findByName(pref)->parse(op, value);
+ } catch(Exception& e) {
+ std::cerr << "Caught Error while parsing environment variable"
+ << " '" << envName << "'"
+ << "\n"
+ << e.stackTrace();
+ }
+ }
+}
+
Option* option_processing(int argc, char* const argv[])
{
std::stringstream cmdstream;
@@ -555,6 +572,12 @@ Option* option_processing(int argc, char* const argv[])
exit(EXIT_FAILURE);
}
}
+ // Override configuration with environment variables.
+ overrideWithEnv(op, oparser, PREF_HTTP_PROXY, "http_proxy");
+ overrideWithEnv(op, oparser, PREF_HTTPS_PROXY, "https_proxy");
+ overrideWithEnv(op, oparser, PREF_FTP_PROXY, "ftp_proxy");
+ overrideWithEnv(op, oparser, PREF_ALL_PROXY, "all_proxy");
+
try {
oparser.parse(op, cmdstream);
} catch(OptionHandlerException& e) {