From 981b57ee28bc54d066cf11a5a8e8579c37d99043 Mon Sep 17 00:00:00 2001 From: Davide Beatrici Date: Mon, 11 May 2020 07:59:34 +0200 Subject: [PATCH] Cedar/Server: set ports in Proto, remove OpenVPN UDP server leftovers The setting's name is still "OpenVPN_UdpPortList". We will change it as soon as there's another UDP protocol implemented in Proto. --- src/Cedar/Server.c | 38 +++++++++----------------------------- src/Cedar/Server.h | 1 - 2 files changed, 9 insertions(+), 30 deletions(-) diff --git a/src/Cedar/Server.c b/src/Cedar/Server.c index 8f43404a..417a4480 100644 --- a/src/Cedar/Server.c +++ b/src/Cedar/Server.c @@ -33,6 +33,8 @@ void SiSetOpenVPNAndSSTPConfig(SERVER *s, OPENVPN_SSTP_CONFIG *c) Lock(s->OpenVpnSstpConfigLock); { + LIST *ports; + // Save the settings if (s->Cedar->Bridge || s->ServerType != SERVER_TYPE_STANDALONE) { @@ -45,24 +47,14 @@ void SiSetOpenVPNAndSSTPConfig(SERVER *s, OPENVPN_SSTP_CONFIG *c) s->DisableOpenVPNServer = !c->EnableOpenVPN; } - NormalizeIntListStr(s->OpenVpnServerUdpPorts, sizeof(s->OpenVpnServerUdpPorts), - c->OpenVPNPortList, true, ", "); + // TODO: Now that we have a unified protocol interface (Proto), the setting's name should be changed. + NormalizeIntListStr(s->OpenVpnServerUdpPorts, sizeof(s->OpenVpnServerUdpPorts), c->OpenVPNPortList, true, ", "); + ports = StrToIntList(s->OpenVpnServerUdpPorts, true); + ProtoSetUdpPorts(s->Proto, ports); + ReleaseIntList(ports); s->Cedar->OpenVPNObfuscation = c->OpenVPNObfuscation; StrCpy(s->Cedar->OpenVPNObfuscationMask, sizeof(s->Cedar->OpenVPNObfuscationMask), c->OpenVPNObfuscationMask); - - // Apply the OpenVPN configuration - if (s->OpenVpnServerUdp != NULL) - { - if (s->DisableOpenVPNServer) - { - OvsApplyUdpPortList(s->OpenVpnServerUdp, "", NULL); - } - else - { - OvsApplyUdpPortList(s->OpenVpnServerUdp, s->OpenVpnServerUdpPorts, &s->ListenIP); - } - } } Unlock(s->OpenVpnSstpConfigLock); } @@ -2629,8 +2621,6 @@ void SiInitConfiguration(SERVER *s) s->Proto = ProtoNew(s->Cedar); // IPsec server s->IPsecServer = NewIPsecServer(s->Cedar); - // OpenVPN server (UDP) - s->OpenVpnServerUdp = NewOpenVpnServerUdp(s->Cedar); } SLog(s->Cedar, "LS_LOAD_CONFIG_1"); @@ -5660,7 +5650,9 @@ void SiLoadServerCfg(SERVER *s, FOLDER *f) } s->DontBackupConfig = CfgGetBool(f, "DontBackupConfig"); + CfgGetIp(f, "ListenIP", &s->ListenIP); + ProtoSetListenIP(s->Proto, &s->ListenIP); if (CfgIsItem(f, "BackupConfigOnlyWhenModified")) { @@ -6036,10 +6028,6 @@ void SiLoadServerCfg(SERVER *s, FOLDER *f) } SetDhParam(DhNewFromBits(c->DhParamBits)); - if (s->OpenVpnServerUdp) - { - OpenVpnServerUdpSetDhParam(s->OpenVpnServerUdp, DhNewFromBits(c->DhParamBits)); - } } Unlock(c->lock); @@ -6549,14 +6537,6 @@ void SiFreeConfiguration(SERVER *s) s->IPsecServer = NULL; } - // Terminate the OpenVPN server - if (s->OpenVpnServerUdp != NULL) - { - FreeOpenVpnServerUdp(s->OpenVpnServerUdp); - s->OpenVpnServerUdp = NULL; - } - - // Terminate the DDNS client if (s->DDnsClient != NULL) { diff --git a/src/Cedar/Server.h b/src/Cedar/Server.h index 75225ecf..cd26634d 100644 --- a/src/Cedar/Server.h +++ b/src/Cedar/Server.h @@ -244,7 +244,6 @@ struct SERVER PROTO *Proto; // Protocols handler IPSEC_SERVER *IPsecServer; // IPsec server function - OPENVPN_SERVER_UDP *OpenVpnServerUdp; // OpenVPN server function char OpenVpnServerUdpPorts[MAX_SIZE]; // UDP port list string DDNS_CLIENT *DDnsClient; // DDNS client feature LOCK *OpenVpnSstpConfigLock; // Lock OpenVPN and SSTP configuration