proxy-uri -> proxy-resolver for no_proxy; add #inc

Signed-off-by: Christoph Lohmann <20h@r-36.net>
This commit is contained in:
Ivan Tham 2015-12-17 21:35:02 +08:00 committed by Christoph Lohmann
parent 9fa4ffef72
commit 86efaf8093
2 changed files with 19 additions and 5 deletions

7
surf.1
View file

@ -283,6 +283,13 @@ string
.TP .TP
.B http_proxy .B http_proxy
If this variable is set and not empty upon startup, surf will use it as the http proxy If this variable is set and not empty upon startup, surf will use it as the http proxy
.TP
.B no_proxy
If both http_proxy is set and no_proxy contain a
.BR comma-separated
list of domain extensions and both is not empty upon startup, proxy will
.BR not
be used for each of the elements in no_proxy.
.SH PLUGINS .SH PLUGINS
For using plugins in surf, first determine your running architecture. Then get For using plugins in surf, first determine your running architecture. Then get
the appropriate plugin for that architecture and copy it to the appropriate plugin for that architecture and copy it to

17
surf.c
View file

@ -24,6 +24,9 @@
#include <stdarg.h> #include <stdarg.h>
#include <regex.h> #include <regex.h>
#include <pwd.h> #include <pwd.h>
#include <glib.h>
#include <lib/gprintf.h>
#include <gio/gio.h>
#include "arg.h" #include "arg.h"
@ -1290,9 +1293,9 @@ void
setup(void) setup(void)
{ {
int i; int i;
char *proxy, *new_proxy; char *proxy, *new_proxy, *no_proxy, **new_no_proxy;
char *styledirfile, *stylepath; char *styledirfile, *stylepath;
SoupURI *puri; GProxyResolver *pr;
SoupSession *s; SoupSession *s;
GError *error = NULL; GError *error = NULL;
@ -1367,15 +1370,19 @@ setup(void)
/* proxy */ /* proxy */
if ((proxy = getenv("http_proxy")) && strcmp(proxy, "")) { if ((proxy = getenv("http_proxy")) && strcmp(proxy, "")) {
new_proxy = g_strrstr(proxy, "http://") new_proxy = g_strrstr(proxy, "http://")
|| g_strrstr(proxy, "https://")
|| g_strrstr(proxy, "socks://") || g_strrstr(proxy, "socks://")
|| g_strrstr(proxy, "socks4://") || g_strrstr(proxy, "socks4://")
|| g_strrstr(proxy, "socks4a://")
|| g_strrstr(proxy, "socks5://") || g_strrstr(proxy, "socks5://")
? g_strdup(proxy) ? g_strdup(proxy)
: g_strdup_printf("http://%s", proxy); : g_strdup_printf("http://%s", proxy);
puri = soup_uri_new(new_proxy); new_no_proxy = ((no_proxy = getenv("no_proxy")) && strcmp(no_proxy, ""))
g_object_set(G_OBJECT(s), "proxy-uri", puri, NULL); ? g_strsplit(no_proxy, ",", -1) : NULL;
soup_uri_free(puri); pr = g_simple_proxy_resolver_new(new_proxy, new_no_proxy);
g_object_set(G_OBJECT(s), "proxy-resolver", pr, NULL);
g_free(new_proxy); g_free(new_proxy);
g_strfreev(new_no_proxy);
usingproxy = 1; usingproxy = 1;
} }
} }