Browse code

remove the --auto-proxy option from openvpn

During discussion on FOSDEM 2012 it was decided that proxy auto detection
is best done in the GUI as it's highly platform specific and shouldn't be
handled in openvpn itself for every supported platform in openvpn itself.

This removes --auto-proxy from openvpn.

Signed-off-by: Heiko Hund <heiko.hund@sophos.com>
Acked-by: David Sommerseth <davids@redhat.com>
Message-Id: 1328446029-30523-1-git-send-email-heiko.hund@sophos.com
URL: http://article.gmane.org/gmane.network.openvpn.devel/5333
Signed-off-by: David Sommerseth <davids@redhat.com>

Heiko Hund authored on 2012/02/05 21:47:09
Showing 8 changed files
... ...
@@ -482,18 +482,6 @@ as the
482 482
 number of retries of connection attempt (default=infinite).
483 483
 .\"*********************************************************
484 484
 .TP
485
-.B \-\-auto-proxy
486
-Try to sense HTTP or SOCKS proxy settings automatically.
487
-If no settings are present, a direct connection will be attempted.
488
-If both HTTP and SOCKS settings are present, HTTP will be preferred.
489
-If the HTTP proxy server requires a password, it will be queried from
490
-stdin or the management interface.  If the underlying OS doesn't support an API for
491
-returning proxy settings, a direct connection will be attempted.
492
-Currently, only Windows clients support this option via the
493
-InternetQueryOption API.
494
-This option exists in OpenVPN 2.1 or higher.
495
-.\"*********************************************************
496
-.TP
497 485
 .B \-\-show-proxy-settings
498 486
 Show sensed HTTP or SOCKS proxy settings. Currently, only Windows clients
499 487
 support this option.
... ...
@@ -498,11 +498,10 @@ init_proxy_dowork (struct context *c)
498 498
   uninit_proxy_dowork (c);
499 499
 
500 500
 #ifdef ENABLE_HTTP_PROXY
501
-  if (c->options.ce.http_proxy_options || c->options.auto_proxy_info)
501
+  if (c->options.ce.http_proxy_options)
502 502
     {
503 503
       /* Possible HTTP proxy user/pass input */
504
-      c->c1.http_proxy = http_proxy_new (c->options.ce.http_proxy_options,
505
-					 c->options.auto_proxy_info);
504
+      c->c1.http_proxy = http_proxy_new (c->options.ce.http_proxy_options);
506 505
       if (c->c1.http_proxy)
507 506
 	{
508 507
 	  did_http = true;
... ...
@@ -512,13 +511,12 @@ init_proxy_dowork (struct context *c)
512 512
 #endif
513 513
 
514 514
 #ifdef ENABLE_SOCKS
515
-  if (!did_http && (c->options.ce.socks_proxy_server || c->options.auto_proxy_info))
515
+  if (!did_http && c->options.ce.socks_proxy_server)
516 516
     {
517 517
       c->c1.socks_proxy = socks_proxy_new (c->options.ce.socks_proxy_server,
518 518
 					   c->options.ce.socks_proxy_port,
519 519
 					   c->options.ce.socks_proxy_authfile,
520
-					   c->options.ce.socks_proxy_retry,
521
-					   c->options.auto_proxy_info);
520
+					   c->options.ce.socks_proxy_retry);
522 521
       if (c->c1.socks_proxy)
523 522
 	{
524 523
 	  c->c1.socks_proxy_owned = true;
... ...
@@ -135,10 +135,6 @@ static const char usage_message[] =
135 135
   "                    between connection retries (default=%d).\n"
136 136
   "--connect-timeout n : For --proto tcp-client, connection timeout (in seconds).\n"
137 137
   "--connect-retry-max n : Maximum connection attempt retries, default infinite.\n"
138
-#ifdef GENERAL_PROXY_SUPPORT
139
-  "--auto-proxy    : Try to sense proxy settings (or lack thereof) automatically.\n"
140
-  "--show-proxy-settings : Show sensed proxy settings.\n"
141
-#endif
142 138
 #ifdef ENABLE_HTTP_PROXY
143 139
   "--http-proxy s p [up] [auth] : Connect to remote host\n"
144 140
   "                  through an HTTP proxy at address s and port p.\n"
... ...
@@ -2060,8 +2056,8 @@ options_postprocess_verify_ce (const struct options *options, const struct conne
2060 2060
     msg (M_USAGE, "--remote MUST be used in TCP Client mode");
2061 2061
 
2062 2062
 #ifdef ENABLE_HTTP_PROXY
2063
-  if ((ce->http_proxy_options || options->auto_proxy_info) && ce->proto != PROTO_TCPv4_CLIENT)
2064
-    msg (M_USAGE, "--http-proxy or --auto-proxy MUST be used in TCP Client mode (i.e. --proto tcp-client)");
2063
+  if ((ce->http_proxy_options) && ce->proto != PROTO_TCPv4_CLIENT)
2064
+    msg (M_USAGE, "--http-proxy MUST be used in TCP Client mode (i.e. --proto tcp-client)");
2065 2065
 #endif
2066 2066
 
2067 2067
 #if defined(ENABLE_HTTP_PROXY) && defined(ENABLE_SOCKS)
... ...
@@ -5000,38 +4996,6 @@ add_option (struct options *options,
5000 5000
       options->proto_force = proto_force;
5001 5001
       options->force_connection_list = true;
5002 5002
     }
5003
-#ifdef GENERAL_PROXY_SUPPORT
5004
-  else if (streq (p[0], "auto-proxy"))
5005
-    {
5006
-      char *error = NULL;
5007
-
5008
-      VERIFY_PERMISSION (OPT_P_GENERAL);
5009
-      options->auto_proxy_info = get_proxy_settings (&error, &options->gc);
5010
-      if (error)
5011
-	msg (M_WARN, "PROXY: %s", error);
5012
-    }
5013
-  else if (streq (p[0], "show-proxy-settings"))
5014
-    {
5015
-      struct auto_proxy_info *pi;
5016
-      char *error = NULL;
5017
-
5018
-      VERIFY_PERMISSION (OPT_P_GENERAL);
5019
-      pi = get_proxy_settings (&error, &options->gc);
5020
-      if (pi)
5021
-	{
5022
-	  msg (M_INFO|M_NOPREFIX, "HTTP Server: %s", np(pi->http.server));
5023
-	  msg (M_INFO|M_NOPREFIX, "HTTP Port: %d", pi->http.port);
5024
-	  msg (M_INFO|M_NOPREFIX, "SOCKS Server: %s", np(pi->socks.server));
5025
-	  msg (M_INFO|M_NOPREFIX, "SOCKS Port: %d", pi->socks.port);
5026
-	}
5027
-      if (error)
5028
-	msg (msglevel, "Proxy error: %s", error);
5029
-#ifdef WIN32
5030
-      show_win_proxy_settings (M_INFO|M_NOPREFIX);
5031
-#endif
5032
-      openvpn_exit (OPENVPN_EXIT_STATUS_GOOD); /* exit point */
5033
-    }
5034
-#endif /* GENERAL_PROXY_SUPPORT */
5035 5003
 #ifdef ENABLE_HTTP_PROXY
5036 5004
   else if (streq (p[0], "http-proxy") && p[1])
5037 5005
     {
... ...
@@ -232,10 +232,6 @@ struct options
232 232
   bool force_connection_list;
233 233
 #endif
234 234
 
235
-#ifdef GENERAL_PROXY_SUPPORT
236
-  struct auto_proxy_info *auto_proxy_info;
237
-#endif
238
-
239 235
 #if HTTP_PROXY_FALLBACK
240 236
   bool http_proxy_fallback;
241 237
   struct http_proxy_options *http_proxy_override;
... ...
@@ -421,47 +421,11 @@ get_pa_var (const char *key, const char *pa, struct gc_arena *gc)
421 421
 }
422 422
 
423 423
 struct http_proxy_info *
424
-http_proxy_new (const struct http_proxy_options *o,
425
-		struct auto_proxy_info *auto_proxy_info)
424
+http_proxy_new (const struct http_proxy_options *o)
426 425
 {
427 426
   struct http_proxy_info *p;
428 427
   struct http_proxy_options opt;
429 428
 
430
-  if (auto_proxy_info)
431
-    {
432
-      if (o && o->server)
433
-	{
434
-	  /* if --http-proxy explicitly given, disable auto-proxy */
435
-	  auto_proxy_info = NULL;
436
-	}
437
-      else
438
-	{
439
-	  /* if no --http-proxy explicitly given and no auto settings, fail */
440
-	  if (!auto_proxy_info->http.server)
441
-	    return NULL;
442
-
443
-	  if (o)
444
-	    {
445
-	      opt = *o;
446
-	    }
447
-	  else
448
-	    {
449
-	      CLEAR (opt);
450
-	  
451
-	      /* These settings are only used for --auto-proxy */
452
-	      opt.timeout = 5;
453
-	      opt.http_version = "1.0";
454
-	    }
455
-
456
-	  opt.server = auto_proxy_info->http.server;
457
-	  opt.port = auto_proxy_info->http.port;
458
-	  if (!opt.auth_retry)
459
-	    opt.auth_retry = PAR_ALL;
460
-
461
-	  o = &opt;
462
-	}
463
-    }
464
-
465 429
   if (!o || !o->server)
466 430
     msg (M_FATAL, "HTTP_PROXY: server not specified");
467 431
 
... ...
@@ -527,7 +491,7 @@ establish_http_proxy_passthru (struct http_proxy_info *p,
527 527
   bool ret = false;
528 528
   bool processed = false;
529 529
 
530
-  /* get user/pass if not previously given or if --auto-proxy is being used */
530
+  /* get user/pass if not previously given */
531 531
   if (p->auth_method == HTTP_AUTH_BASIC
532 532
       || p->auth_method == HTTP_AUTH_DIGEST
533 533
       || p->auth_method == HTTP_AUTH_NTLM)
... ...
@@ -926,205 +890,3 @@ establish_http_proxy_passthru (struct http_proxy_info *p,
926 926
 static void dummy(void) {}
927 927
 #endif /* ENABLE_HTTP_PROXY */
928 928
 
929
-#ifdef GENERAL_PROXY_SUPPORT
930
-
931
-#ifdef WIN32
932
-
933
-#if 0
934
-char *
935
-get_windows_internet_string (const DWORD dwOption, struct gc_arena *gc)
936
-{
937
-  DWORD size = 0;
938
-  char *ret = NULL;
939
-
940
-  /* Initially, get size of return buffer */
941
-  InternetQueryOption (NULL, dwOption, NULL, &size);
942
-  if (size)
943
-    {
944
-      /* Now get actual info */
945
-      ret = (INTERNET_PROXY_INFO *) gc_malloc (size, false, gc);
946
-      if (!InternetQueryOption (NULL, dwOption, (LPVOID) ret, &size))
947
-	ret = NULL;
948
-    }
949
-  return ret;
950
-}
951
-#endif
952
-
953
-static INTERNET_PROXY_INFO *
954
-get_windows_proxy_settings (struct gc_arena *gc)
955
-{
956
-  DWORD size = 0;
957
-  INTERNET_PROXY_INFO *ret = NULL;
958
-
959
-  /* Initially, get size of return buffer */
960
-  InternetQueryOption (NULL, INTERNET_OPTION_PROXY, NULL, &size);
961
-  if (size)
962
-    {
963
-      /* Now get actual info */
964
-      ret = (INTERNET_PROXY_INFO *) gc_malloc (size, false, gc);
965
-      if (!InternetQueryOption (NULL, INTERNET_OPTION_PROXY, (LPVOID) ret, &size))
966
-	ret = NULL;
967
-    }
968
-  return ret;
969
-}
970
-
971
-static const char *
972
-parse_windows_proxy_setting (const char *str, struct auto_proxy_info_entry *e, struct gc_arena *gc)
973
-{
974
-  char buf[128];
975
-  const char *ret = NULL;
976
-  struct buffer in;
977
-
978
-  CLEAR (*e);
979
-
980
-  buf_set_read (&in, (const uint8_t *)str, strlen (str));
981
-
982
-  if (strchr (str, '=') != NULL)
983
-    {
984
-      if (buf_parse (&in, '=', buf, sizeof (buf)))
985
-	ret = string_alloc (buf, gc);
986
-    }
987
-	
988
-  if (buf_parse (&in, ':', buf, sizeof (buf)))
989
-    e->server = string_alloc (buf, gc);
990
-
991
-  if (e->server && buf_parse (&in, '\0', buf, sizeof (buf)))
992
-    e->port = atoi (buf);
993
-
994
-  return ret;
995
-}
996
-
997
-static void
998
-parse_windows_proxy_setting_list (const char *str, const char *type, struct auto_proxy_info_entry *e, struct gc_arena *gc)
999
-{
1000
-  struct gc_arena gc_local = gc_new ();
1001
-  struct auto_proxy_info_entry el;
1002
-
1003
-  CLEAR (*e);
1004
-  if (type)
1005
-    {
1006
-      char buf[128];
1007
-      struct buffer in;
1008
-
1009
-      buf_set_read (&in, (const uint8_t *)str, strlen (str));
1010
-      if (strchr (str, '=') != NULL)
1011
-	{
1012
-	  while (buf_parse (&in, ' ', buf, sizeof (buf)))
1013
-	    {
1014
-	      const char *t = parse_windows_proxy_setting (buf, &el, &gc_local);
1015
-	      if (t && !strcmp (t, type))
1016
-		goto found;
1017
-	    }
1018
-	}
1019
-    }
1020
-  else
1021
-    {
1022
-      if (!parse_windows_proxy_setting (str, &el, &gc_local))
1023
-	goto found;
1024
-    }
1025
-  goto done;
1026
-
1027
- found:
1028
-  if (el.server && el.port > 0)
1029
-    {
1030
-      e->server = string_alloc (el.server, gc);
1031
-      e->port = el.port;
1032
-    }
1033
-
1034
- done:
1035
-  gc_free (&gc_local);
1036
-}
1037
-
1038
-static const char *
1039
-win_proxy_access_type (const DWORD dwAccessType)
1040
-{
1041
-  switch (dwAccessType)
1042
-    {
1043
-    case INTERNET_OPEN_TYPE_DIRECT:
1044
-      return "INTERNET_OPEN_TYPE_DIRECT";
1045
-    case INTERNET_OPEN_TYPE_PROXY:
1046
-      return "INTERNET_OPEN_TYPE_PROXY";
1047
-    default:
1048
-      return "[UNKNOWN]";
1049
-    }
1050
-}
1051
-
1052
-void
1053
-show_win_proxy_settings (const int msglevel)
1054
-{
1055
-  INTERNET_PROXY_INFO *info;
1056
-  struct gc_arena gc = gc_new ();
1057
-
1058
-  info = get_windows_proxy_settings (&gc);
1059
-  msg (msglevel, "PROXY INFO: %s %s",
1060
-       win_proxy_access_type (info->dwAccessType),
1061
-       info->lpszProxy ? info->lpszProxy : "[NULL]");
1062
-
1063
-  gc_free (&gc);
1064
-}
1065
-
1066
-struct auto_proxy_info *
1067
-get_proxy_settings (char **err, struct gc_arena *gc)
1068
-{
1069
-  struct gc_arena gc_local = gc_new ();
1070
-  INTERNET_PROXY_INFO *info;
1071
-  struct auto_proxy_info *pi;
1072
-
1073
-  ALLOC_OBJ_CLEAR_GC (pi, struct auto_proxy_info, gc);
1074
-
1075
-  if (err)
1076
-    *err = NULL;
1077
-
1078
-  info = get_windows_proxy_settings (&gc_local);
1079
-
1080
-  if (!info)
1081
-    {
1082
-      if (err)
1083
-	*err = "PROXY: failed to obtain windows proxy info";
1084
-      goto done;
1085
-    }
1086
-
1087
-  switch (info->dwAccessType)
1088
-    {
1089
-    case INTERNET_OPEN_TYPE_DIRECT:
1090
-      break;
1091
-    case INTERNET_OPEN_TYPE_PROXY:
1092
-      if (!info->lpszProxy)
1093
-	break;
1094
-      parse_windows_proxy_setting_list (info->lpszProxy, NULL, &pi->http, gc);
1095
-      if (!pi->http.server)
1096
-	parse_windows_proxy_setting_list (info->lpszProxy, "http", &pi->http, gc);
1097
-      parse_windows_proxy_setting_list (info->lpszProxy, "socks", &pi->socks, gc);
1098
-      break;
1099
-    default:
1100
-      if (err)
1101
-	*err = "PROXY: unknown proxy type";
1102
-      break;
1103
-    }
1104
-
1105
- done:
1106
-  gc_free (&gc_local);
1107
-  return pi;
1108
-}
1109
-
1110
-#else
1111
-
1112
-struct auto_proxy_info *
1113
-get_proxy_settings (char **err, struct gc_arena *gc)
1114
-{
1115
-#if 1
1116
-  if (err)
1117
-    *err = string_alloc ("PROXY: automatic detection not supported on this OS", gc);
1118
-  return NULL;
1119
-#else /* test --auto-proxy feature */
1120
-  struct auto_proxy_info *pi;
1121
-  ALLOC_OBJ_CLEAR_GC (pi, struct auto_proxy_info, gc);
1122
-  pi->http.server = "10.10.0.2";
1123
-  pi->http.port = 4000;
1124
-  return pi;
1125
-#endif
1126
-}
1127
-
1128
-#endif
1129
-
1130
-#endif /* GENERAL_PROXY_SUPPORT */
... ...
@@ -28,30 +28,6 @@
28 28
 #include "buffer.h"
29 29
 #include "misc.h"
30 30
 
31
-#ifdef GENERAL_PROXY_SUPPORT
32
-
33
-/*
34
- * Return value for get_proxy_settings to automatically
35
- * determine proxy information.
36
- */
37
-struct auto_proxy_info_entry {
38
-  char *server;
39
-  int port;
40
-};
41
-
42
-struct auto_proxy_info {
43
-  struct auto_proxy_info_entry http;
44
-  struct auto_proxy_info_entry socks;
45
-};
46
-
47
-struct auto_proxy_info *get_proxy_settings (char **err, struct gc_arena *gc);
48
-
49
-#ifdef WIN32
50
-void show_win_proxy_settings (const int msglevel);
51
-#endif /* WIN32 */
52
-
53
-#endif /* GENERAL_PROXY_SUPPORT */
54
-
55 31
 #ifdef ENABLE_HTTP_PROXY
56 32
 
57 33
 /* HTTP CONNECT authentication methods */
... ...
@@ -94,8 +70,7 @@ struct http_proxy_info {
94 94
   bool queried_creds;
95 95
 };
96 96
 
97
-struct http_proxy_info *http_proxy_new (const struct http_proxy_options *o,
98
-					struct auto_proxy_info *auto_proxy_info);
97
+struct http_proxy_info *http_proxy_new (const struct http_proxy_options *o);
99 98
 
100 99
 void http_proxy_close (struct http_proxy_info *hp);
101 100
 
... ...
@@ -63,23 +63,10 @@ struct socks_proxy_info *
63 63
 socks_proxy_new (const char *server,
64 64
 		 int port,
65 65
 		 const char *authfile,
66
-		 bool retry,
67
-		 struct auto_proxy_info *auto_proxy_info)
66
+		 bool retry)
68 67
 {
69 68
   struct socks_proxy_info *p;
70 69
 
71
-  if (auto_proxy_info)
72
-    {
73
-      if (!server)
74
-	{
75
-	  if (!auto_proxy_info->socks.server)
76
-	    return NULL;
77
-
78
-	  server = auto_proxy_info->socks.server;
79
-	  port = auto_proxy_info->socks.port;
80
-	}
81
-    }
82
-
83 70
   ALLOC_OBJ_CLEAR (p, struct socks_proxy_info);
84 71
 
85 72
   ASSERT (server);
... ...
@@ -51,8 +51,7 @@ void socks_adjust_frame_parameters (struct frame *frame, int proto);
51 51
 struct socks_proxy_info *socks_proxy_new (const char *server,
52 52
 					  int port,
53 53
 					  const char *authfile,
54
-					  bool retry,
55
-					  struct auto_proxy_info *auto_proxy_info);
54
+					  bool retry);
56 55
 
57 56
 void socks_proxy_close (struct socks_proxy_info *sp);
58 57