mirror of
https://github.com/SoftEtherVPN/SoftEtherVPN.git
synced 2025-07-14 19:54:57 +03:00
Improve NAT-T hint string handling
This commit is contained in:
@ -4315,6 +4315,13 @@ void InRpcClientOption(CLIENT_OPTION *c, PACK *p)
|
||||
|
||||
PackGetUniStr(p, "AccountName", c->AccountName, sizeof(c->AccountName));
|
||||
PackGetStr(p, "Hostname", c->Hostname, sizeof(c->Hostname));
|
||||
// Extract hint string from hostname
|
||||
UINT i = SearchStrEx(c->Hostname, "/", 0, false);
|
||||
if (i != INFINITE)
|
||||
{
|
||||
StrCpy(c->HintStr, sizeof(c->HintStr), c->Hostname + i + 1);
|
||||
c->Hostname[i] = 0;
|
||||
}
|
||||
c->Port = PackGetInt(p, "Port");
|
||||
c->PortUDP = PackGetInt(p, "PortUDP");
|
||||
c->ProxyType = PackGetInt(p, "ProxyType");
|
||||
@ -4352,7 +4359,20 @@ void OutRpcClientOption(PACK *p, CLIENT_OPTION *c)
|
||||
}
|
||||
|
||||
PackAddUniStr(p, "AccountName", c->AccountName);
|
||||
PackAddStr(p, "Hostname", c->Hostname);
|
||||
// Append hint string to hostname
|
||||
if (IsEmptyStr(c->HintStr))
|
||||
{
|
||||
// No hint
|
||||
PackAddStr(p, "Hostname", c->Hostname);
|
||||
}
|
||||
else
|
||||
{
|
||||
char hostname[MAX_SIZE];
|
||||
StrCpy(hostname, sizeof(hostname), c->Hostname);
|
||||
StrCat(hostname, sizeof(hostname), "/");
|
||||
StrCat(hostname, sizeof(hostname), c->HintStr);
|
||||
PackAddStr(p, "Hostname", hostname);
|
||||
}
|
||||
PackAddStr(p, "ProxyName", c->ProxyName);
|
||||
PackAddStr(p, "ProxyUsername", c->ProxyUsername);
|
||||
PackAddStr(p, "ProxyPassword", c->ProxyPassword);
|
||||
@ -7030,6 +7050,12 @@ bool CtEnumAccount(CLIENT *c, RPC_CLIENT_ENUM_ACCOUNT *e)
|
||||
|
||||
// Server name
|
||||
StrCpy(item->ServerName, sizeof(item->ServerName), a->ClientOption->Hostname);
|
||||
// Append hint string to hostname
|
||||
if (IsEmptyStr(a->ClientOption->HintStr) == false)
|
||||
{
|
||||
StrCat(item->ServerName, sizeof(item->ServerName), "/");
|
||||
StrCat(item->ServerName, sizeof(item->ServerName), a->ClientOption->HintStr);
|
||||
}
|
||||
|
||||
// Proxy type
|
||||
item->ProxyType = a->ClientOption->ProxyType;
|
||||
@ -9222,6 +9248,13 @@ CLIENT_OPTION *CiLoadClientOption(FOLDER *f)
|
||||
|
||||
CfgGetUniStr(f, "AccountName", o->AccountName, sizeof(o->AccountName));
|
||||
CfgGetStr(f, "Hostname", o->Hostname, sizeof(o->Hostname));
|
||||
// Extract hint string from hostname
|
||||
UINT i = SearchStrEx(o->Hostname, "/", 0, false);
|
||||
if (i != INFINITE)
|
||||
{
|
||||
StrCpy(o->HintStr, sizeof(o->HintStr), o->Hostname + i + 1);
|
||||
o->Hostname[i] = 0;
|
||||
}
|
||||
o->Port = CfgGetInt(f, "Port");
|
||||
o->PortUDP = CfgGetInt(f, "PortUDP");
|
||||
o->ProxyType = CfgGetInt(f, "ProxyType");
|
||||
@ -9764,7 +9797,20 @@ void CiWriteClientOption(FOLDER *f, CLIENT_OPTION *o)
|
||||
}
|
||||
|
||||
CfgAddUniStr(f, "AccountName", o->AccountName);
|
||||
CfgAddStr(f, "Hostname", o->Hostname);
|
||||
// Append hint string to hostname
|
||||
if (IsEmptyStr(o->HintStr))
|
||||
{
|
||||
// No hint
|
||||
CfgAddStr(f, "Hostname", o->Hostname);
|
||||
}
|
||||
else
|
||||
{
|
||||
char hostname[MAX_SIZE];
|
||||
StrCpy(hostname, sizeof(hostname), o->Hostname);
|
||||
StrCat(hostname, sizeof(hostname), "/");
|
||||
StrCat(hostname, sizeof(hostname), o->HintStr);
|
||||
CfgAddStr(f, "Hostname", hostname);
|
||||
}
|
||||
CfgAddInt(f, "Port", o->Port);
|
||||
CfgAddInt(f, "PortUDP", o->PortUDP);
|
||||
CfgAddInt(f, "ProxyType", o->ProxyType);
|
||||
|
Reference in New Issue
Block a user