]> www.infradead.org Git - users/dwmw2/openconnect.git/commitdiff
New option to define server name in config file
authorDimitri Papadopoulos <3350651+DimitriPapadopoulos@users.noreply.gitlab.com>
Wed, 23 Jun 2021 09:17:18 +0000 (11:17 +0200)
committerDimitri Papadopoulos <3350651+DimitriPapadopoulos@users.noreply.gitlab.com>
Sun, 27 Jun 2021 08:44:34 +0000 (10:44 +0200)
Signed-off-by: Dimitri Papadopoulos <3350651+DimitriPapadopoulos@users.noreply.gitlab.com>
main.c
openconnect.8.in

diff --git a/main.c b/main.c
index c68ba6439ea2c9d27c41eecfeba30f58439d89ea..3259ab8877cf473c3565606fe076b2acb61ad773 100644 (file)
--- 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();
        }
index 8036c399a860e3d3fd945339a8f22c967c22dca8..b9da423ce8043a27941ae4162bfe715f6477aae0 100644 (file)
@@ -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