mirror of
https://github.com/SoftEtherVPN/SoftEtherVPN.git
synced 2025-07-06 07:44:57 +03:00
v4.06-9436-beta
This commit is contained in:
@ -1476,14 +1476,42 @@ void RUDPProcess_NatT_Recv(RUDP_STACK *r, UDPPACKET *udp)
|
||||
{
|
||||
if (StrCmpi(r->CurrentRegisterHostname, new_hostname) != 0)
|
||||
{
|
||||
// Change the host name
|
||||
Debug("CurrentRegisterHostname Changed: New=%s\n", new_hostname);
|
||||
StrCpy(r->CurrentRegisterHostname, sizeof(r->CurrentRegisterHostname), new_hostname);
|
||||
r->NumChangedHostname++;
|
||||
|
||||
Zero(&r->NatT_IP, sizeof(r->NatT_IP));
|
||||
//Zero(&r->NatT_IP_Safe, sizeof(r->NatT_IP_Safe));
|
||||
if (r->NumChangedHostname <= RUDP_NATT_MAX_CONT_CHANGE_HOSTNAME)
|
||||
{
|
||||
if (r->NumChangedHostnameValueResetTick == 0)
|
||||
{
|
||||
r->NumChangedHostnameValueResetTick = r->Now + (UINT64)RUDP_NATT_CONT_CHANGE_HOSTNAME_RESET_INTERVAL;
|
||||
}
|
||||
|
||||
Set(r->HaltEvent);
|
||||
// Change the host name
|
||||
Debug("CurrentRegisterHostname Changed: New=%s\n", new_hostname);
|
||||
StrCpy(r->CurrentRegisterHostname, sizeof(r->CurrentRegisterHostname), new_hostname);
|
||||
|
||||
Zero(&r->NatT_IP, sizeof(r->NatT_IP));
|
||||
//Zero(&r->NatT_IP_Safe, sizeof(r->NatT_IP_Safe));
|
||||
|
||||
Set(r->HaltEvent);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (r->NumChangedHostnameValueResetTick == 0)
|
||||
{
|
||||
r->NumChangedHostnameValueResetTick = r->Now + (UINT64)RUDP_NATT_CONT_CHANGE_HOSTNAME_RESET_INTERVAL;
|
||||
}
|
||||
|
||||
if (r->Now >= r->NumChangedHostnameValueResetTick)
|
||||
{
|
||||
r->NumChangedHostname = 0;
|
||||
r->NumChangedHostnameValueResetTick = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
r->NumChangedHostname = 0;
|
||||
r->NumChangedHostnameValueResetTick = 0;
|
||||
}
|
||||
}
|
||||
Unlock(r->Lock);
|
||||
@ -4939,16 +4967,17 @@ LABEL_TIMEOUT:
|
||||
sock, sock_event, 0, false);
|
||||
}
|
||||
|
||||
if (sock != NULL)
|
||||
{
|
||||
Disconnect(sock);
|
||||
ReleaseSock(sock);
|
||||
}
|
||||
|
||||
if (sock_event != NULL)
|
||||
{
|
||||
ReleaseSockEvent(sock_event);
|
||||
}
|
||||
|
||||
if (sock != NULL)
|
||||
{
|
||||
ReleaseSock(sock);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
@ -773,6 +773,10 @@ typedef bool (RUDP_STACK_RPC_RECV_PROC)(RUDP_STACK *r, UDPPACKET *p);
|
||||
#define RUDP_PROTOCOL_ICMP 1 // ICMP
|
||||
#define RUDP_PROTOCOL_DNS 2 // DNS
|
||||
|
||||
// Maximum time of continously changing of the NAT-T hostname
|
||||
#define RUDP_NATT_MAX_CONT_CHANGE_HOSTNAME 30
|
||||
#define RUDP_NATT_CONT_CHANGE_HOSTNAME_RESET_INTERVAL (5 * 60 * 1000)
|
||||
|
||||
// Minimum time to wait for a trial to connect by ICMP and DNS in case failing to connect by TCP
|
||||
#define SOCK_CONNECT_WAIT_FOR_ICMP_AND_DNS_AT_LEAST 5000
|
||||
|
||||
@ -806,6 +810,8 @@ struct RUDP_STACK
|
||||
UINT64 TotalPhysicalSent; // Physical amount of data transmitted
|
||||
UINT64 TotalLogicalSent; // Logical amount of data transmitted
|
||||
char CurrentRegisterHostname[MAX_SIZE]; // The host name of the the current destination of registration
|
||||
UINT NumChangedHostname; // How number of changing NAT-T hostname has occured continously
|
||||
UINT64 NumChangedHostnameValueResetTick;
|
||||
|
||||
// NAT-T server related
|
||||
bool NoNatTRegister; // Flag not to register with the NAT-T server
|
||||
|
Reference in New Issue
Block a user