summaryrefslogtreecommitdiffstats
path: root/options.c
diff options
context:
space:
mode:
authorJames Yonan <james@openvpn.net>2010-09-01 06:04:29 +0000
committerJames Yonan <james@openvpn.net>2010-09-01 06:04:29 +0000
commit51e6e5b0f14db8bf5a6b6ebee26678fe8b623ad4 (patch)
tree6dbf2460c7ee52862759bc1e9db1d154fb1a732a /options.c
parent1d76ecbcd03de5bbf97f9969f15debddd0387b87 (diff)
downloadopenvpn-51e6e5b0f14db8bf5a6b6ebee26678fe8b623ad4.tar.gz
openvpn-51e6e5b0f14db8bf5a6b6ebee26678fe8b623ad4.tar.xz
openvpn-51e6e5b0f14db8bf5a6b6ebee26678fe8b623ad4.zip
Added --proto-force directive.
Version 2.1.3a git-svn-id: http://svn.openvpn.net/projects/openvpn/branches/BETA21/openvpn@6424 e7ae566f-a301-0410-adde-c780ea21d3b5
Diffstat (limited to 'options.c')
-rw-r--r--options.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/options.c b/options.c
index b1ac26c..5f1efc5 100644
--- a/options.c
+++ b/options.c
@@ -94,6 +94,7 @@ static const char usage_message[] =
"--mode m : Major mode, m = 'p2p' (default, point-to-point) or 'server'.\n"
"--proto p : Use protocol p for communicating with peer.\n"
" p = udp (default), tcp-server, or tcp-client\n"
+ "--proto-force p : only consider protocol p in list of connection profiles.\n"
"--connect-retry n : For --proto tcp-client, number of seconds to wait\n"
" between connection retries (default=%d).\n"
"--connect-timeout n : For --proto tcp-client, connection timeout (in seconds).\n"
@@ -693,6 +694,7 @@ init_options (struct options *o, const bool init_gc)
o->route_delay_window = 30;
o->max_routes = MAX_ROUTES_DEFAULT;
o->resolve_retry_seconds = RESOLV_RETRY_INFINITE;
+ o->proto_force = -1;
#ifdef ENABLE_OCC
o->occ = true;
#endif
@@ -2129,6 +2131,10 @@ options_postprocess_mutate_ce (struct options *o, struct connection_entry *ce)
if (!ce->bind_local)
ce->local_port = 0;
+
+ /* if protocol forcing is enabled, disable all protocols except for the forced one */
+ if (o->proto_force >= 0 && is_proto_tcp(o->proto_force) != is_proto_tcp(ce->proto))
+ ce->flags |= CE_DISABLED;
}
static void
@@ -4311,6 +4317,19 @@ add_option (struct options *options,
}
options->ce.proto = proto;
}
+ else if (streq (p[0], "proto-force") && p[1])
+ {
+ int proto_force;
+ VERIFY_PERMISSION (OPT_P_GENERAL);
+ proto_force = ascii2proto (p[1]);
+ if (proto_force < 0)
+ {
+ msg (msglevel, "Bad --proto-force protocol: '%s'", p[1]);
+ goto err;
+ }
+ options->proto_force = proto_force;
+ options->force_connection_list = true;
+ }
#ifdef GENERAL_PROXY_SUPPORT
else if (streq (p[0], "auto-proxy"))
{