1
0
mirror of https://github.com/SoftEtherVPN/SoftEtherVPN.git synced 2025-07-07 08:14:58 +03:00

Cedar/SM.c: move UDP ports setting outside of the OpenVPN/SSTP dialog

This commit moves the UDP ports setting right below the TCP listeners and uses the new RPC methods to get and set them.
This commit is contained in:
Davide Beatrici
2020-05-20 04:41:18 +02:00
parent c52e49de2d
commit c4838006b1
10 changed files with 105 additions and 62 deletions

View File

@ -1072,7 +1072,6 @@ UINT SmOpenVpnDlg(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, void *param
switch (LOWORD(wParam))
{
case R_OPENVPN:
case E_UDP:
case R_SSTP:
SmOpenVpnDlgUpdate(hWnd, s);
break;
@ -1084,12 +1083,6 @@ UINT SmOpenVpnDlg(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, void *param
SmOpenVpnDlgOnOk(hWnd, s, false);
break;
case B_DEFAULT:
ToStr(tmp, OPENVPN_UDP_PORT);
SetTextA(hWnd, E_UDP, tmp);
FocusEx(hWnd, E_UDP);
break;
case B_CONFIG:
// Create an OpenVPN configuration
{
@ -1198,13 +1191,11 @@ void SmOpenVpnDlgInit(HWND hWnd, SM_SERVER *s)
}
Check(hWnd, R_OPENVPN, t.EnableOpenVPN);
SetTextA(hWnd, E_UDP, t.OpenVPNPortList);
Check(hWnd, R_SSTP, t.EnableSSTP);
SetIcon(hWnd, 0, ICO_OPENVPN);
DlgFont(hWnd, S_TITLE, 14, true);
SetFont(hWnd, E_UDP, GetFont("Verdana", 10, false, false, false, false));
DlgFont(hWnd, R_OPENVPN, 0, true);
DlgFont(hWnd, S_TOOL, 11, true);
@ -1224,10 +1215,6 @@ void SmOpenVpnDlgUpdate(HWND hWnd, SM_SERVER *s)
b1 = IsChecked(hWnd, R_OPENVPN);
b2 = IsChecked(hWnd, R_SSTP);
SetEnable(hWnd, S_UDP, b1);
SetEnable(hWnd, E_UDP, b1);
SetEnable(hWnd, B_DEFAULT, b1);
SetEnable(hWnd, S_UDP2, b1);
SetEnable(hWnd, S_TOOL, b1);
SetEnable(hWnd, S_TOOL2, b1);
SetEnable(hWnd, B_CONFIG, b1);
@ -1246,7 +1233,6 @@ void SmOpenVpnDlgOnOk(HWND hWnd, SM_SERVER *s, bool no_close)
Zero(&t, sizeof(t));
t.EnableOpenVPN = IsChecked(hWnd, R_OPENVPN);
GetTxtA(hWnd, E_UDP, t.OpenVPNPortList, sizeof(t.OpenVPNPortList));
t.EnableSSTP = IsChecked(hWnd, R_SSTP);
if (CALL(hWnd, ScSetOpenVpnSstpConfig(s->Rpc, &t)) == false)
@ -18272,6 +18258,7 @@ void SmServerDlgRefresh(HWND hWnd, SM_SERVER *p)
{
RPC_ENUM_HUB t;
RPC_LISTENER_LIST t2;
RPC_PORTS t3;
DDNS_CLIENT_STATUS st;
RPC_AZURE_STATUS sta;
UINT i;
@ -18389,6 +18376,32 @@ void SmServerDlgRefresh(HWND hWnd, SM_SERVER *p)
FreeRpcListenerList(&t2);
}
// Get the UDP ports
Zero(&t3, sizeof(RPC_PORTS));
if (CALL(hWnd, ScGetPortsUDP(p->Rpc, &t3)))
{
char str[MAX_SIZE];
Zero(str, sizeof(str));
if (t3.Num > 0)
{
UINT i;
Format(str, sizeof(str), "%u", t3.Ports[0]);
for (i = 1; i < t3.Num; ++i)
{
char tmp[MAX_SIZE];
Format(tmp, sizeof(tmp), ", %u", t3.Ports[i]);
StrCat(str, sizeof(str), tmp);
}
}
SetTextA(hWnd, E_UDP, str);
FreeRpcPorts(&t3);
}
// Get the DDNS client state
Zero(&st, sizeof(st));
if (ScGetDDnsClientStatus(p->Rpc, &st) == ERR_NO_ERROR && IsEmptyStr(st.CurrentFqdn) == false)
@ -18664,6 +18677,45 @@ UINT SmServerDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, void *pa
}
break;
case B_APPLY:
{
// Apply UDP ports
bool ret;
LIST* ports;
RPC_PORTS t;
char tmp[MAX_SIZE];
GetTxtA(hWnd, E_UDP, tmp, sizeof(tmp));
ports = StrToPortList(tmp, false);
t.Num = LIST_NUM(ports);
if (t.Num > 0)
{
UINT i;
t.Ports = Malloc(sizeof(UINT) * t.Num);
for (i = 0; i < t.Num; ++i)
{
t.Ports[i] = (UINT)LIST_DATA(ports, i);
}
}
else
{
t.Ports = NULL;
}
ReleaseList(ports);
if (CALL(hWnd, ScSetPortsUDP(p->Rpc, &t)))
{
SmServerDlgRefresh(hWnd, p);
}
Free(t.Ports);
break;
}
case B_SSL:
// SSL related
SmSslDlg(hWnd, p);