From: Dimitri Papadopoulos <3350651+DimitriPapadopoulos@users.noreply.gitlab.com> Date: Wed, 23 Jun 2021 09:17:18 +0000 (+0200) Subject: New option to define server name in config file X-Git-Tag: v8.20~136^2 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=a2fd6f4f2e8ac78e1ba28fd10fcbdf0f9074274f;p=users%2Fdwmw2%2Fopenconnect.git New option to define server name in config file Signed-off-by: Dimitri Papadopoulos <3350651+DimitriPapadopoulos@users.noreply.gitlab.com> --- diff --git a/main.c b/main.c index c68ba643..3259ab88 100644 --- a/main.c +++ b/main.c @@ -208,6 +208,7 @@ enum { OPT_PROTOCOL, OPT_PASSTOS, OPT_VERSION, + OPT_SERVER, }; #ifdef __sun__ @@ -300,6 +301,7 @@ static const struct option long_options[] = { #elif defined(OPENCONNECT_OPENSSL) OPTION("openssl-ciphers", 1, OPT_CIPHERSUITES), #endif + OPTION("server", 1, OPT_SERVER), OPTION(NULL, 0, 0) }; @@ -881,6 +883,7 @@ static void usage(void) printf(" --cafile=FILE %s\n", _("Cert file for server verification")); printf("\n%s:\n", _("Internet connectivity")); + printf(" --server=SERVER %s\n", _("Set VPN server")); printf(" -P, --proxy=URL %s\n", _("Set proxy server")); printf(" --proxy-auth=METHODS %s\n", _("Set proxy authentication methods")); printf(" --no-proxy %s\n", _("Disable proxy")); @@ -1366,6 +1369,10 @@ static int autocomplete(int argc, char **argv) } break; + case OPT_SERVER: /* --server */ + autocomplete_special("HOSTNAME", comp_opt, prefixlen, NULL); + break; + case 'i': /* --interface */ /* FIXME: Enumerate available tun devices */ break; @@ -2025,6 +2032,10 @@ int main(int argc, char **argv) vpninfo->ciphersuite_config = dup_config_arg(); break; + case OPT_SERVER: + if (openconnect_parse_url(vpninfo, config_arg)) + exit(1); + break; default: usage(); } @@ -2033,10 +2044,10 @@ int main(int argc, char **argv) if (gai_overrides) openconnect_override_getaddrinfo(vpninfo, gai_override_cb); - if (optind < argc - 1) { + if (optind < argc - (vpninfo->hostname ? 0 : 1)) { fprintf(stderr, _("Too many arguments on command line\n")); usage(); - } else if (optind > argc - 1) { + } else if (optind > argc - (vpninfo->hostname ? 0 : 1)) { fprintf(stderr, _("No server specified\n")); usage(); } diff --git a/openconnect.8.in b/openconnect.8.in index 8036c399..b9da423c 100644 --- a/openconnect.8.in +++ b/openconnect.8.in @@ -70,7 +70,7 @@ openconnect \- Multi-protocol VPN client, for Cisco AnyConnect VPNs and others .OP \-\-version\-string string .OP \-\-local-hostname string .OP \-\-os string -.B [https://]\fIserver\fB[:\fIport\fB][/\fIgroup\fB] +.B [\-\-server] [https://]\fIhost\fB[:\fIport\fB][/\fIgroup\fB] .YS .SH DESCRIPTION @@ -346,6 +346,19 @@ tun/tap device. This allows the VPN IP traffic to be handled entirely in userspace, for example by a program which uses lwIP to provide SOCKS access into the VPN. .TP +.B \-\-server=[https://]\fIHOST\fB[:\fIPORT\fB][/\fIGROUP\fB] +Define the VPN server as a simple +.I HOST +or as an URL containing the +. I HOST +and optionally the +.I PORT +number and the login +.I GROUP +or realm. + +As an alternative, define the VPN server as non-option command line argument. +.TP .B \-u,\-\-user=NAME Set login username to .I NAME