Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/SoftEtherVPN/SoftEtherVPN_Stable.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordnobori <da.git@softether.co.jp>2014-04-09 04:35:00 +0400
committerdnobori <da.git@softether.co.jp>2014-04-09 04:35:00 +0400
commita3a4ad0b0aab8f457722a4283819351ad271742f (patch)
treeb27a49fb8883b0357b1081073f67a5397923df3f /src/Mayaqua
parenta22f8216ae5158c722560dee468960b58467b3e3 (diff)
v4.06-9436-beta
Diffstat (limited to 'src/Mayaqua')
-rw-r--r--src/Mayaqua/Network.c49
-rw-r--r--src/Mayaqua/Network.h6
2 files changed, 45 insertions, 10 deletions
diff --git a/src/Mayaqua/Network.c b/src/Mayaqua/Network.c
index 820cfb7f..8d6ee47b 100644
--- a/src/Mayaqua/Network.c
+++ b/src/Mayaqua/Network.c
@@ -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;
+ }
+
+ // Change the host name
+ Debug("CurrentRegisterHostname Changed: New=%s\n", new_hostname);
+ StrCpy(r->CurrentRegisterHostname, sizeof(r->CurrentRegisterHostname), new_hostname);
- Set(r->HaltEvent);
+ 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,14 +4967,15 @@ LABEL_TIMEOUT:
sock, sock_event, 0, false);
}
- if (sock_event != NULL)
+ if (sock != NULL)
{
- ReleaseSockEvent(sock_event);
+ Disconnect(sock);
+ ReleaseSock(sock);
}
- if (sock != NULL)
+ if (sock_event != NULL)
{
- ReleaseSock(sock);
+ ReleaseSockEvent(sock_event);
}
return ret;
diff --git a/src/Mayaqua/Network.h b/src/Mayaqua/Network.h
index f062fb98..057af6ea 100644
--- a/src/Mayaqua/Network.h
+++ b/src/Mayaqua/Network.h
@@ -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