commit db11143178de137e993ff081767fa5c8dbcc7921
parent 6a26f248d47459aee153025e93c5de908550ed70
Author: Russell Wood <rjw@lab.lan>
Date: Thu, 5 Sep 2024 21:27:34 +1000
Update proxyconfig patch and documentation.
Diffstat:
3 files changed, 103 insertions(+), 101 deletions(-)
diff --git a/surf.suckless.org/patches/proxyconfig/index.md b/surf.suckless.org/patches/proxyconfig/index.md
@@ -1,4 +1,4 @@
-proxyconfig
+Proxy Config
===========
Description
@@ -6,19 +6,38 @@ 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:
+It supports the three proxy modes in 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.
+* CustomProxy: specify a custom proxy URL and list of hosts to ignore.
+* SystemProxy: use your desktop environment proxy settings or `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.
+Usage
+-----
-The default value is SystemProxy, which preserves the default behavior of vanilla surf out of the box.
+Once the patch is applied, modify the ProxyMode, ProxyUrl and ProxyIgnoreHosts variables as required. For example, if using a custom proxy server then the variables might be set as:
+
+``
+[ProxyIgnoreHosts] = { { .v = (char *[]){ "localhost","local.lan",NULL } }, },
+[ProxyMode] = { { .i = CustomProxy }, },
+[ProxyUrl] = { { .v = (char *) "http://proxy.local.lan:8080/"}, },
+``
+
+The default value is SystemProxy, which preserves the default behavior of surf.
+
+Note that the SystemProxy mode will not respect your ProxyIgnoreHosts list.
+
+FreeBSD Ports
+-------------
+
+To apply this patch to the `www/surf` port on FreeBSD, create the `files` directory within the port directory and copy the patch into it. If you have your own pre-defined `config.h` file, you can build and install the port using the using the `SURF_CONF=/path/to/surf/config.h` `make` variable. Otherwise, run `make patch` to apply the patch to the source files, edit `work/surf-VERSION/config.def.h`, set the variables as required and then build and install the port as per usual.
Download
--------
-* [surf-proxyconfig-20210503-7dcce9e.diff](surf-proxyconfig-20210503-7dcce9e.diff)
+* [patch-proxyconfig-20240905.diff](patch-proxyconfig-20240905.diff)
+
+Reference
+---------
+
+* [https://webkitgtk.org/reference/webkit2gtk/2.35.1/WebKitNetworkProxySettings.html](Webkit Network Proxy Settings Reference)
diff --git a/surf.suckless.org/patches/proxyconfig/patch-proxyconfig-20240905.diff b/surf.suckless.org/patches/proxyconfig/patch-proxyconfig-20240905.diff
@@ -0,0 +1,74 @@
+--- config.def.h.orig 2024-09-05 06:51:02 UTC
++++ config.def.h
+@@ -36,6 +36,9 @@ static Parameter defconfig[ParameterLast] = {
+ [LoadImages] = { { .i = 1 }, },
+ [MediaManualPlay] = { { .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 }, },
+--- surf.c.orig 2024-09-05 06:51:09 UTC
++++ surf.c
+@@ -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 {
+ AccessMicrophone,
+ AccessWebcam,
+@@ -72,6 +78,9 @@ typedef enum {
+ LoadImages,
+ MediaManualPlay,
+ PreferredLanguages,
++ ProxyIgnoreHosts,
++ ProxyMode,
++ ProxyUrl,
+ RunInFullscreen,
+ ScrollBars,
+ ShowIndicators,
+@@ -1099,6 +1108,7 @@ newview(Client *c, WebKitWebView *rv)
+ WebKitWebContext *context;
+ WebKitCookieManager *cookiemanager;
+ WebKitUserContentManager *contentmanager;
++ WebKitNetworkProxySettings *proxysettings;
+
+ /* Webview */
+ if (rv) {
+@@ -1157,6 +1167,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 :
diff --git a/surf.suckless.org/patches/proxyconfig/surf-proxyconfig-20210503-7dcce9e.diff b/surf.suckless.org/patches/proxyconfig/surf-proxyconfig-20210503-7dcce9e.diff
@@ -1,91 +0,0 @@
-From d0ba61a0e75cfc7b8e6d70d6f323d53295e628ad Mon Sep 17 00:00:00 2001
-From: weirdling <maddy@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
-@@ -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
-@@ -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,
-@@ -73,6 +79,9 @@ typedef enum {
- LoadImages,
- MediaManualPlay,
- Plugins,
-+ ProxyIgnoreHosts,
-+ ProxyMode,
-+ ProxyUrl,
- PreferredLanguages,
- RunInFullscreen,
- ScrollBars,
-@@ -1111,6 +1120,7 @@ newview(Client *c, WebKitWebView *rv)
- WebKitWebContext *context;
- WebKitCookieManager *cookiemanager;
- WebKitUserContentManager *contentmanager;
-+ WebKitNetworkProxySettings *proxysettings;
-
- /* Webview */
- if (rv) {
-@@ -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
-