summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/backend/plugins/config-env/config-env.c2
-rw-r--r--src/backend/plugins/config-gnome/config-gnome.c5
-rw-r--r--src/backend/plugins/config-kde/config-kde.c2
-rw-r--r--src/backend/plugins/config-osx/config-osx.c10
-rw-r--r--src/backend/plugins/config-sysconfig/config-sysconfig.c2
-rw-r--r--src/backend/plugins/config-windows/config-windows.c10
-rw-r--r--src/backend/px-manager.c22
-rw-r--r--src/backend/px-manager.h3
8 files changed, 36 insertions, 20 deletions
diff --git a/src/backend/plugins/config-env/config-env.c b/src/backend/plugins/config-env/config-env.c
index af13de6..397fdd9 100644
--- a/src/backend/plugins/config-env/config-env.c
+++ b/src/backend/plugins/config-env/config-env.c
@@ -156,7 +156,7 @@ px_config_env_get_config (PxConfig *config,
proxy = self->http_proxy;
if (proxy)
- g_strv_builder_add (builder, proxy);
+ px_strv_builder_add_proxy (builder, proxy);
}
static void
diff --git a/src/backend/plugins/config-gnome/config-gnome.c b/src/backend/plugins/config-gnome/config-gnome.c
index 0041c1b..e8a58ab 100644
--- a/src/backend/plugins/config-gnome/config-gnome.c
+++ b/src/backend/plugins/config-gnome/config-gnome.c
@@ -24,6 +24,7 @@
#include "config-gnome.h"
#include "px-plugin-config.h"
+#include "px-manager.h"
struct _PxConfigGnome {
GObject parent_instance;
@@ -156,7 +157,7 @@ store_response (GStrvBuilder *builder,
g_string_append_printf (tmp, "%s:%d", host, port);
- g_strv_builder_add (builder, tmp->str);
+ px_strv_builder_add_proxy (builder, tmp->str);
}
}
@@ -178,7 +179,7 @@ px_config_gnome_get_config (PxConfig *config,
else
proxy = g_strdup ("wpad://");
- g_strv_builder_add (builder, proxy);
+ px_strv_builder_add_proxy (builder, proxy);
} else if (mode == GNOME_PROXY_MODE_MANUAL) {
g_autofree char *username = g_settings_get_string (self->http_proxy_settings, "authentication-user");
g_autofree char *password = g_settings_get_string (self->http_proxy_settings, "authentication-password");
diff --git a/src/backend/plugins/config-kde/config-kde.c b/src/backend/plugins/config-kde/config-kde.c
index 1079c19..f30a130 100644
--- a/src/backend/plugins/config-kde/config-kde.c
+++ b/src/backend/plugins/config-kde/config-kde.c
@@ -269,7 +269,7 @@ px_config_kde_get_config (PxConfig *config,
}
if (proxy)
- g_strv_builder_add (builder, proxy);
+ px_strv_builder_add_proxy (builder, proxy);
}
static void
diff --git a/src/backend/plugins/config-osx/config-osx.c b/src/backend/plugins/config-osx/config-osx.c
index 08b87c3..f733c93 100644
--- a/src/backend/plugins/config-osx/config-osx.c
+++ b/src/backend/plugins/config-osx/config-osx.c
@@ -229,11 +229,11 @@ get_ignore_list (CFDictionaryRef proxies)
for (int idx = 0; idx < CFArrayGetCount (ref); idx++) {
CFStringRef s = (CFStringRef)CFArrayGetValueAtIndex (ref, idx);
- g_strv_builder_add (ret, str (s));
+ px_strv_builder_add_proxy (ret, str (s));
}
if (getbool (proxies, "ExcludeSimpleHostnames"))
- g_strv_builder_add (ret, "127.0.0.1");
+ px_strv_builder_add_proxy (ret, "127.0.0.1");
return g_strv_builder_end (ret);
}
@@ -259,7 +259,7 @@ px_config_osx_get_config (PxConfig *self,
if (getbool (proxies, "ProxyAutoDiscoveryEnable")) {
CFRelease (proxies);
- g_strv_builder_add (builder, "wpad://");
+ px_strv_builder_add_proxy (builder, "wpad://");
return;
}
@@ -271,7 +271,7 @@ px_config_osx_get_config (PxConfig *self,
if (tmp_uri) {
g_autofree char *ret = g_strdup_printf ("pac+%s", g_uri_to_string (tmp_uri));
CFRelease (proxies);
- g_strv_builder_add (builder, ret);
+ px_strv_builder_add_proxy (builder, ret);
return;
}
} else {
@@ -288,7 +288,7 @@ px_config_osx_get_config (PxConfig *self,
}
if (proxy)
- g_strv_builder_add (builder, proxy);
+ px_strv_builder_add_proxy (builder, proxy);
}
static void
diff --git a/src/backend/plugins/config-sysconfig/config-sysconfig.c b/src/backend/plugins/config-sysconfig/config-sysconfig.c
index a7e7d47..1f90a44 100644
--- a/src/backend/plugins/config-sysconfig/config-sysconfig.c
+++ b/src/backend/plugins/config-sysconfig/config-sysconfig.c
@@ -238,7 +238,7 @@ px_config_sysconfig_get_config (PxConfig *config,
}
if (proxy)
- g_strv_builder_add (builder, proxy);
+ px_strv_builder_add_proxy (builder, proxy);
}
static void
diff --git a/src/backend/plugins/config-windows/config-windows.c b/src/backend/plugins/config-windows/config-windows.c
index c8bc94d..b623c2d 100644
--- a/src/backend/plugins/config-windows/config-windows.c
+++ b/src/backend/plugins/config-windows/config-windows.c
@@ -167,7 +167,7 @@ px_config_windows_get_config (PxConfig *self,
/* WPAD */
if (is_enabled (W32REG_OFFSET_WPAD)) {
- g_strv_builder_add (builder, "wpad://");
+ px_strv_builder_add_proxy (builder, "wpad://");
return;
}
@@ -177,7 +177,7 @@ px_config_windows_get_config (PxConfig *self,
GUri *ac_uri = g_uri_parse (tmp, G_URI_FLAGS_PARSE_RELAXED, NULL);
if (ac_uri) {
- g_strv_builder_add (builder, pac_uri);
+ px_strv_builder_add_proxy (builder, pac_uri);
return;
}
}
@@ -190,19 +190,19 @@ px_config_windows_get_config (PxConfig *self,
if (table) {
char *ret = g_hash_table_lookup (table, scheme);
if (ret) {
- g_strv_builder_add (builder, ret);
+ px_strv_builder_add_proxy (builder, ret);
return;
}
ret = g_hash_table_lookup (table, "http");
if (ret) {
- g_strv_builder_add (builder, ret);
+ px_strv_builder_add_proxy (builder, ret);
return;
}
ret = g_hash_table_lookup (table, "socks");
if (ret) {
- g_strv_builder_add (builder, ret);
+ px_strv_builder_add_proxy (builder, ret);
return;
}
}
diff --git a/src/backend/px-manager.c b/src/backend/px-manager.c
index 618d9fe..1e3bcb0 100644
--- a/src/backend/px-manager.c
+++ b/src/backend/px-manager.c
@@ -450,10 +450,10 @@ px_manager_run_pac (PeasExtensionSet *set,
proxy_string = g_strconcat ("socks://", server, NULL);
}
- g_strv_builder_add (pac_data->builder, proxy_string);
+ px_strv_builder_add_proxy (pac_data->builder, proxy_string);
} else {
/* Syntax not found, returning direct */
- g_strv_builder_add (pac_data->builder, "direct://");
+ px_strv_builder_add_proxy (pac_data->builder, "direct://");
}
}
}
@@ -549,7 +549,7 @@ px_manager_get_proxies_sync (PxManager *self,
g_debug ("%s: url=%s online=%d", __FUNCTION__, url ? url : "?", self->online);
if (!uri || !self->online) {
- g_strv_builder_add (builder, "direct://");
+ px_strv_builder_add_proxy (builder, "direct://");
return g_strv_builder_end (builder);
}
@@ -568,16 +568,28 @@ px_manager_get_proxies_sync (PxManager *self,
};
peas_extension_set_foreach (self->pacrunner_set, px_manager_run_pac, &pac_data);
} else if (!g_str_has_prefix (g_uri_get_scheme (conf_url), "wpad") && !g_str_has_prefix (g_uri_get_scheme (conf_url), "pac+")) {
- g_strv_builder_add (builder, g_uri_to_string (conf_url));
+ px_strv_builder_add_proxy (builder, g_uri_to_string (conf_url));
}
}
/* In case no proxy could be found, assume direct connection */
if (((GPtrArray *)builder)->len == 0)
- g_strv_builder_add (builder, "direct://");
+ px_strv_builder_add_proxy (builder, "direct://");
for (int idx = 0; idx < ((GPtrArray *)builder)->len; idx++)
g_debug ("%s: Proxy[%d] = %s", __FUNCTION__, idx, (char *)((GPtrArray *)builder)->pdata[idx]);
return g_strv_builder_end (builder);
}
+
+void
+px_strv_builder_add_proxy (GStrvBuilder *builder,
+ const char *value)
+{
+ for (int idx = 0; idx < ((GPtrArray *)builder)->len; idx++) {
+ if (strcmp ((char *)((GPtrArray *)builder)->pdata[idx], value) == 0)
+ return;
+ }
+
+ g_strv_builder_add (builder, value);
+}
diff --git a/src/backend/px-manager.h b/src/backend/px-manager.h
index 486fb51..2bb816b 100644
--- a/src/backend/px-manager.h
+++ b/src/backend/px-manager.h
@@ -51,4 +51,7 @@ char **px_manager_get_configuration (PxManager *self,
GUri *uri,
GError **error);
+void px_strv_builder_add_proxy (GStrvBuilder *builder,
+ const char *value);
+
G_END_DECLS