1
0
mirror of https://github.com/SoftEtherVPN/SoftEtherVPN.git synced 2024-11-26 11:29:53 +03:00

Cedar/Admin: use Proto in StGetOpenVpnSstpConfig() and StSetOpenVpnSstpConfig()

For now Server Manager still uses the two RPC methods.
This commit is contained in:
Davide Beatrici 2020-07-20 01:55:44 +02:00
parent b853140626
commit 18ad35ebfe

View File

@ -1989,42 +1989,96 @@ UINT StSetSpecialListener(ADMIN *a, RPC_SPECIAL_LISTENER *t)
// Set configurations for OpenVPN and SSTP // Set configurations for OpenVPN and SSTP
UINT StSetOpenVpnSstpConfig(ADMIN *a, OPENVPN_SSTP_CONFIG *t) UINT StSetOpenVpnSstpConfig(ADMIN *a, OPENVPN_SSTP_CONFIG *t)
{ {
SERVER *s = a->Server; PROTO *proto = a->Server->Proto;
CEDAR *c = s->Cedar; PROTO_CONTAINER *container, tmp_c;
PROTO_OPTION *option, tmp_o;
UINT ret = ERR_NO_ERROR; UINT ret = ERR_NO_ERROR;
bool changed = false;
SERVER_ADMIN_ONLY; SERVER_ADMIN_ONLY;
NO_SUPPORT_FOR_BRIDGE;
if (s->ServerType != SERVER_TYPE_STANDALONE) if (proto == NULL)
{ {
return ERR_NOT_SUPPORTED; return ERR_NOT_SUPPORTED;
} }
SiSetOpenVPNAndSSTPConfig(s, t); tmp_o.Name = PROTO_OPTION_TOGGLE_NAME;
tmp_c.Name = "OpenVPN";
container = Search(proto->Containers, &tmp_c);
if (container != NULL)
{
option = Search(container->Options, &tmp_o);
if (option != NULL)
{
if (option->Type == PROTO_OPTION_BOOL)
{
option->Bool = t->EnableOpenVPN;
changed = true;
}
else
{
ret = ERR_INVALID_PARAMETER;
}
}
else
{
ret = ERR_OBJECT_NOT_FOUND;
}
}
else
{
ret = ERR_OBJECT_NOT_FOUND;
}
tmp_c.Name = "SSTP";
container = Search(proto->Containers, &tmp_c);
if (container != NULL)
{
option = Search(container->Options, &tmp_o);
if (option != NULL)
{
if (option->Type == PROTO_OPTION_BOOL)
{
option->Bool = t->EnableSSTP;
changed = true;
}
else
{
ret = ERR_INVALID_PARAMETER;
}
}
else
{
ret = ERR_OBJECT_NOT_FOUND;
}
}
else
{
ret = ERR_OBJECT_NOT_FOUND;
}
if (changed)
{
ALog(a, NULL, "LA_SET_OVPN_SSTP_CONFIG"); ALog(a, NULL, "LA_SET_OVPN_SSTP_CONFIG");
IncrementServerConfigRevision(a->Server);
}
IncrementServerConfigRevision(s); return ret;
return ERR_NO_ERROR;
} }
// Get configurations for OpenVPN and SSTP // Get configurations for OpenVPN and SSTP
UINT StGetOpenVpnSstpConfig(ADMIN *a, OPENVPN_SSTP_CONFIG *t) UINT StGetOpenVpnSstpConfig(ADMIN *a, OPENVPN_SSTP_CONFIG *t)
{ {
SERVER *s = a->Server; PROTO *proto = a->Server->Proto;
CEDAR *c = s->Cedar; if (proto == NULL)
UINT ret = ERR_NO_ERROR;
SERVER_ADMIN_ONLY;
NO_SUPPORT_FOR_BRIDGE;
if (s->ServerType != SERVER_TYPE_STANDALONE)
{ {
return ERR_NOT_SUPPORTED; return ERR_NOT_SUPPORTED;
} }
Zero(t, sizeof(OPENVPN_SSTP_CONFIG)); t->EnableOpenVPN = ProtoEnabled(proto, "OpenVPN");
SiGetOpenVPNAndSSTPConfig(s, t); t->EnableSSTP = ProtoEnabled(proto, "SSTP");
return ERR_NO_ERROR; return ERR_NO_ERROR;
} }