[wiki] [sites] Add proxyconfig patch to surf || weirdling

From: <git_AT_suckless.org>
Date: Mon, 03 May 2021 16:02:33 +0200

commit cab8f76ab375079429ff142518901b42df0b161d
Author: weirdling <maddy_AT_clappe.rs>
Date: Mon May 3 15:00:38 2021 +0100

    Add proxyconfig patch to surf

diff --git a/surf.suckless.org/patches/proxyconfig/index.md b/surf.suckless.org/patches/proxyconfig/index.md
new file mode 100644
index 00000000..92dcd6ae
--- /dev/null
+++ b/surf.suckless.org/patches/proxyconfig/index.md
_AT_@ -0,0 +1,24 @@
+proxyconfig
+===================
+
+Description
+-----------
+
+This patch allows you to specify proxy settings in your config.h file.
+
+It contains an enum which wraps the three proxy modes supported by Webkit:
+
+* CustomProxy allows you to specify a custom proxy URL and list of hosts to ignore.
+* SystemProxy uses your system proxy settings (which on *nix is your http_proxy environment variable).
+* NoProxy ensures that a proxy is never used.
+
+To use this patch, first set your ProxyMode Parameter to the desired value.
+If you're using CustomProxy, you then need to set your ProxyUrl Parameter to the URL of your proxy, for example, "http://localhost:8080", or "socks://localhost:9050".
+You may also optionally set your ProxyIgnoreHosts to specify a list of URLs which will not have their connections proxied. Please note that the SystemProxy mode will not respect your ProxyIgnoreHosts list -- my testing indicates that Webkit doesn't support this.
+
+The default value is SystemProxy, which preserves the default behavior of vanilla surf out of the box.
+
+Download
+--------
+
+* [surf-proxyconfig-20210503-7dcce9e.diff](surf-proxyconfig-20210503-7dcce9e.diff)
diff --git a/surf.suckless.org/patches/proxyconfig/surf-proxyconfig-20210503-7dcce9e.diff b/surf.suckless.org/patches/proxyconfig/surf-proxyconfig-20210503-7dcce9e.diff
new file mode 100644
index 00000000..ef17ea83
--- /dev/null
+++ b/surf.suckless.org/patches/proxyconfig/surf-proxyconfig-20210503-7dcce9e.diff
_AT_@ -0,0 +1,91 @@
+From d0ba61a0e75cfc7b8e6d70d6f323d53295e628ad Mon Sep 17 00:00:00 2001
+From: weirdling <maddy_AT_clappe.rs>
+Date: Mon, 3 May 2021 14:46:24 +0100
+Subject: [PATCH] Implement proxy settings
+
+---
+ config.def.h | 3 +++
+ surf.c | 32 ++++++++++++++++++++++++++++++++
+ 2 files changed, 35 insertions(+)
+
+diff --git a/config.def.h b/config.def.h
+index be168ab..46d164e 100644
+--- a/config.def.h
++++ b/config.def.h
+_AT_@ -43,6 +43,9 @@ static Parameter defconfig[ParameterLast] = {
+ [MediaManualPlay] = { { .i = 1 }, },
+ [Plugins] = { { .i = 1 }, },
+ [PreferredLanguages] = { { .v = (char *[]){ NULL } }, },
++ [ProxyIgnoreHosts] = { { .v = (char *[]){ NULL } }, },
++ [ProxyMode] = { { .i = SystemProxy }, },
++ [ProxyUrl] = { { .v = (char *) NULL }, },
+ [RunInFullscreen] = { { .i = 0 }, },
+ [ScrollBars] = { { .i = 1 }, },
+ [ShowIndicators] = { { .i = 1 }, },
+diff --git a/surf.c b/surf.c
+index ac832ff..5c74560 100644
+--- a/surf.c
++++ b/surf.c
+_AT_@ -50,6 +50,12 @@ enum {
+ OnAny = OnDoc | OnLink | OnImg | OnMedia | OnEdit | OnBar | OnSel,
+ };
+
++enum {
++ CustomProxy = WEBKIT_NETWORK_PROXY_MODE_CUSTOM,
++ SystemProxy = WEBKIT_NETWORK_PROXY_MODE_DEFAULT,
++ NoProxy = WEBKIT_NETWORK_PROXY_MODE_NO_PROXY,
++};
++
+ typedef enum {
+ AcceleratedCanvas,
+ AccessMicrophone,
+_AT_@ -73,6 +79,9 @@ typedef enum {
+ LoadImages,
+ MediaManualPlay,
+ Plugins,
++ ProxyIgnoreHosts,
++ ProxyMode,
++ ProxyUrl,
+ PreferredLanguages,
+ RunInFullscreen,
+ ScrollBars,
+_AT_@ -1111,6 +1120,7 @@ newview(Client *c, WebKitWebView *rv)
+ WebKitWebContext *context;
+ WebKitCookieManager *cookiemanager;
+ WebKitUserContentManager *contentmanager;
++ WebKitNetworkProxySettings *proxysettings;
+
+ /* Webview */
+ if (rv) {
+_AT_@ -1171,6 +1181,28 @@ newview(Client *c, WebKitWebView *rv)
+ webkit_web_context_set_tls_errors_policy(context,
+ curconfig[StrictTLS].val.i ? WEBKIT_TLS_ERRORS_POLICY_FAIL :
+ WEBKIT_TLS_ERRORS_POLICY_IGNORE);
++ /* proxy */
++ switch (curconfig[ProxyMode].val.i) {
++ case CustomProxy:
++ proxysettings = webkit_network_proxy_settings_new(
++ curconfig[ProxyUrl].val.v,
++ curconfig[ProxyIgnoreHosts].val.v);
++ webkit_web_context_set_network_proxy_settings(context,
++ CustomProxy,
++ proxysettings);
++ break;
++ case NoProxy:
++ webkit_web_context_set_network_proxy_settings(context,
++ NoProxy,
++ NULL);
++ break;
++ case SystemProxy:
++ default:
++ webkit_web_context_set_network_proxy_settings(context,
++ SystemProxy,
++ proxysettings);
++ break;
++ }
+ /* disk cache */
+ webkit_web_context_set_cache_model(context,
+ curconfig[DiskCache].val.i ? WEBKIT_CACHE_MODEL_WEB_BROWSER :
+--
+2.31.1
+
Received on Mon May 03 2021 - 16:02:33 CEST

This archive was generated by hypermail 2.3.0 : Mon May 03 2021 - 16:12:51 CEST