dhcp: Set proxy properly when applying DHCP lease
PATCH 1/2 dhcp: Set proxy properly when applying DHCP lease
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(-)
src/dhcp.c +1 -2
@@ -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" ))
Signature · 1 line
2.25.1
PATCH 2/2 wispr: Fix online check when using WPAD/PAC
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(-)
src/wispr.c +24 -6
@@ -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 );
Signature · 1 line
2.25.1
Re: [PATCH v1 2/2] wispr: Fix online check when using WPAD/PAC
Hi Rayn,
Quoted 8 lines · 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.
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
Re: [PATCH v1 2/2] wispr: Fix online check when using WPAD/PAC
It looks good to me. Thanks for the quick response!
-Ryan
Quoted 21 lines · Daniel Wagner
Hi Rayn,
Quoted 8 lines · 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.
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
Re: [PATCH v1 2/2] wispr: Fix online check when using WPAD/PAC
Quoted 1 line · Ryan Smith
It looks good to me. Thanks for the quick response!
And now I got really slow. Was on holiday...