OCT 1. 移除UDP代理服务调试信息以及sleep,加快网络转发数据包效率
This commit is contained in:
parent
0cdad9225a
commit
c2b96cc333
|
@ -5,6 +5,8 @@
|
|||
#include "usrerr.h"
|
||||
#include "misc.h"
|
||||
|
||||
#define DEBUG_PROXY_PACKAGE (0)
|
||||
|
||||
#if !USED_PORTMAP_TUNNEL
|
||||
#include "globalcfg.h"
|
||||
#include <winsock2.h>
|
||||
|
@ -16,7 +18,6 @@
|
|||
|
||||
#endif
|
||||
|
||||
|
||||
void StopUDPProxyServer() {
|
||||
#if !USED_PORTMAP_TUNNEL
|
||||
const PSCG_PROXY_INFO pProxy = &GetGlobalCfgInfo()->scgProxy;
|
||||
|
@ -47,8 +48,9 @@ static DWORD UDPProxvRemoteThread(LPVOID lpParameter) {
|
|||
|
||||
while (pPeerSock && !pProxy->exitNow) {
|
||||
sockaddr_in remoteWgAddr {};
|
||||
#if DEBUG_PROXY_PACKAGE
|
||||
TCHAR ipAddr[MAX_IP_LEN];
|
||||
|
||||
#endif
|
||||
int addrSize = sizeof(SOCKADDR);
|
||||
char recvBuf[1500];
|
||||
int iRecvBytes;
|
||||
|
@ -60,15 +62,16 @@ static DWORD UDPProxvRemoteThread(LPVOID lpParameter) {
|
|||
0,
|
||||
reinterpret_cast<SOCKADDR *>(&remoteWgAddr),
|
||||
&addrSize);
|
||||
|
||||
#if DEBUG_PROXY_PACKAGE
|
||||
memset(ipAddr, 0, MAX_IP_LEN);
|
||||
InetNtop(AF_INET, &remoteWgAddr.sin_addr.s_addr, ipAddr, MAX_IP_LEN);
|
||||
|
||||
SPDLOG_TRACE(TEXT(">>> Scoket In {1} Recv {0} bytes from {2}:{3}"),
|
||||
iRecvBytes,
|
||||
pProxy->scgGwSock,
|
||||
ipAddr,
|
||||
ntohs(remoteWgAddr.sin_port));
|
||||
|
||||
#endif
|
||||
if (iRecvBytes != SOCKET_ERROR) {
|
||||
int sendBytes = sendto(pProxy->udpProxySock,
|
||||
recvBuf,
|
||||
|
@ -76,6 +79,8 @@ static DWORD UDPProxvRemoteThread(LPVOID lpParameter) {
|
|||
0,
|
||||
reinterpret_cast<SOCKADDR *>(pPeerSock),
|
||||
sizeof(SOCKADDR));
|
||||
|
||||
#if DEBUG_PROXY_PACKAGE
|
||||
memset(ipAddr, 0, MAX_IP_LEN);
|
||||
InetNtop(AF_INET, &pPeerSock->sin_addr.s_addr, ipAddr, MAX_IP_LEN);
|
||||
SPDLOG_TRACE(TEXT("<<< Scoket In Send {0} bytes to {2}:{3}"),
|
||||
|
@ -91,8 +96,10 @@ static DWORD UDPProxvRemoteThread(LPVOID lpParameter) {
|
|||
ntohs(remoteWgAddr.sin_port),
|
||||
WSAGetLastError());
|
||||
}
|
||||
|
||||
Sleep(100);
|
||||
#else
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -102,7 +109,9 @@ static DWORD UDPProxyRecvThread(LPVOID lpParameter) {
|
|||
sockaddr_in localWgAddr {};
|
||||
sockaddr_in scgAddr {};
|
||||
unsigned char recvBuf[1500 + SCG_UDP_HEAD_SIZE];
|
||||
#if DEBUG_PROXY_PACKAGE
|
||||
std::array<UINT8, 1511> arr;
|
||||
#endif
|
||||
const PSCG_PROXY_INFO pProxy = &GetGlobalCfgInfo()->scgProxy;
|
||||
const auto svrId = static_cast<UINT8>(GetGlobalCfgInfo()->userCfg.cliConfig.scgTunnelAppId);
|
||||
char *pRecBuf = reinterpret_cast<char *>(&recvBuf[SCG_UDP_HEAD_SIZE]);
|
||||
|
@ -126,7 +135,9 @@ static DWORD UDPProxyRecvThread(LPVOID lpParameter) {
|
|||
|
||||
pProxy->exitNow = false;
|
||||
while (!pProxy->exitNow) {
|
||||
#if DEBUG_PROXY_PACKAGE
|
||||
TCHAR ipAddr[MAX_IP_LEN];
|
||||
#endif
|
||||
int addrSize = sizeof(SOCKADDR);
|
||||
int iRecvBytes;
|
||||
|
||||
|
@ -138,12 +149,16 @@ static DWORD UDPProxyRecvThread(LPVOID lpParameter) {
|
|||
reinterpret_cast<SOCKADDR *>(&localWgAddr),
|
||||
&addrSize);
|
||||
|
||||
#if DEBUG_PROXY_PACKAGE
|
||||
InetNtop(AF_INET, &localWgAddr.sin_addr.s_addr, ipAddr, MAX_IP_LEN);
|
||||
|
||||
SPDLOG_TRACE(TEXT(">>> Scoket Out {1} Recv {0} bytes from {2}:{3}"),
|
||||
iRecvBytes,
|
||||
pProxy->udpProxySock,
|
||||
ipAddr,
|
||||
ntohs(localWgAddr.sin_port));
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
if (iRecvBytes >= (1450 - SCG_UDP_HEAD_SIZE)) {
|
||||
SPDLOG_WARN(TEXT("!Maybe MTU overflow: Current package {0} bytes, UDP MTU 1450, SCG Head Used {1} bytes"),
|
||||
|
@ -186,7 +201,7 @@ static DWORD UDPProxyRecvThread(LPVOID lpParameter) {
|
|||
|
||||
// 增加SCG包头数据长度
|
||||
iRecvBytes += 11;
|
||||
|
||||
#if DEBUG_PROXY_PACKAGE
|
||||
if (GetGlobalCfgInfo()->logLevel == spdlog::level::trace) {
|
||||
const auto start = std::begin(recvBuf);
|
||||
std::copy_n(start, iRecvBytes, std::begin(arr));
|
||||
|
@ -195,23 +210,26 @@ static DWORD UDPProxyRecvThread(LPVOID lpParameter) {
|
|||
svrId,
|
||||
id);
|
||||
}
|
||||
|
||||
#endif
|
||||
sendBytes = sendto(pProxy->scgGwSock,
|
||||
reinterpret_cast<char *>(recvBuf),
|
||||
iRecvBytes,
|
||||
0,
|
||||
reinterpret_cast<SOCKADDR *>(&scgAddr),
|
||||
sizeof(SOCKADDR));
|
||||
#if DEBUG_PROXY_PACKAGE
|
||||
memset(ipAddr, 0, MAX_IP_LEN);
|
||||
InetNtop(AF_INET, &scgAddr.sin_addr.s_addr, ipAddr, MAX_IP_LEN);
|
||||
|
||||
SPDLOG_TRACE(TEXT("<<< Scoket Out Send {0} bytes to {2}:{3}"),
|
||||
sendBytes,
|
||||
pProxy->scgGwSock,
|
||||
ipAddr,
|
||||
ntohs(scgAddr.sin_port));
|
||||
#endif
|
||||
}
|
||||
|
||||
Sleep(100);
|
||||
//Sleep(100);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1103,7 +1103,6 @@ int RemoveAllIntelnetConnectSharing() {
|
|||
SPDLOG_DEBUG(TEXT("Remove {0}-{1} ICS"), ifIndex, pAdapter->AdapterName);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
SPDLOG_ERROR(TEXT("Get {0}-{1} ICS status error: {2}"), ifIndex, pAdapter->AdapterName, ret);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue