mirror of
https://github.com/SoftEtherVPN/SoftEtherVPN.git
synced 2024-11-22 09:29:52 +03:00
Cedar/Admin: implement new RPC methods to get/set the UDP ports
This commit is contained in:
parent
c4ec63fe32
commit
f1cb86d979
@ -1494,6 +1494,8 @@ PACK *AdminDispatch(RPC *rpc, char *name, PACK *p)
|
||||
DECLARE_RPC_EX("EnumListener", RPC_LISTENER_LIST, StEnumListener, InRpcListenerList, OutRpcListenerList, FreeRpcListenerList)
|
||||
DECLARE_RPC("DeleteListener", RPC_LISTENER, StDeleteListener, InRpcListener, OutRpcListener)
|
||||
DECLARE_RPC("EnableListener", RPC_LISTENER, StEnableListener, InRpcListener, OutRpcListener)
|
||||
DECLARE_RPC_EX("SetPortsUDP", RPC_PORTS, StSetPortsUDP, InRpcPorts, OutRpcPorts, FreeRpcPorts)
|
||||
DECLARE_RPC_EX("GetPortsUDP", RPC_PORTS, StGetPortsUDP, InRpcPorts, OutRpcPorts, FreeRpcPorts)
|
||||
DECLARE_RPC("SetServerPassword", RPC_SET_PASSWORD, StSetServerPassword, InRpcSetPassword, OutRpcSetPassword)
|
||||
DECLARE_RPC_EX("SetFarmSetting", RPC_FARM, StSetFarmSetting, InRpcFarm, OutRpcFarm, FreeRpcFarm)
|
||||
DECLARE_RPC_EX("GetFarmSetting", RPC_FARM, StGetFarmSetting, InRpcFarm, OutRpcFarm, FreeRpcFarm)
|
||||
@ -1674,6 +1676,8 @@ DECLARE_SC("CreateListener", RPC_LISTENER, ScCreateListener, InRpcListener, OutR
|
||||
DECLARE_SC_EX("EnumListener", RPC_LISTENER_LIST, ScEnumListener, InRpcListenerList, OutRpcListenerList, FreeRpcListenerList)
|
||||
DECLARE_SC("DeleteListener", RPC_LISTENER, ScDeleteListener, InRpcListener, OutRpcListener)
|
||||
DECLARE_SC("EnableListener", RPC_LISTENER, ScEnableListener, InRpcListener, OutRpcListener)
|
||||
DECLARE_SC_EX("SetPortsUDP", RPC_PORTS, ScSetPortsUDP, InRpcPorts, OutRpcPorts, FreeRpcPorts)
|
||||
DECLARE_SC_EX("GetPortsUDP", RPC_PORTS, ScGetPortsUDP, InRpcPorts, OutRpcPorts, FreeRpcPorts)
|
||||
DECLARE_SC("SetServerPassword", RPC_SET_PASSWORD, ScSetServerPassword, InRpcSetPassword, OutRpcSetPassword)
|
||||
DECLARE_SC_EX("SetFarmSetting", RPC_FARM, ScSetFarmSetting, InRpcFarm, OutRpcFarm, FreeRpcFarm)
|
||||
DECLARE_SC_EX("GetFarmSetting", RPC_FARM, ScGetFarmSetting, InRpcFarm, OutRpcFarm, FreeRpcFarm)
|
||||
@ -9873,6 +9877,88 @@ UINT StCreateListener(ADMIN *a, RPC_LISTENER *t)
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Set UDP ports the server should listen on
|
||||
UINT StSetPortsUDP(ADMIN *a, RPC_PORTS *t)
|
||||
{
|
||||
UINT i;
|
||||
LIST *ports, *server_ports;
|
||||
|
||||
SERVER_ADMIN_ONLY;
|
||||
|
||||
ports = NewIntList(true);
|
||||
|
||||
for (i = 0; i < t->Num; ++i)
|
||||
{
|
||||
const UINT port = t->Ports[i];
|
||||
if (port < 1 || port > 65535)
|
||||
{
|
||||
ReleaseIntList(ports);
|
||||
return ERR_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
AddIntDistinct(ports, port);
|
||||
}
|
||||
|
||||
server_ports = a->Server->PortsUDP;
|
||||
|
||||
LockList(server_ports);
|
||||
{
|
||||
char tmp[MAX_SIZE];
|
||||
wchar_t str[MAX_SIZE];
|
||||
|
||||
for (i = 0; i < LIST_NUM(server_ports); ++i)
|
||||
{
|
||||
Free(LIST_DATA(server_ports, i));
|
||||
}
|
||||
DeleteAll(server_ports);
|
||||
|
||||
for (i = 0; i < LIST_NUM(ports); ++i)
|
||||
{
|
||||
const UINT port = *(UINT *)LIST_DATA(ports, i);
|
||||
AddInt(server_ports, port);
|
||||
}
|
||||
|
||||
ProtoSetUdpPorts(a->Server->Proto, server_ports);
|
||||
|
||||
IntListToStr(tmp, sizeof(tmp), server_ports, ", ");
|
||||
StrToUni(str, sizeof(str), tmp);
|
||||
ALog(a, NULL, "LA_SET_PORTS_UDP", str);
|
||||
}
|
||||
UnlockList(server_ports);
|
||||
|
||||
ReleaseIntList(ports);
|
||||
|
||||
IncrementServerConfigRevision(a->Server);
|
||||
|
||||
return ERR_NO_ERROR;
|
||||
}
|
||||
|
||||
// List UDP ports the server is listening on
|
||||
UINT StGetPortsUDP(ADMIN *a, RPC_PORTS *t)
|
||||
{
|
||||
LIST *ports = a->Server->PortsUDP;
|
||||
|
||||
FreeRpcPorts(t);
|
||||
|
||||
LockList(ports);
|
||||
{
|
||||
t->Num = LIST_NUM(ports);
|
||||
t->Ports = t->Num > 0 ? Malloc(sizeof(UINT) * t->Num) : NULL;
|
||||
if (t->Ports != NULL)
|
||||
{
|
||||
UINT i;
|
||||
for (i = 0; i < t->Num; ++i)
|
||||
{
|
||||
const UINT port = *(UINT *)LIST_DATA(ports, i);
|
||||
t->Ports[i] = port;
|
||||
}
|
||||
}
|
||||
}
|
||||
UnlockList(ports);
|
||||
|
||||
return ERR_NO_ERROR;
|
||||
}
|
||||
|
||||
// Get server status
|
||||
UINT StGetServerStatus(ADMIN *a, RPC_SERVER_STATUS *t)
|
||||
{
|
||||
@ -12094,6 +12180,49 @@ void FreeRpcListenerList(RPC_LISTENER_LIST *t)
|
||||
Free(t->Errors);
|
||||
}
|
||||
|
||||
// RPC_PORTS
|
||||
void InRpcPorts(RPC_PORTS *t, PACK *p)
|
||||
{
|
||||
UINT i;
|
||||
// Validate arguments
|
||||
if (t == NULL || p == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
t->Num = PackGetIndexCount(p, "Ports");
|
||||
t->Ports = ZeroMalloc(sizeof(UINT) * t->Num);
|
||||
|
||||
for (i = 0; i < t->Num; ++i)
|
||||
{
|
||||
t->Ports[i] = PackGetIntEx(p, "Ports", i);
|
||||
}
|
||||
}
|
||||
void OutRpcPorts(PACK *p, RPC_PORTS *t)
|
||||
{
|
||||
UINT i;
|
||||
// Validate arguments
|
||||
if (t == NULL || p == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < t->Num; ++i)
|
||||
{
|
||||
PackAddIntEx(p, "Ports", t->Ports[i], i, t->Num);
|
||||
}
|
||||
}
|
||||
void FreeRpcPorts(RPC_PORTS *t)
|
||||
{
|
||||
// Validate arguments
|
||||
if (t == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Free(t->Ports);
|
||||
}
|
||||
|
||||
// RPC_STR
|
||||
void InRpcStr(RPC_STR *t, PACK *p)
|
||||
{
|
||||
|
@ -105,6 +105,13 @@ struct RPC_LISTENER_LIST
|
||||
bool *Errors; // An error occurred
|
||||
};
|
||||
|
||||
// List of ports
|
||||
struct RPC_PORTS
|
||||
{
|
||||
UINT Num; // Number of ports
|
||||
UINT *Ports; // Ports
|
||||
};
|
||||
|
||||
// String *
|
||||
struct RPC_STR
|
||||
{
|
||||
@ -957,6 +964,8 @@ UINT StCreateListener(ADMIN *a, RPC_LISTENER *t);
|
||||
UINT StEnumListener(ADMIN *a, RPC_LISTENER_LIST *t);
|
||||
UINT StDeleteListener(ADMIN *a, RPC_LISTENER *t);
|
||||
UINT StEnableListener(ADMIN *a, RPC_LISTENER *t);
|
||||
UINT StSetPortsUDP(ADMIN *a, RPC_PORTS *t);
|
||||
UINT StGetPortsUDP(ADMIN *a, RPC_PORTS *t);
|
||||
UINT StSetServerPassword(ADMIN *a, RPC_SET_PASSWORD *t);
|
||||
UINT StSetFarmSetting(ADMIN *a, RPC_FARM *t);
|
||||
UINT StGetFarmSetting(ADMIN *a, RPC_FARM *t);
|
||||
@ -1101,6 +1110,8 @@ UINT ScCreateListener(RPC *r, RPC_LISTENER *t);
|
||||
UINT ScEnumListener(RPC *r, RPC_LISTENER_LIST *t);
|
||||
UINT ScDeleteListener(RPC *r, RPC_LISTENER *t);
|
||||
UINT ScEnableListener(RPC *r, RPC_LISTENER *t);
|
||||
UINT ScSetPortsUDP(RPC *r, RPC_PORTS *t);
|
||||
UINT ScGetPortsUDP(RPC *r, RPC_PORTS *t);
|
||||
UINT ScSetServerPassword(RPC *r, RPC_SET_PASSWORD *t);
|
||||
UINT ScSetFarmSetting(RPC *r, RPC_FARM *t);
|
||||
UINT ScGetFarmSetting(RPC *r, RPC_FARM *t);
|
||||
@ -1251,6 +1262,9 @@ void OutRpcListener(PACK *p, RPC_LISTENER *t);
|
||||
void InRpcListenerList(RPC_LISTENER_LIST *t, PACK *p);
|
||||
void OutRpcListenerList(PACK *p, RPC_LISTENER_LIST *t);
|
||||
void FreeRpcListenerList(RPC_LISTENER_LIST *t);
|
||||
void InRpcPorts(RPC_PORTS *t, PACK *p);
|
||||
void OutRpcPorts(PACK *p, RPC_PORTS *t);
|
||||
void FreeRpcPorts(RPC_PORTS *t);
|
||||
void InRpcStr(RPC_STR *t, PACK *p);
|
||||
void OutRpcStr(PACK *p, RPC_STR *t);
|
||||
void FreeRpcStr(RPC_STR *t);
|
||||
|
@ -288,6 +288,7 @@ typedef struct RPC_SERVER_INFO RPC_SERVER_INFO;
|
||||
typedef struct RPC_SERVER_STATUS RPC_SERVER_STATUS;
|
||||
typedef struct RPC_LISTENER RPC_LISTENER;
|
||||
typedef struct RPC_LISTENER_LIST RPC_LISTENER_LIST;
|
||||
typedef struct RPC_PORTS RPC_PORTS;
|
||||
typedef struct RPC_STR RPC_STR;
|
||||
typedef struct RPC_SET_PASSWORD RPC_SET_PASSWORD;
|
||||
typedef struct RPC_FARM RPC_FARM;
|
||||
|
@ -2006,6 +2006,7 @@ LA_CREATE_LISTENER 已建立新 TCP 监听器 (端口号 %u)。
|
||||
LA_DELETE_LISTENER 已删除 TCP 监听器 (端口号 %u)。
|
||||
LA_ENABLE_LISTENER 已启用 TCP 监听器 (端口号 %u)。
|
||||
LA_DISABLE_LISTENER 已禁用 TCP 监听器 (端口号 %u)。
|
||||
LA_SET_PORTS_UDP UDP ports have been set: %s.
|
||||
LA_SET_SERVER_PASSWORD 服务端管理员密码设置完成。
|
||||
LA_SET_FARM_SETTING 群集设置变更完成。
|
||||
LA_SET_SERVER_CERT 服务端证书设定完成。
|
||||
|
@ -1988,6 +1988,7 @@ LA_CREATE_LISTENER A new TCP listener (port number %u) has been created.
|
||||
LA_DELETE_LISTENER TCP listener (port number %u) has been deleted.
|
||||
LA_ENABLE_LISTENER TCP listener (port number %u) has been enabled.
|
||||
LA_DISABLE_LISTENER TCP listener (port number %u) has been disabled.
|
||||
LA_SET_PORTS_UDP UDP ports have been set: %s.
|
||||
LA_SET_SERVER_PASSWORD The server administrator password has been set.
|
||||
LA_SET_FARM_SETTING The clustering setting has been changed.
|
||||
LA_SET_SERVER_CERT The server certificates have been set.
|
||||
|
@ -1992,6 +1992,7 @@ LA_CREATE_LISTENER 新しい TCP リスナー (ポート番号 %u) を作成し
|
||||
LA_DELETE_LISTENER TCP リスナー (ポート番号 %u) を削除しました。
|
||||
LA_ENABLE_LISTENER TCP リスナー (ポート番号 %u) を有効化しました。
|
||||
LA_DISABLE_LISTENER TCP リスナー (ポート番号 %u) を無効化しました。
|
||||
LA_SET_PORTS_UDP UDP ポートの一覧が設定されました: %s.
|
||||
LA_SET_SERVER_PASSWORD サーバー管理者パスワードを設定しました。
|
||||
LA_SET_FARM_SETTING クラスタリング設定を変更しました。
|
||||
LA_SET_SERVER_CERT サーバー証明書を設定しました。
|
||||
|
@ -1970,6 +1970,7 @@ LA_CREATE_LISTENER 새로운 TCP 리스너 (포트 번호 %u)를 만들었습니
|
||||
LA_DELETE_LISTENER TCP 리스너 (포트 번호 %u)을 삭제했습니다.
|
||||
LA_ENABLE_LISTENER TCP 리스너 (포트 번호 %u)를 활성화했습니다.
|
||||
LA_DISABLE_LISTENER TCP 리스너 (포트 번호 %u)를 비활성화했습니다.
|
||||
LA_SET_PORTS_UDP UDP ports have been set: %s.
|
||||
LA_SET_SERVER_PASSWORD 서버 관리자 암호를 설정했습니다.
|
||||
LA_SET_FARM_SETTING 클러스터링 설정을 변경했습니다.
|
||||
LA_SET_SERVER_CERT 서버 인증서를 설정했습니다.
|
||||
|
@ -1989,6 +1989,7 @@ LA_CREATE_LISTENER A new TCP listener (port number %u) has been created.
|
||||
LA_DELETE_LISTENER TCP listener (port number %u) has been deleted.
|
||||
LA_ENABLE_LISTENER TCP listener (port number %u) has been enabled.
|
||||
LA_DISABLE_LISTENER TCP listener (port number %u) has been disabled.
|
||||
LA_SET_PORTS_UDP UDP ports have been set: %s.
|
||||
LA_SET_SERVER_PASSWORD The server administrator password has been set.
|
||||
LA_SET_FARM_SETTING The clustering setting has been changed.
|
||||
LA_SET_SERVER_CERT The server certificates have been set.
|
||||
|
@ -1989,6 +1989,7 @@ LA_CREATE_LISTENER A new TCP listener (port number %u) has been created.
|
||||
LA_DELETE_LISTENER TCP listener (port number %u) has been deleted.
|
||||
LA_ENABLE_LISTENER TCP listener (port number %u) has been enabled.
|
||||
LA_DISABLE_LISTENER TCP listener (port number %u) has been disabled.
|
||||
LA_SET_PORTS_UDP UDP ports have been set: %s.
|
||||
LA_SET_SERVER_PASSWORD The server administrator password has been set.
|
||||
LA_SET_FARM_SETTING The clustering setting has been changed.
|
||||
LA_SET_SERVER_CERT The server certificates have been set.
|
||||
|
@ -2009,6 +2009,7 @@ LA_CREATE_LISTENER 已建立新 TCP 監聽器 (埠號 %u)。
|
||||
LA_DELETE_LISTENER 已刪除 TCP 監聽器 (埠號 %u)。
|
||||
LA_ENABLE_LISTENER 已啟用 TCP 監聽器 (埠號 %u)。
|
||||
LA_DISABLE_LISTENER 已禁用 TCP 監聽器 (埠號 %u)。
|
||||
LA_SET_PORTS_UDP UDP ports have been set: %s.
|
||||
LA_SET_SERVER_PASSWORD 服務端管理員密碼設置完成。
|
||||
LA_SET_FARM_SETTING 群集設置變更完成。
|
||||
LA_SET_SERVER_CERT 服務端證書設定完成。
|
||||
|
Loading…
Reference in New Issue
Block a user