We already request WPAD information from the DHCP server (bug 368423)
but we don't do anything useful with it at all.
The same information can also come from a VPN server, but we don't even
*collect* that.
This patch fixes the latter, and exposes the information in a coherent
fashion. There's no need at this point to overcomplicate matters by
pretending to support complicated manual proxy setups (as discussed in
TODO); this is just for what we can glean automatically, which is *only*
PAC files.
Tested with a local DHCP server that tells me where the proxy is, and
with a slightly modified nm-openconnect-service-openconnect-helper[sic].
This is based largely on the existing handling of NIS domainname.
I see that it's considered acceptable to (ab)use nm-dns-manager to
configure the NIS domain. I'll look at making it prod the PacRunner
dæmon with proxy information too, but this part stands alone.
diff --git a/include/NetworkManagerVPN.h b/include/NetworkManagerVPN.h
index 6e654b3..9b6e5f7 100644
--- a/include/NetworkManagerVPN.h
+++ b/include/NetworkManagerVPN.h
@@ -176,6 +176,9 @@ typedef enum {
/* boolean: prevent this VPN connection from ever getting the default route */
#define NM_VPN_PLUGIN_IP4_CONFIG_NEVER_DEFAULT never-default
+/* string: Location of PAC file for HTTP proxy */
+#define NM_VPN_PLUGIN_IP4_CONFIG_PROXY_PAC proxy-pac
+
/* Deprecated */
#define NM_VPN_PLUGIN_IP4_CONFIG_GATEWAY NM_VPN_PLUGIN_IP4_CONFIG_EXT_GATEWAY
diff --git a/src/dhcp-manager/nm-dhcp-client.c
b/src/dhcp-manager/nm-dhcp-client.c
index f4e94a6..ebe9a69 100644
--- a/src/dhcp-manager/nm-dhcp-client.c
+++ b/src/dhcp-manager/nm-dhcp-client.c
@@ -1292,6 +1292,12 @@ ip4_options_to_config (NMDHCPClient *self)
nm_ip4_config_set_nis_domain (ip4_config, str);
}
+ str = g_hash_table_lookup (priv-options, new_wpad);
+ if (str) {
+ nm_log_info (LOGD_DHCP4, Proxy PAC '%s', str);
+ nm_ip4_config_set_proxy_pac (ip4_config, str);
+ }
+
str = g_hash_table_lookup (priv-options, new_nis_servers);
if (str) {
char **searches = g_strsplit (str, , 0);
diff --git a/src/nm-ip4-config.c b/src/nm-ip4-config.c
index 0722981..8f86996 100644
--- a/src/nm-ip4-config.c
+++ b/src/nm-ip4-config.c
@@ -59,6 +59,8 @@ typedef struct {
GArray *nis;
char * nis_domain;
+ char * proxy_pac;
+
GSList *routes;
gboolean never_default;
@@ -569,6 +571,26 @@ nm_ip4_config_get_nis_domain (NMIP4Config *config)
return NM_IP4_CONFIG_GET_PRIVATE (config)-nis_domain;
}
+void
+nm_ip4_config_set_proxy_pac (NMIP4Config *config, const char *uri)
+{
+ NMIP4ConfigPrivate *priv;
+
+ g_return_if_fail (NM_IS_IP4_CONFIG (config));
+
+ priv = NM_IP4_CONFIG_GET_PRIVATE (config);
+ g_free (priv-proxy_pac);
+ priv-proxy_pac = g_strdup (uri);
+}
+
+const char *
+nm_ip4_config_get_proxy_pac (NMIP4Config *config)
+{
+ g_return_val_if_fail (NM_IS_IP4_CONFIG (config), 0);
+
+ return NM_IP4_CONFIG_GET_PRIVATE (config)-proxy_pac;
+}
+
/* libnl convenience/conversion functions */
static int ip4_addr_to_rtnl_local (guint32 ip4_address, struct rtnl_addr *addr)
@@ -790,6 +812,10 @@ nm_ip4_config_diff (NMIP4Config *a, NMIP4Config *b)
(g_strcmp0 (a_priv-nis_domain, b_priv-nis_domain) != 0))
flags |= NM_IP4_COMPARE_FLAG_NIS_DOMAIN;
+ if ( (a_priv-proxy_pac || b_priv-proxy_pac)
+(g_strcmp0 (a_priv-proxy_pac, b_priv-proxy_pac) != 0))
+ flags |= NM_IP4_COMPARE_FLAG_PROXY_PAC;
+
if ( !route_slist_compare (a_priv-routes, b_priv-routes)
|| !route_slist_compare (b_priv-routes, a_priv-routes))
flags |= NM_IP4_COMPARE_FLAG_ROUTES;
@@ -856,6 +882,10 @@ nm_ip4_config_hash (NMIP4Config *config, GChecksum *sum,
gboolean dns_only)
s = nm_ip4_config_get_nis_domain (config);
if (s)
g_checksum_update (sum, (const guint8 *) s, strlen (s));
+
+ s = nm_ip4_config_get_proxy_pac (config);
+ if (s)
+ g_checksum_update (sum, (const guint8 *) s, strlen (s));
}
for (i = 0; i nm_ip4_config_get_num_nameservers (config); i++)
@@ -900,6 +930,7 @@ finalize (GObject *object)
g_ptr_array_free (priv-searches, TRUE);
g_array_free (priv-nis, TRUE);
g_free (priv-nis_domain);
+ g_free (priv-proxy_pac);
G_OBJECT_CLASS (nm_ip4_config_parent_class)-finalize (object);
}
diff --git a/src/nm-ip4-config.h b/src/nm-ip4-config.h
index 5433768..c66aece 100644
--- a/src/nm-ip4-config.h
+++ b/src/nm-ip4-config.h
@@ -107,6 +107,9 @@ void nm_ip4_config_reset_nis_servers
(NMIP4Config *config);
void nm_ip4_config_set_nis_domain (NMIP4Config *config, const
char *domain);
const char * nm_ip4_config_get_nis_domain (NMIP4Config *config);