Browse Source

2010-08-31 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

	In .netrc file, if machine name starts ".", aria2 performs domain
	match instead of exact match. This is an extension of aria2.
	* src/Netrc.h
Tatsuhiro Tsujikawa 15 years ago
parent
commit
f9d68a4ecf
2 changed files with 16 additions and 1 deletions
  1. 6 0
      ChangeLog
  2. 10 1
      src/Netrc.h

+ 6 - 0
ChangeLog

@@ -1,3 +1,9 @@
+2010-08-31  Tatsuhiro Tsujikawa  <t-tujikawa@users.sourceforge.net>
+
+	In .netrc file, if machine name starts ".", aria2 performs domain
+	match instead of exact match. This is an extension of aria2.
+	* src/Netrc.h
+
 2010-08-31  Tatsuhiro Tsujikawa  <t-tujikawa@users.sourceforge.net>
 
 	Fixed the bug which prevents HTTP redirection from working when

+ 10 - 1
src/Netrc.h

@@ -43,6 +43,7 @@
 
 #include "SharedHandle.h"
 #include "A2STR.h"
+#include "util.h"
 
 namespace aria2 {
 
@@ -75,7 +76,15 @@ public:
 
   virtual bool match(const std::string& hostname) const
   {
-    return hostname == machine_;
+    if(util::isNumericHost(hostname)) {
+      return hostname == machine_;
+    } else {
+      if(util::startsWith(machine_, A2STR::DOT_C)) {
+        return util::endsWith(A2STR::DOT_C+hostname, machine_);
+      } else {
+        return hostname == machine_;
+      }
+    }
   }
 
   const std::string& getMachine() const