Skip to content

Commit 51e6e5b

Browse files
committed
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
1 parent 1d76ecb commit 51e6e5b

File tree

5 files changed

+35
-2
lines changed

5 files changed

+35
-2
lines changed

openvpn.8

+7-1
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,13 @@ block. The effect would be as if
378378
were declared in all
379379
.B <connection>
380380
blocks below it.
381-
381+
.\"*********************************************************
382+
.TP
383+
.B --proto-force p
384+
When iterating through connection profiles,
385+
only consider profiles using protocol
386+
.B p
387+
('tcp'|'udp').
382388
.\"*********************************************************
383389
.TP
384390
.B --remote-random

options.c

+19
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ static const char usage_message[] =
9494
"--mode m : Major mode, m = 'p2p' (default, point-to-point) or 'server'.\n"
9595
"--proto p : Use protocol p for communicating with peer.\n"
9696
" p = udp (default), tcp-server, or tcp-client\n"
97+
"--proto-force p : only consider protocol p in list of connection profiles.\n"
9798
"--connect-retry n : For --proto tcp-client, number of seconds to wait\n"
9899
" between connection retries (default=%d).\n"
99100
"--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)
693694
o->route_delay_window = 30;
694695
o->max_routes = MAX_ROUTES_DEFAULT;
695696
o->resolve_retry_seconds = RESOLV_RETRY_INFINITE;
697+
o->proto_force = -1;
696698
#ifdef ENABLE_OCC
697699
o->occ = true;
698700
#endif
@@ -2129,6 +2131,10 @@ options_postprocess_mutate_ce (struct options *o, struct connection_entry *ce)
21292131

21302132
if (!ce->bind_local)
21312133
ce->local_port = 0;
2134+
2135+
/* if protocol forcing is enabled, disable all protocols except for the forced one */
2136+
if (o->proto_force >= 0 && is_proto_tcp(o->proto_force) != is_proto_tcp(ce->proto))
2137+
ce->flags |= CE_DISABLED;
21322138
}
21332139

21342140
static void
@@ -4311,6 +4317,19 @@ add_option (struct options *options,
43114317
}
43124318
options->ce.proto = proto;
43134319
}
4320+
else if (streq (p[0], "proto-force") && p[1])
4321+
{
4322+
int proto_force;
4323+
VERIFY_PERMISSION (OPT_P_GENERAL);
4324+
proto_force = ascii2proto (p[1]);
4325+
if (proto_force < 0)
4326+
{
4327+
msg (msglevel, "Bad --proto-force protocol: '%s'", p[1]);
4328+
goto err;
4329+
}
4330+
options->proto_force = proto_force;
4331+
options->force_connection_list = true;
4332+
}
43144333
#ifdef GENERAL_PROXY_SUPPORT
43154334
else if (streq (p[0], "auto-proxy"))
43164335
{

options.h

+2
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,8 @@ struct options
216216
bool tun_mtu_defined; /* true if user overriding parm with command line option */
217217
bool link_mtu_defined; /* true if user overriding parm with command line option */
218218

219+
int proto_force;
220+
219221
/* Advanced MTU negotiation and datagram fragmentation options */
220222
int mtu_discover_type; /* used if OS supports setting Path MTU discovery options on socket */
221223

socket.h

+6
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,12 @@ legal_ipv4_port (int port)
509509
return port > 0 && port < 65536;
510510
}
511511

512+
static inline int
513+
is_proto_tcp(const int p)
514+
{
515+
return p > 0; /* depends on the definition of PROTO_x */
516+
}
517+
512518
static inline bool
513519
link_socket_proto_connection_oriented (int proto)
514520
{

version.m4

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
dnl define the OpenVPN version
2-
define(PRODUCT_VERSION,[2.1.3])
2+
define(PRODUCT_VERSION,[2.1.3a])
33
dnl define the TAP version
44
define(PRODUCT_TAP_ID,[tap0901])
55
define(PRODUCT_TAP_WIN32_MIN_MAJOR,[9])

0 commit comments

Comments
 (0)