mirror of
https://github.com/SoftEtherVPN/SoftEtherVPN.git
synced 2025-07-07 00:04:57 +03:00
Added the function to save the DNS query log on the packet logs.
This commit is contained in:
@ -6955,104 +6955,6 @@ NAT_ENTRY *CreateNatDns(VH *v, UINT src_ip, UINT src_port, UINT dest_ip, UINT de
|
||||
return n;
|
||||
}
|
||||
|
||||
// Get the next byte
|
||||
UCHAR GetNextByte(BUF *b)
|
||||
{
|
||||
UCHAR c = 0;
|
||||
// Validate arguments
|
||||
if (b == NULL)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ReadBuf(b, &c, 1) != 1)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
// Interpret the DNS query
|
||||
bool ParseDnsQuery(char *name, UINT name_size, void *data, UINT data_size)
|
||||
{
|
||||
BUF *b;
|
||||
char tmp[257];
|
||||
bool ok = true;
|
||||
USHORT val;
|
||||
// Validate arguments
|
||||
if (name == NULL || data == NULL || data_size == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
StrCpy(name, name_size, "");
|
||||
|
||||
b = NewBuf();
|
||||
WriteBuf(b, data, data_size);
|
||||
SeekBuf(b, 0, 0);
|
||||
|
||||
while (true)
|
||||
{
|
||||
UINT next_len = (UINT)GetNextByte(b);
|
||||
if (next_len > 0)
|
||||
{
|
||||
// Read only the specified length
|
||||
Zero(tmp, sizeof(tmp));
|
||||
if (ReadBuf(b, tmp, next_len) != next_len)
|
||||
{
|
||||
ok = false;
|
||||
break;
|
||||
}
|
||||
// Append
|
||||
if (StrLen(name) != 0)
|
||||
{
|
||||
StrCat(name, name_size, ".");
|
||||
}
|
||||
StrCat(name, name_size, tmp);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Read all
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (ReadBuf(b, &val, sizeof(val)) != sizeof(val))
|
||||
{
|
||||
ok = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Endian16(val) != 0x01 && Endian16(val) != 0x0c)
|
||||
{
|
||||
ok = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (ReadBuf(b, &val, sizeof(val)) != sizeof(val))
|
||||
{
|
||||
ok = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Endian16(val) != 0x01)
|
||||
{
|
||||
ok = false;
|
||||
}
|
||||
}
|
||||
|
||||
FreeBuf(b);
|
||||
|
||||
if (ok == false || StrLen(name) == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Set the VGS host name
|
||||
void SetDnsProxyVgsHostname(char *hostname)
|
||||
{
|
||||
|
Reference in New Issue
Block a user