From 9830ff83392c71acceba269ab918bab04c024869 Mon Sep 17 00:00:00 2001 From: Daniel Lenski Date: Tue, 19 May 2020 20:53:25 -0700 Subject: [PATCH] add OC_PROTO_HIDDEN and use this to hide nullppp from protocols displayed or shown by openconnect_get_supported_protocols Signed-off-by: Daniel Lenski --- library.c | 21 ++++++++++++--------- openconnect.h | 1 + 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/library.c b/library.c index 206949da..f7eca7d6 100644 --- a/library.c +++ b/library.c @@ -190,9 +190,9 @@ static const struct vpn_proto openconnect_protos[] = { #endif }, { .name = "nullppp", - .pretty_name = N_("nullppp"), + .pretty_name = N_("PPP over TLS"), .description = N_("Unauthenticated RFC1661/RFC1662 PPP over TLS, for testing"), - .flags = OC_PROTO_PROXY, + .flags = OC_PROTO_PROXY | OC_PROTO_HIDDEN, .tcp_connect = nullppp_connect, .tcp_mainloop = ppp_mainloop, .add_http_headers = http_common_headers, @@ -205,7 +205,7 @@ static const struct vpn_proto openconnect_protos[] = { int openconnect_get_supported_protocols(struct oc_vpn_proto **protos) { struct oc_vpn_proto *pr; - int i; + int i, j; /* The original version of this function included an all-zero * sentinel value at the end of the array, so we must continue @@ -217,13 +217,16 @@ int openconnect_get_supported_protocols(struct oc_vpn_proto **protos) if (!pr) return -ENOMEM; - for (i = 0; i < NR_PROTOS; i++) { - pr[i].name = openconnect_protos[i].name; - pr[i].pretty_name = _(openconnect_protos[i].pretty_name); - pr[i].description = _(openconnect_protos[i].description); - pr[i].flags = openconnect_protos[i].flags; + for (i = j = 0; i < NR_PROTOS; i++) { + if (!(openconnect_protos[i].flags & OC_PROTO_HIDDEN)) { + pr[j].name = openconnect_protos[i].name; + pr[j].pretty_name = _(openconnect_protos[i].pretty_name); + pr[j].description = _(openconnect_protos[i].description); + pr[j].flags = openconnect_protos[i].flags; + j++; + } } - return i; + return j; } void openconnect_free_supported_protocols(struct oc_vpn_proto *protos) diff --git a/openconnect.h b/openconnect.h index 5abb7bb8..9cc142fa 100644 --- a/openconnect.h +++ b/openconnect.h @@ -193,6 +193,7 @@ extern "C" { #define OC_PROTO_AUTH_OTP (1<<3) #define OC_PROTO_AUTH_STOKEN (1<<4) #define OC_PROTO_PERIODIC_TROJAN (1<<5) +#define OC_PROTO_HIDDEN (1<<6) struct oc_vpn_proto { const char *name; -- 2.49.0