]> git.saurik.com Git - apt.git/commitdiff
Alfredo's no_proxy patch
authorArch Librarian <arch@canonical.com>
Mon, 20 Sep 2004 16:56:39 +0000 (16:56 +0000)
committerArch Librarian <arch@canonical.com>
Mon, 20 Sep 2004 16:56:39 +0000 (16:56 +0000)
Author: jgg
Date: 2001-02-23 05:45:27 GMT
Alfredo's no_proxy patch

apt-pkg/contrib/strutl.cc
apt-pkg/contrib/strutl.h
debian/changelog
methods/ftp.cc
methods/http.cc

index c1a1cb4dbdd24a2514a391207a8d539db4f78102..7175402a7040e2734fcddf9e225a13cb8d0040e8 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: strutl.cc,v 1.35 2001/02/20 07:03:17 jgg Exp $
+// $Id: strutl.cc,v 1.36 2001/02/23 05:45:27 jgg Exp $
 /* ######################################################################
 
    String Util - Some useful string functions.
@@ -880,6 +880,30 @@ void ioprintf(ostream &out,const char *format,...)
 }
                                                                        /*}}}*/
 
+// CheckDomainList - See if Host is in a , seperate list               /*{{{*/
+// ---------------------------------------------------------------------
+/* The domain list is a comma seperate list of domains that are suffix
+   matched against the argument */
+bool CheckDomainList(string Host,string List)
+{
+   const char *Start = List.begin();
+   for (const char *Cur = List.begin(); Cur <= List.end() ; Cur++)
+   {
+      if (Cur < List.end() && *Cur != ',')
+        continue;
+      
+      // Match the end of the string..
+      if ((Host.size() >= (Cur - List.begin())) &&
+         Cur - Start != 0 &&
+         stringcasecmp(Host.end() - (Cur - Start),Host.end(),Start,Cur) == 0)
+        return true;
+      
+      Start = Cur + 1;
+   }
+   return false;
+}
+                                                                       /*}}}*/
+
 // URI::CopyFrom - Copy from an object                                 /*{{{*/
 // ---------------------------------------------------------------------
 /* This parses the URI into all of its components */
index 5549673a15a8257e393b8c00a3d65c15c999eaee..88f9a50137d26c73f44d55e5fab16869dcc0cbae 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: strutl.h,v 1.16 2001/02/20 07:03:17 jgg Exp $
+// $Id: strutl.h,v 1.17 2001/02/23 05:45:27 jgg Exp $
 /* ######################################################################
 
    String Util - These are some useful string functions
@@ -53,6 +53,7 @@ bool Hex2Num(const char *Start,const char *End,unsigned char *Num,
 bool TokSplitString(char Tok,char *Input,char **List,
                    unsigned long ListMax);
 void ioprintf(ostream &out,const char *format,...) APT_FORMAT2;
+bool CheckDomainList(string Host,string List);
 
 int stringcmp(const char *A,const char *AEnd,const char *B,const char *BEnd);
 inline int stringcmp(const char *A,const char *AEnd,const char *B) {return stringcmp(A,AEnd,B,B+strlen(B));};
index df46e3d9eef02bbe350461b8120b8dd80d0a62ff..3097232461cc3bdedc89c07fae324c1bee05489f 100644 (file)
@@ -2,6 +2,7 @@ apt (0.5.1) unstable; urgency=low
 
   * Fixed #82894 again, or should be and.
   * Process the option string right. Closes: #86921
+  * Alfredo's no_proxy patch
   
  -- Jason Gunthorpe <jgg@debian.org>  Thu, 22 Feb 2001 00:39:15 -0500
 
index 0d617dd8f83385738b2cd6b381ce7f3aa8d0ea7c..e0f71239f726a26982fc423bfaafb41a8a260c97 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: ftp.cc,v 1.21 2001/02/20 07:03:18 jgg Exp $
+// $Id: ftp.cc,v 1.22 2001/02/23 05:45:27 jgg Exp $
 /* ######################################################################
 
    HTTP Aquire Method - This is the FTP aquire method for APT.
@@ -125,6 +125,13 @@ bool FTPConn::Open(pkgAcqMethod *Owner)
    else
       Proxy = getenv("ftp_proxy");
    
+   // Parse no_proxy, a , separated list of domains
+   if (getenv("no_proxy") != 0)
+   {
+      if (CheckDomainList(ServerName.Host,getenv("no_proxy")) == true)
+        Proxy = "";
+   }
+   
    // Determine what host and port to use based on the proxy settings
    int Port = 0;
    string Host;   
@@ -1071,6 +1078,15 @@ int main(int argc,const char *argv[])
    if (getenv("ftp_proxy") != 0)
    {
       URI Proxy = string(getenv("ftp_proxy"));
+      
+      // Parse no_proxy, a , separated list of domains
+      if (getenv("no_proxy") != 0)
+      {
+        if (CheckDomainList(Proxy.Host,getenv("no_proxy")) == true)
+           Proxy.Access = "";
+      }
+      
+      // Run the HTTP method
       if (Proxy.Access == "http")
       {
         // Copy over the environment setting
index 7347e8349d4b2b8c687905cf09d692b86a9fa072..9f4494dc79e05f89221d9111e1450c858a9db268 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: http.cc,v 1.47 2001/02/20 07:03:18 jgg Exp $
+// $Id: http.cc,v 1.48 2001/02/23 05:45:27 jgg Exp $
 /* ######################################################################
 
    HTTP Aquire Method - This is the HTTP aquire method for APT.
@@ -285,27 +285,13 @@ bool ServerState::Open()
    else
       Proxy = getenv("http_proxy");
    
-   // Parse no_proxy, a , separated list of hosts
+   // Parse no_proxy, a , separated list of domains
    if (getenv("no_proxy") != 0)
    {
-      const char *Start = getenv("no_proxy");
-      for (const char *Cur = Start; true ; Cur++)
-      {
-        if (*Cur != ',' && *Cur != 0)
-           continue;
-        if (stringcasecmp(ServerName.Host.begin(),ServerName.Host.end(),
-                          Start,Cur) == 0)
-        {
-           Proxy = "";
-           break;
-        }
-        
-        Start = Cur + 1;
-        if (*Cur == 0)
-           break;
-      }         
-   }      
-
+      if (CheckDomainList(ServerName.Host,getenv("no_proxy")) == true)
+        Proxy = "";
+   }
+   
    // Determine what host and port to use based on the proxy settings
    int Port = 0;
    string Host;