diff --git a/AUTHORS b/AUTHORS index 39e64e65..3e919b6b 100644 --- a/AUTHORS +++ b/AUTHORS @@ -363,3 +363,4 @@ Contributors: [ ] Nik Soggia *wget [at] niksoggia.it* [ ] Aarni Koskela *akx [at] iki.fi* [ ] jinfuchiang *jinfuchiang [at] outlook.com* +[ ] Jan-Michael Brummer *jan-michael.brummer1 [at] volkswagen.de* diff --git a/configure.ac b/configure.ac index aff89c1b..f26f13a6 100644 --- a/configure.ac +++ b/configure.ac @@ -951,6 +951,21 @@ AS_IF([test x"$with_metalink" != xno], [ ]) ]) +dnl +dnl libproxy support +dnl +with_libproxy=no +AC_ARG_ENABLE(libproxy, + [ --enable-libproxy libproxy support for system wide proxy configuration]) +AS_IF([test "${enable_libproxy}" = "yes"], [ + with_libproxy=yes + PKG_CHECK_MODULES([LIBPROXY], [libproxy-1.0], [ + LIBS="$LIBPROXY_LIBS $LIBS" + CFLAGS="$LIBPROXY_CFLAGS $CFLAGS" + AC_DEFINE([HAVE_LIBPROXY], [1], [Define if using libproxy.]) + ]) +]) + dnl dnl Extended Attribute support dnl @@ -1022,4 +1037,5 @@ AC_MSG_NOTICE([Summary of build options: GPGME: $have_gpg IRI: $iri Fuzzing build: $enable_fuzzing, $LIB_FUZZING_ENGINE + libproxy: $with_libproxy ]) diff --git a/src/retr.c b/src/retr.c index 44cc81c5..01f7c49c 100644 --- a/src/retr.c +++ b/src/retr.c @@ -44,6 +44,10 @@ as that of the covered work. */ # include #endif +#ifdef HAVE_LIBPROXY +# include "proxy.h" +#endif + #include "exits.h" #include "utils.h" #include "retr.h" @@ -1489,7 +1493,39 @@ getproxy (struct url *u) break; } if (!proxy || !*proxy) +#ifdef HAVE_LIBPROXY + { + pxProxyFactory *pf = px_proxy_factory_new (); + if (!pf) + { + debug_logprintf ("Allocating memory for libproxy failed"); + return NULL; + } + + debug_logprintf ("asking libproxy about url '%s'\n", u->url); + char **proxies = px_proxy_factory_get_proxies (pf, u->url); + if (proxies) + { + if (proxies[0]) + { + debug_logprintf ("libproxy suggest to use '%s'\n", proxies[0]); + if (strcmp (proxies[0], "direct://") != 0) + { + proxy = xstrdup (proxies[0]); + debug_logprintf ("libproxy setting to use '%s'\n", proxy); + } + } + + px_proxy_factory_free_proxies (proxies); + } + px_proxy_factory_free (pf); + + if (!proxy || !*proxy) + return NULL; + } +#else return NULL; +#endif /* Handle shorthands. `rewritten_storage' is a kludge to allow getproxy() to return static storage. */