[PATCH] Allow specifying server in configuration file

Max Rees maxcrees at me.com
Mon Apr 2 23:03:18 PDT 2018


This allows the configuration file to have an entry of the form:
server https://server[:port][/group]
similar to the CLI invocation.

Signed-off-by: Max Rees <maxcrees at me.com>
---
 main.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/main.c b/main.c
index d09efd5..23b0efc 100644
--- a/main.c
+++ b/main.c
@@ -187,6 +187,7 @@ enum {
 	OPT_HTTP_AUTH,
 	OPT_LOCAL_HOSTNAME,
 	OPT_PROTOCOL,
+	OPT_SERVER,
 	OPT_PASSTOS,
 };
 
@@ -269,6 +270,7 @@ static const struct option long_options[] = {
 	OPTION("dump-http-traffic", 0, OPT_DUMP_HTTP),
 	OPTION("no-system-trust", 0, OPT_NO_SYSTEM_TRUST),
 	OPTION("protocol", 1, OPT_PROTOCOL),
+	OPTION("server", 1, OPT_SERVER),
 #ifdef OPENCONNECT_GNUTLS
 	OPTION("gnutls-debug", 1, OPT_GNUTLS_DEBUG),
 #endif
@@ -1164,6 +1166,10 @@ int main(int argc, char **argv)
 			if (openconnect_set_protocol(vpninfo, config_arg))
 				exit(1);
 			break;
+		case OPT_SERVER:
+			if (openconnect_parse_url(vpninfo, config_arg))
+				exit(1);
+			break;
 		case OPT_JUNIPER:
 			fprintf(stderr, "WARNING: Juniper Network Connect support is experimental.\n");
 			fprintf(stderr, "It will probably be superseded by Junos Pulse support.\n");
@@ -1457,7 +1463,7 @@ int main(int argc, char **argv)
 	if (optind < argc - 1) {
 		fprintf(stderr, _("Too many arguments on command line\n"));
 		usage();
-	} else if (optind > argc - 1) {
+	} else if (optind > argc - 1 && !vpninfo->hostname) {
 		fprintf(stderr, _("No server specified\n"));
 		usage();
 	}
-- 
2.15.0




More information about the openconnect-devel mailing list