1
0
mirror of https://github.com/SoftEtherVPN/SoftEtherVPN.git synced 2026-02-21 10:00:09 +03:00

Bind outgoing connection to a specific IP address No.2

This commit is contained in:
hiura
2023-08-08 18:14:22 +09:00
parent e4330ca71a
commit c2fe874865
14 changed files with 158 additions and 65 deletions

View File

@ -609,6 +609,24 @@ void SessionMain(SESSION *s)
WHERE;
}
}
// If all the specified number of tcp connections are not alive continuously, then terminate the session.
UINT num_tcp_conn = LIST_NUM(s->Connection->Tcp->TcpSockList);
UINT max_conn = s->ClientOption->MaxConnection;
if ((s->CurrentConnectionEstablishTime +
(UINT64)(s->ClientOption->AdditionalConnectionInterval * 1000 * 2 + CONNECTING_TIMEOUT * 2))
<= Tick64())
{
if (s->ClientOption->BindLocalPort != 0 || num_tcp_conn == 0)
{
timeouted = true;
WHERE;
}
}
//Debug("SessionMain(): The number of TCP connections short... Num_Tcp_Conn=%d Max_Conn=%d Curr_Conn_Time=%llu Tick64=%llu\n"
// , num_tcp_conn, max_conn, s->CurrentConnectionEstablishTime, Tick64());
}
}
@ -1430,7 +1448,7 @@ void ClientThread(THREAD *t, void *param)
while (true)
{
Zero(&s->ServerIP_CacheForNextConnect, sizeof(IP));
Zero(&s->LocalIP_CacheForNextConnect, sizeof(IP));
Zero(&s->LocalIP_CacheForNextConnect, sizeof(IP)); // Assigned by first outgoing connection
Zero(s->UnderlayProtocol, sizeof(s->UnderlayProtocol));
Zero(s->ProtocolDetails, sizeof(s->ProtocolDetails));