summaryrefslogtreecommitdiff
path: root/src/AbstractCommand.cc
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2010-03-19 08:56:17 +0000
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2010-03-19 08:56:17 +0000
commit49511423468b4fcaeb7bcf2ee3800ab55ce94848 (patch)
treefc2ecf879ab322e9f193fee4e35194afebb13f1d /src/AbstractCommand.cc
parent55d7c99638939284995466280de16711b8f65c03 (diff)
2010-03-19 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Accept IPv4 network address with CIDR block in --no-proxy option and no_proxy environment variable. Current implementation does not resolve hostname in URI to compare network address. So it is only effecive if URI has numeric IP addresses. * doc/aria2c.1.txt * src/AbstractCommand.cc * src/OptionHandlerFactory.cc * src/bitfield.h * src/usage_text.h * src/util.cc * src/util.h * test/UtilTest.cc * test/bitfieldTest.cc
Diffstat (limited to 'src/AbstractCommand.cc')
-rw-r--r--src/AbstractCommand.cc30
1 files changed, 27 insertions, 3 deletions
diff --git a/src/AbstractCommand.cc b/src/AbstractCommand.cc
index 05f491cb..a43cd284 100644
--- a/src/AbstractCommand.cc
+++ b/src/AbstractCommand.cc
@@ -448,9 +448,33 @@ static bool inNoProxy(const SharedHandle<Request>& req,
if(entries.empty()) {
return false;
}
- return
- std::find_if(entries.begin(), entries.end(),
- DomainMatch(A2STR::DOT_C+req->getHost())) != entries.end();
+ DomainMatch domainMatch(A2STR::DOT_C+req->getHost());
+ for(std::vector<std::string>::const_iterator i = entries.begin(),
+ eoi = entries.end(); i != eoi; ++i) {
+ std::string::size_type slashpos = (*i).find('/');
+ if(slashpos == std::string::npos) {
+ if(domainMatch(*i)) {
+ return true;
+ }
+ } else {
+ if(!util::isNumericHost(req->getHost())) {
+ // TODO We don't resolve hostname here. More complete
+ // implementation is that we should first resolve
+ // hostname(which may result in several IP addresses) and
+ // evaluates against all of them
+ continue;
+ }
+ std::string ip = (*i).substr(0, slashpos);
+ uint32_t bits;
+ if(!util::parseUIntNoThrow(bits, (*i).substr(slashpos+1))) {
+ continue;
+ }
+ if(util::inSameCidrBlock(ip, req->getHost(), bits)) {
+ return true;
+ }
+ }
+ }
+ return false;
}
bool AbstractCommand::isProxyDefined() const