mirror of
https://github.com/mirror/wget.git
synced 2024-12-25 20:30:37 +08:00
Add libproxy support
Add support for libproxy, which is capable to extract desktop environment proxy configurations from dozens of systems and platforms. This also enables wget to handle pac/wpad proxy server. * configure.ac: Add check for libbproxy. * src/retr.c (getproxy): Retrieve proxy via libproxy. Copyright-paperwork-exempt: Yes
This commit is contained in:
parent
73d24b2779
commit
8e8900613c
1
AUTHORS
1
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*
|
||||
|
16
configure.ac
16
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
|
||||
])
|
||||
|
36
src/retr.c
36
src/retr.c
@ -44,6 +44,10 @@ as that of the covered work. */
|
||||
# include <zlib.h>
|
||||
#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. */
|
||||
|
Loading…
Reference in New Issue
Block a user