1
0
mirror of https://github.com/SoftEtherVPN/SoftEtherVPN.git synced 2025-11-20 02:11:33 +03:00

Rewrite DNS API from scratch into dedicated file(s)

From a functional point of view, the main improvement is that GetIP() now always prioritizes IPv6 over IPv4.
The previous implementation always returned an IPv4 address, unless not available: in such case it failed.
This means that now connections to hostnames should be established via IPv6 if available.

From a programmer point of view, getting rid of the insane wrappers is enough to justify a complete rewrite.

As an extra, several unrelated unused global variables are removed.
This commit is contained in:
Davide Beatrici
2021-04-18 01:46:59 +02:00
parent f7e988ffc7
commit 0472f9c286
16 changed files with 702 additions and 1237 deletions

View File

@ -25,6 +25,7 @@
#include "WinUi.h"
#include "Mayaqua/Cfg.h"
#include "Mayaqua/DNS.h"
#include "Mayaqua/FileIO.h"
#include "Mayaqua/Internat.h"
#include "Mayaqua/Memory.h"
@ -312,8 +313,8 @@ UINT SiDebugProcGetCurrentGetIPThreadCount(SERVER *s, char *in_str, char *ret_st
return ERR_INVALID_PARAMETER;
}
ToStr3(tmp1, 0, GetCurrentGetIpThreadNum());
ToStr3(tmp2, 0, GetGetIpThreadMaxNum());
ToStr3(tmp1, 0, DnsThreadNum());
ToStr3(tmp2, 0, DnsThreadNumMax());
Format(ret_str, 0,
"Current threads = %s\n"
@ -5629,11 +5630,11 @@ void SiLoadServerCfg(SERVER *s, FOLDER *f)
i = CfgGetInt(f, "MaxConcurrentDnsClientThreads");
if (i != 0)
{
SetGetIpThreadMaxNum(i);
DnsThreadNumMaxSet(i);
}
else
{
SetGetIpThreadMaxNum(DEFAULT_GETIP_THREAD_MAX_NUM);
DnsThreadNumMaxSet(DNS_THREAD_DEFAULT_NUM_MAX);
}
s->DontBackupConfig = CfgGetBool(f, "DontBackupConfig");
@ -6103,7 +6104,7 @@ void SiWriteServerCfg(FOLDER *f, SERVER *s)
return;
}
CfgAddInt(f, "MaxConcurrentDnsClientThreads", GetGetIpThreadMaxNum());
CfgAddInt(f, "MaxConcurrentDnsClientThreads", DnsThreadNumMax());
CfgAddInt(f, "CurrentBuild", s->Cedar->Build);
@ -10766,7 +10767,7 @@ SERVER *SiNewServerEx(bool bridge, bool in_client_inner_server, bool relay_serve
LISTENER *azure;
LISTENER *rudp;
SetGetIpThreadMaxNum(DEFAULT_GETIP_THREAD_MAX_NUM);
DnsThreadNumMaxSet(DNS_THREAD_DEFAULT_NUM_MAX);
s = ZeroMalloc(sizeof(SERVER));