aboutsummaryrefslogtreecommitdiff
path: root/proxy.c
diff options
context:
space:
mode:
authorjames <james@e7ae566f-a301-0410-adde-c780ea21d3b5>2005-12-08 23:10:22 +0000
committerjames <james@e7ae566f-a301-0410-adde-c780ea21d3b5>2005-12-08 23:10:22 +0000
commitdf5722cc68307206c5edcc94fd7ae333d3212b59 (patch)
tree6cf9b42be4660ac58cb61c76276f28f140b44b25 /proxy.c
parentInline file capability now works for (diff)
downloadopenvpn-df5722cc68307206c5edcc94fd7ae333d3212b59.tar.xz
First attempt at automatic proxy detection,
Windows-only at this point. Proxy settings are taken from IE. git-svn-id: http://svn.openvpn.net/projects/openvpn/branches/BETA21/openvpn@846 e7ae566f-a301-0410-adde-c780ea21d3b5
Diffstat (limited to 'proxy.c')
-rw-r--r--proxy.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/proxy.c b/proxy.c
index 0911733..0cfd51c 100644
--- a/proxy.c
+++ b/proxy.c
@@ -40,8 +40,62 @@
#include "proxy.h"
#include "ntlm.h"
+#ifdef WIN32
+#include "ieproxy.h"
+#endif
+
#include "memdbg.h"
+#ifdef WIN32
+
+bool
+get_http_proxy_settings (struct http_proxy_options *p, char **err, struct gc_arena *gc)
+{
+ bool ret = false;
+ const char *result;
+
+ p->server = NULL;
+ p->port = 0;
+ getIeHttpProxyError = NULL;
+ if (err)
+ *err = NULL;
+
+ result = getIeHttpProxy ();
+ if (result)
+ {
+ char addr_str[128];
+ char port_str[16];
+ struct buffer in;
+ buf_set_read (&in, (const uint8_t *)result, strlen (result));
+ if (buf_parse (&in, ':', addr_str, sizeof (addr_str))
+ && buf_parse (&in, ':', port_str, sizeof (port_str)))
+ {
+ p->server = string_alloc (addr_str, gc);
+ p->port = atoi (port_str);
+ ret = true;
+ }
+ free ((void *)result);
+ }
+ else if (getIeHttpProxyError)
+ {
+ if (err)
+ *err = string_alloc (getIeHttpProxyError, gc);
+ }
+ return ret;
+}
+
+#else
+
+bool
+get_http_proxy_settings (struct http_proxy_options *p, char **err, struct gc_arena *gc)
+{
+ if (err)
+ *err = string_alloc ("HTTP proxy detection not supported on this OS", gc);
+ return false;
+}
+
+#endif
+
/* cached proxy username/password */
static struct user_pass static_proxy_user_pass;