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

Implementation of the JSON-RPC API and the Web Admin interface. (dnobori's internal note: 7579 - 7682)

This commit is contained in:
Daiyuu Nobori
2019-05-28 12:51:51 +09:00
parent 03841e4181
commit 98b08c2ad1
35 changed files with 5991 additions and 231 deletions

View File

@ -7229,6 +7229,12 @@ bool IsIP4(IP *ip)
return (IsIP6(ip) ? false : true);
}
// Copy the IP address
void CopyIP(IP *dst, IP *src)
{
Copy(dst, src, sizeof(IP));
}
// Get the number of clients connected from the specified IP address
UINT GetNumIpClient(IP *ip)
{
@ -11368,6 +11374,50 @@ void InitSockSet(SOCKSET *set)
Zero(set, sizeof(SOCKSET));
}
// Receive data and discard all of them
bool RecvAllWithDiscard(SOCK *sock, UINT size, bool secure)
{
static UCHAR buffer[4096];
UINT recv_size, sz, ret;
if (sock == NULL)
{
return false;
}
if (size == 0)
{
return true;
}
if (sock->AsyncMode)
{
return false;
}
recv_size = 0;
while (true)
{
sz = MIN(size - recv_size, sizeof(buffer));
ret = Recv(sock, buffer, sz, secure);
if (ret == 0)
{
return false;
}
if (ret == SOCK_LATER)
{
// I suppose that this is safe because the RecvAll() function is used only
// if the sock->AsyncMode == true. And the Recv() function may return
// SOCK_LATER only if the sock->AsyncMode == false. Therefore the call of
// Recv() function in the RecvAll() function never returns SOCK_LATER.
return false;
}
recv_size += ret;
if (recv_size >= size)
{
return true;
}
}
}
// Receive all by TCP
bool RecvAll(SOCK *sock, void *data, UINT size, bool secure)
{