remote-override <alt-remote> -- replace the hostname in all remote directives with alt-remote.
Merged from OpenVPN 2.1 Signed-off-by: James Yonan <ja...@openvpn.net> --- doc/openvpn.8 | 5 +++++ src/openvpn/options.c | 8 +++++++- src/openvpn/options.h | 2 ++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/doc/openvpn.8 b/doc/openvpn.8 index 628d877..249100d 100644 --- a/doc/openvpn.8 +++ b/doc/openvpn.8 @@ -281,6 +281,11 @@ DNS caching. For example, "foo.bar.gov" would be modified to "<random-chars>.foo.bar.gov". .\"********************************************************* .TP +.B \-\-remote-override [alt-remote] +Replace the hostname in all remote directives with +.B alt-remote. +.\"********************************************************* +.TP .B <connection> Define a client connection profile. Client connection profiles are groups of OpenVPN options that diff --git a/src/openvpn/options.c b/src/openvpn/options.c index 02def3a..0942a4d 100644 --- a/src/openvpn/options.c +++ b/src/openvpn/options.c @@ -118,6 +118,7 @@ static const char usage_message[] = "--remote host [port] : Remote host name or ip address.\n" "--remote-random : If multiple --remote options specified, choose one randomly.\n" "--remote-random-hostname : Add a random string to remote DNS name.\n" + "--remote-override a : Replace the hostname in all remote directives with a.\n" "--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" @@ -4565,6 +4566,11 @@ add_option (struct options *options, goto err; } #endif + else if (streq (p[0], "remote-override") && p[1]) + { + VERIFY_PERMISSION (OPT_P_GENERAL); + options->remote_override = p[1]; + } else if (streq (p[0], "remote") && p[1] && !p[4]) { struct remote_entry re; @@ -4573,7 +4579,7 @@ add_option (struct options *options, re.af=0; VERIFY_PERMISSION (OPT_P_GENERAL|OPT_P_CONNECTION); - re.remote = p[1]; + re.remote = options->remote_override ? options->remote_override : p[1]; if (p[2]) { re.remote_port = p[2]; diff --git a/src/openvpn/options.h b/src/openvpn/options.h index 23d3992..e281069 100644 --- a/src/openvpn/options.h +++ b/src/openvpn/options.h @@ -213,6 +213,8 @@ struct options struct remote_host_store *rh_store; + const char *remote_override; + bool remote_random; const char *ipchange; const char *dev; -- 1.9.1