sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

patch-proxyconfig-20240905.diff (2397B)


      1 --- config.def.h.orig	2024-09-05 06:51:02 UTC
      2 +++ config.def.h
      3 @@ -36,6 +36,9 @@ static Parameter defconfig[ParameterLast] = {
      4  	[LoadImages]          =       { { .i = 1 },     },
      5  	[MediaManualPlay]     =       { { .i = 1 },     },
      6  	[PreferredLanguages]  =       { { .v = (char *[]){ NULL } }, },
      7 +	[ProxyIgnoreHosts]    =       { { .v = (char *[]){ NULL } }, },
      8 +	[ProxyMode]           =       { { .i = SystemProxy }, },
      9 +	[ProxyUrl]            =       { { .v = (char *) NULL }, },
     10  	[RunInFullscreen]     =       { { .i = 0 },     },
     11  	[ScrollBars]          =       { { .i = 1 },     },
     12  	[ShowIndicators]      =       { { .i = 1 },     },
     13 --- surf.c.orig	2024-09-05 06:51:09 UTC
     14 +++ surf.c
     15 @@ -50,6 +50,12 @@ enum {
     16  	OnAny   = OnDoc | OnLink | OnImg | OnMedia | OnEdit | OnBar | OnSel,
     17  };
     18  
     19 +enum {
     20 +	CustomProxy = WEBKIT_NETWORK_PROXY_MODE_CUSTOM,
     21 +	SystemProxy = WEBKIT_NETWORK_PROXY_MODE_DEFAULT,
     22 +	NoProxy   = WEBKIT_NETWORK_PROXY_MODE_NO_PROXY,
     23 +};
     24 +
     25  typedef enum {
     26  	AccessMicrophone,
     27  	AccessWebcam,
     28 @@ -72,6 +78,9 @@ typedef enum {
     29  	LoadImages,
     30  	MediaManualPlay,
     31  	PreferredLanguages,
     32 +	ProxyIgnoreHosts,
     33 +	ProxyMode,
     34 +	ProxyUrl,
     35  	RunInFullscreen,
     36  	ScrollBars,
     37  	ShowIndicators,
     38 @@ -1099,6 +1108,7 @@ newview(Client *c, WebKitWebView *rv)
     39  	WebKitWebContext *context;
     40  	WebKitCookieManager *cookiemanager;
     41  	WebKitUserContentManager *contentmanager;
     42 +	WebKitNetworkProxySettings *proxysettings;
     43  
     44  	/* Webview */
     45  	if (rv) {
     46 @@ -1157,6 +1167,28 @@ newview(Client *c, WebKitWebView *rv)
     47  		webkit_web_context_set_tls_errors_policy(context,
     48  		    curconfig[StrictTLS].val.i ? WEBKIT_TLS_ERRORS_POLICY_FAIL :
     49  		    WEBKIT_TLS_ERRORS_POLICY_IGNORE);
     50 +		/* proxy */
     51 +		switch (curconfig[ProxyMode].val.i) {
     52 +			case CustomProxy:
     53 +				proxysettings = webkit_network_proxy_settings_new(
     54 +					curconfig[ProxyUrl].val.v,
     55 +					curconfig[ProxyIgnoreHosts].val.v);
     56 +				webkit_web_context_set_network_proxy_settings(context,
     57 +					CustomProxy,
     58 +					proxysettings);
     59 +				break;
     60 +			case NoProxy:
     61 +				webkit_web_context_set_network_proxy_settings(context,
     62 +					NoProxy,
     63 +					NULL);
     64 +				break;
     65 +			case SystemProxy:
     66 +			default:
     67 +				webkit_web_context_set_network_proxy_settings(context,
     68 +					SystemProxy,
     69 +					proxysettings);
     70 +				break;
     71 +		}
     72  		/* disk cache */
     73  		webkit_web_context_set_cache_model(context,
     74  		    curconfig[DiskCache].val.i ? WEBKIT_CACHE_MODEL_WEB_BROWSER :