summaryrefslogtreecommitdiff
path: root/apt-pkg/contrib
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2017-06-30 14:38:25 +0200
committerJulian Andres Klode <jak@debian.org>2017-06-30 15:00:41 +0200
commit535c06a759dc13c8e2858735973cac24ceaa36fa (patch)
treea0e0601ac7324cc41e88cdbbf30f81beb486ec1c /apt-pkg/contrib
parentbafebf1afc59db7df7e0148b723f3f361770272c (diff)
Allow http(s) and socks5h for http and https in proxy auto detect
This makes it possible to write sensible auto detect scripts.
Diffstat (limited to 'apt-pkg/contrib')
-rw-r--r--apt-pkg/contrib/proxy.cc17
1 files changed, 16 insertions, 1 deletions
diff --git a/apt-pkg/contrib/proxy.cc b/apt-pkg/contrib/proxy.cc
index a26ab4fbc..9af76bdce 100644
--- a/apt-pkg/contrib/proxy.cc
+++ b/apt-pkg/contrib/proxy.cc
@@ -12,6 +12,7 @@
#include<apt-pkg/fileutl.h>
#include<apt-pkg/strutl.h>
+#include <algorithm>
#include<iostream>
#include<fcntl.h>
#include<unistd.h>
@@ -22,6 +23,13 @@
// AutoDetectProxy - auto detect proxy /*{{{*/
// ---------------------------------------------------------------------
/* */
+static std::vector<std::string> CompatibleProxies(URI const &URL)
+{
+ if (URL.Access == "http" || URL.Access == "https")
+ return {"http", "https", "socks5h"};
+ return {URL.Access};
+}
+
bool AutoDetectProxy(URI &URL)
{
// we support both http/https debug options
@@ -74,7 +82,14 @@ 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)
+ auto compatibleTypes = CompatibleProxies(URL);
+ bool compatible = strcmp(cleanedbuf, "DIRECT") == 0 ||
+ compatibleTypes.end() != std::find_if(compatibleTypes.begin(),
+ compatibleTypes.end(), [cleanedbuf](std::string &compat) {
+ return strstr(cleanedbuf, compat.c_str()) == cleanedbuf;
+ });
+
+ if (compatible)
_config->Set("Acquire::"+URL.Access+"::proxy::"+URL.Host, cleanedbuf);
return true;