aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomasz Bursztyka <tomasz.bursztyka@linux.intel.com>2012-01-20 09:47:06 +0200
committerSamuel Ortiz <sameo@linux.intel.com>2012-01-27 11:33:47 +0100
commit276113e14c9e7abf20f2396fc92333a80f52cc35 (patch)
treefd6f4099b6821dbb2f26c82bd55cde5e95bb3776
parentb081e602f02b0870deb93a88bee0fc2c48268de2 (diff)
downloadpacrunner-276113e14c9e7abf20f2396fc92333a80f52cc35.tar.gz
manual: Execute manual proxy on configured servers
-rw-r--r--src/manual.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/src/manual.c b/src/manual.c
index 2d1b13e..4d017bb 100644
--- a/src/manual.c
+++ b/src/manual.c
@@ -439,12 +439,36 @@ void __pacrunner_manual_destroy_excludes(GList **excludes)
char *__pacrunner_manual_execute(const char *url, const char *host,
GList **servers, GList **excludes)
{
+ char *protocol = NULL;
+ char *result = NULL;
+ char *host_p = NULL;
+ int proto;
+
DBG("url %s host %s", url, host);
- if (servers == NULL || servers[0] == NULL)
+ if (servers == NULL || (url == NULL && host == NULL))
return NULL;
- return g_strdup_printf("PROXY %s", (char *)servers[0]->data);
+ if (url == NULL)
+ url = host;
+
+ if (parse_uri((char *)url, &host_p, &protocol, FALSE, FALSE) < 0)
+ goto direct;
+
+ proto = get_protocol_from_string(protocol);
+
+ if (servers[PACRUNNER_PROTOCOL_ALL] != NULL)
+ result = (char *)servers[PACRUNNER_PROTOCOL_ALL]->data;
+ else if (proto >= PACRUNNER_PROTOCOL_HTTP &&
+ proto < PACRUNNER_PROTOCOL_MAXIMUM_NUMBER)
+ if (servers[proto] != NULL)
+ result = (char *)servers[proto]->data;
+
+direct:
+ g_free(protocol);
+ g_free(host_p);
+
+ return g_strdup(result);
}
int __pacrunner_manual_init(void)