All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 1/2] dhcp: Set proxy properly when applying DHCP lease
@ 2022-04-11 17:32 Ryan Smith
  2022-04-11 17:32 ` [PATCH v1 2/2] wispr: Fix online check when using WPAD/PAC Ryan Smith
  0 siblings, 1 reply; 5+ messages in thread
From: Ryan Smith @ 2022-04-11 17:32 UTC (permalink / raw)
  To: connman; +Cc: Ryan Smith

When DHCP Option 252 (PAC file URL) is included,
the service should be updated. Doing so sets the proxy
method to 'auto', updates the ipconfig object, and
notifies PACrunner (if included) that the proxy setting
has changed.

Currently, only the ipconfig object is updated. This patch
calls the proper function to perform these actions.
---
 src/dhcp.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/dhcp.c b/src/dhcp.c
index 11274269..bf100b9b 100644
--- a/src/dhcp.c
+++ b/src/dhcp.c
@@ -422,8 +422,7 @@ static bool apply_lease_available_on_network(GDHCPClient *dhcp_client,
 		g_free(dhcp->pac);
 		dhcp->pac = pac;
 
-		__connman_ipconfig_set_proxy_autoconfig(dhcp->ipconfig,
-								dhcp->pac);
+		__connman_service_set_proxy_autoconfig(service, dhcp->pac);
 	}
 
 	if (connman_setting_get_bool("Enable6to4"))
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v1 2/2] wispr: Fix online check when using WPAD/PAC
  2022-04-11 17:32 [PATCH v1 1/2] dhcp: Set proxy properly when applying DHCP lease Ryan Smith
@ 2022-04-11 17:32 ` Ryan Smith
  2022-04-14 19:01   ` Daniel Wagner
  0 siblings, 1 reply; 5+ messages in thread
From: Ryan Smith @ 2022-04-11 17:32 UTC (permalink / raw)
  To: connman; +Cc: Ryan Smith

A PAC file can return multiple proxies in response to a query.
They are separated by a semicolon and, possibly, a space.

'PROXY proxy1.example.com:3128; PROXY proxy2.example.com; DIRECT'

Currently, this is not handled, and the inclusion of more than
one proxy causes the online check to fail. This fix parses the
first proxy in the list and uses it.
---
 src/wispr.c | 30 ++++++++++++++++++++++++------
 1 file changed, 24 insertions(+), 6 deletions(-)

diff --git a/src/wispr.c b/src/wispr.c
index 41157580..d7afcf05 100644
--- a/src/wispr.c
+++ b/src/wispr.c
@@ -797,6 +797,26 @@ done:
 	return false;
 }
 
+static char *parse_proxy(const char *proxy)
+{
+	char *proxy_server = NULL;
+
+	if (g_strcmp0(proxy, "DIRECT") != 0) {
+		if (g_str_has_prefix(proxy, "PROXY ")) {
+			proxy_server = g_strdup(proxy + 6);
+
+			// Use first proxy server
+			for (char *c = proxy_server; *c != '\0'; ++c)
+				if (*c == ';')
+					*c = '\0';
+
+			g_strstrip(proxy_server);
+		}
+	}
+
+	return proxy_server;
+}
+
 static void proxy_callback(const char *proxy, void *user_data)
 {
 	struct connman_wispr_portal_context *wp_context = user_data;
@@ -808,12 +828,10 @@ static void proxy_callback(const char *proxy, void *user_data)
 
 	wp_context->token = 0;
 
-	if (proxy && g_strcmp0(proxy, "DIRECT") != 0) {
-		if (g_str_has_prefix(proxy, "PROXY")) {
-			proxy += 5;
-			for (; *proxy == ' ' && *proxy != '\0'; proxy++);
-		}
-		g_web_set_proxy(wp_context->web, proxy);
+	char *proxy_server = parse_proxy(proxy);
+	if (proxy_server) {
+		g_web_set_proxy(wp_context->web, proxy_server);
+		g_free(proxy_server);
 	}
 
 	g_web_set_accept(wp_context->web, NULL);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v1 2/2] wispr: Fix online check when using WPAD/PAC
  2022-04-11 17:32 ` [PATCH v1 2/2] wispr: Fix online check when using WPAD/PAC Ryan Smith
@ 2022-04-14 19:01   ` Daniel Wagner
  2022-04-14 20:44     ` Ryan Smith
  0 siblings, 1 reply; 5+ messages in thread
From: Daniel Wagner @ 2022-04-14 19:01 UTC (permalink / raw)
  To: Ryan Smith; +Cc: connman

Hi Rayn,

On Mon, Apr 11, 2022 at 11:32:17AM -0600, Ryan Smith wrote:
> A PAC file can return multiple proxies in response to a query.
> They are separated by a semicolon and, possibly, a space.
> 
> 'PROXY proxy1.example.com:3128; PROXY proxy2.example.com; DIRECT'
> 
> Currently, this is not handled, and the inclusion of more than
> one proxy causes the online check to fail. This fix parses the
> first proxy in the list and uses it.

Patch patches applied. I took the liberty and refactored parse_proxy()
slighly to much the style. Also we are still stuck pre C99 (I know...)
so the declaration have to go to the beginning of the block.

Please let me know if I screwed it up.

Thanks,
Daniel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v1 2/2] wispr: Fix online check when using WPAD/PAC
  2022-04-14 19:01   ` Daniel Wagner
@ 2022-04-14 20:44     ` Ryan Smith
  2022-05-16  6:35       ` Daniel Wagner
  0 siblings, 1 reply; 5+ messages in thread
From: Ryan Smith @ 2022-04-14 20:44 UTC (permalink / raw)
  To: Daniel Wagner; +Cc: connman

It looks good to me. Thanks for the quick response!

-Ryan

On Thu, Apr 14, 2022 at 1:01 PM Daniel Wagner <wagi@monom.org> wrote:
>
> Hi Rayn,
>
> On Mon, Apr 11, 2022 at 11:32:17AM -0600, Ryan Smith wrote:
> > A PAC file can return multiple proxies in response to a query.
> > They are separated by a semicolon and, possibly, a space.
> >
> > 'PROXY proxy1.example.com:3128; PROXY proxy2.example.com; DIRECT'
> >
> > Currently, this is not handled, and the inclusion of more than
> > one proxy causes the online check to fail. This fix parses the
> > first proxy in the list and uses it.
>
> Patch patches applied. I took the liberty and refactored parse_proxy()
> slighly to much the style. Also we are still stuck pre C99 (I know...)
> so the declaration have to go to the beginning of the block.
>
> Please let me know if I screwed it up.
>
> Thanks,
> Daniel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v1 2/2] wispr: Fix online check when using WPAD/PAC
  2022-04-14 20:44     ` Ryan Smith
@ 2022-05-16  6:35       ` Daniel Wagner
  0 siblings, 0 replies; 5+ messages in thread
From: Daniel Wagner @ 2022-05-16  6:35 UTC (permalink / raw)
  To: Ryan Smith; +Cc: connman

On Thu, Apr 14, 2022 at 02:44:49PM -0600, Ryan Smith wrote:
> It looks good to me. Thanks for the quick response!

And now I got really slow. Was on holiday...

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-05-16  6:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-11 17:32 [PATCH v1 1/2] dhcp: Set proxy properly when applying DHCP lease Ryan Smith
2022-04-11 17:32 ` [PATCH v1 2/2] wispr: Fix online check when using WPAD/PAC Ryan Smith
2022-04-14 19:01   ` Daniel Wagner
2022-04-14 20:44     ` Ryan Smith
2022-05-16  6:35       ` Daniel Wagner

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.