[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[PATCH 1/2] Expand debug output for Acquire::http::Proxy-Auto-Detect



In particular the previous implementation didn't output the command
parameter which was passed, and also didn't complain about any output
from the external command which was going to be ignored (except an
empty line).

Signed-off-by: Tim Small <tim@seoss.co.uk>
---
 apt-pkg/contrib/proxy.cc | 26 +++++++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)

diff --git a/apt-pkg/contrib/proxy.cc b/apt-pkg/contrib/proxy.cc
index 4529cf2..23f66e8 100644
--- a/apt-pkg/contrib/proxy.cc
+++ b/apt-pkg/contrib/proxy.cc
@@ -38,10 +38,11 @@ bool AutoDetectProxy(URI &URL)
    if (AutoDetectProxyCmd.empty())
       return true;
 
+   std::string const urlstring = URL;
    if (Debug)
-      std::clog << "Using auto proxy detect command: " << AutoDetectProxyCmd << std::endl;
+      std::clog << "Calling auto proxy detect command: '" << AutoDetectProxyCmd << "'" <<
+	 std::endl << "   ... with argument '" << urlstring.c_str() << "'" << std::endl;
 
-   std::string const urlstring = URL;
    std::vector<const char *> Args;
    Args.push_back(AutoDetectProxyCmd.c_str());
    Args.push_back(urlstring.c_str());
@@ -57,8 +58,12 @@ bool AutoDetectProxy(URI &URL)
       return false;
    // no output means the detector has no idea which proxy to use
    // and apt will use the generic proxy settings
-   if (goodread == false)
+   if (goodread == false) {
+      if (Debug)
+	 std::clog << "Proxy auto detect command returned no output, apt will use default proxy " <<
+	    std::endl << "settings (if any) for this URI" << std::endl;
       return true;
+   }
    auto const cleanedbuf = _strstrip(buf);
    // We warn about this as the implementor probably meant to use DIRECT instead
    if (cleanedbuf[0] == '\0')
@@ -70,8 +75,19 @@ bool AutoDetectProxy(URI &URL)
    if (Debug)
       std::clog << "auto detect command returned: '" << cleanedbuf << "'" << std::endl;
 
-   if (strstr(cleanedbuf, URL.Access.c_str()) == cleanedbuf || strcmp(cleanedbuf, "DIRECT") == 0)
-      _config->Set("Acquire::"+URL.Access+"::proxy::"+URL.Host, cleanedbuf);
+   std::string const urlSpecificProxy = "Acquire::"+URL.Access+"::proxy::"+URL.Host;
+
+   if (strstr(cleanedbuf, URL.Access.c_str()) == cleanedbuf || strcmp(cleanedbuf, "DIRECT") == 0) {
+      if (Debug)
+	 std::clog << "Setting '" << urlSpecificProxy << "' to: '" << cleanedbuf << "'" << std::endl;
+      _config->Set(urlSpecificProxy, cleanedbuf);
+   } else {
+      if (Debug)
+         std::clog << "NOT setting '" << urlSpecificProxy << "' to: '" << cleanedbuf << "'" <<
+	    std::endl << "   ... non-applicable (for access method '" << URL.Access.c_str() <<
+	    "') or malformed proxy URL returned by script." << std::endl;
+   }
+
 
    return true;
 }
-- 
2.9.3


Reply to: