diff --git a/NetTunnelSDK/UserManager.cpp b/NetTunnelSDK/UserManager.cpp index d15c398..ecda78c 100644 --- a/NetTunnelSDK/UserManager.cpp +++ b/NetTunnelSDK/UserManager.cpp @@ -597,8 +597,13 @@ int GetUserClientConfigure(const TCHAR *pUserName, const TCHAR *pToken, PUSER_CL StringCbCopy(pVm->vmNetwork, MAX_IP_LEN, vm.vmNetwork.c_str()); //StringCbCopy(pVm->scgGateWay, MAX_PATH, vm.scgGateway.c_str()); StringCbPrintf(pVm->scgGateWay, MAX_PATH, TEXT("http://%s:%d"), vm.scgIp.c_str(), vm.scgPort); - httplib::Client cli(pVm->scgGateWay); - StringCbPrintf(pVm->scgTunnelGw, MAX_PATH, TEXT("%s:%d"), cli.host().c_str(), cli.port() - 1); +#if USED_PORTMAP_TUNNEL + StringCbPrintf(pVm->scgTunnelGw, MAX_PATH, TEXT("%s:%d"), vm.portMapIp.c_str(), vm.portMapPort - 1); +#else + StringCbPrintf(pVm->scgTunnelGw, MAX_PATH, TEXT("%s:%d"), vm.scgIp.c_str(), vm.scgPort - 1); +#endif +#if USED_PORTMAP_TUNNEL +#endif pVm++; } } diff --git a/NetTunnelSDK/include/common.h b/NetTunnelSDK/include/common.h index 8037c5e..41f00d0 100644 --- a/NetTunnelSDK/include/common.h +++ b/NetTunnelSDK/include/common.h @@ -1,5 +1,7 @@ #pragma once +#define USED_PORTMAP_TUNNEL (1) + /** * @brief WireGuard key 最大长度 */ diff --git a/NetTunnelSDK/include/protocol.h b/NetTunnelSDK/include/protocol.h index e134712..d96eb53 100644 --- a/NetTunnelSDK/include/protocol.h +++ b/NetTunnelSDK/include/protocol.h @@ -1,5 +1,6 @@ #pragma once #include "ProtocolBase.h" +#include "common.h" #if !USER_REAL_PLATFORM class PlatformReqServerCfgParms { @@ -33,12 +34,16 @@ public: class VitrualMathineInfo { public: VitrualMathineInfo() { - this->vmId = 0; - this->scgPort = 0; - this->vmName = TEXT(""); - this->scgIp = TEXT(""); - this->vmNetwork = TEXT(""); - this->svrPubKey = TEXT(""); + this->vmId = 0; + this->scgPort = 0; + this->vmName = TEXT(""); + this->scgIp = TEXT(""); + this->vmNetwork = TEXT(""); + this->svrPubKey = TEXT(""); +#if USED_PORTMAP_TUNNEL + this->portMapIp = TEXT(""); + this->portMapPort = 0; +#endif } int vmId; @@ -47,8 +52,13 @@ public: std::string vmNetwork; std::string scgIp; int scgPort; - +#if USED_PORTMAP_TUNNEL + std::string portMapIp; + int portMapPort; + AIGC_JSON_HELPER(vmId, vmName, svrPubKey, vmNetwork, scgIp, scgPort, portMapIp, portMapPort) +#else AIGC_JSON_HELPER(vmId, vmName, svrPubKey, vmNetwork, scgIp, scgPort) +#endif }; class PlatformRspUserClientCfgParams { @@ -167,6 +177,10 @@ public: this->scgGateway = TEXT(""); this->vmNetwork = TEXT(""); this->svrPublicKey = TEXT(""); +#if USED_PORTMAP_TUNNEL + this->portMapIp = TEXT(""); + this->portMapPort = 0; +#endif } int vmId; @@ -174,8 +188,13 @@ public: std::string svrPublicKey; std::string vmNetwork; std::string scgGateway; - +#if USED_PORTMAP_TUNNEL + std::string portMapIp; + int portMapPort; + AIGC_JSON_HELPER(vmId, vmName, svrPublicKey, vmNetwork, scgGateway, portMapIp, portMapPort) +#else AIGC_JSON_HELPER(vmId, vmName, svrPublicKey, vmNetwork, scgGateway) +#endif }; class RspUsrCliConfigParams { diff --git a/NetTunnelSDK/sdk/common.h b/NetTunnelSDK/sdk/common.h index 5a426aa..1a5a1b7 100644 --- a/NetTunnelSDK/sdk/common.h +++ b/NetTunnelSDK/sdk/common.h @@ -1,5 +1,7 @@ #pragma once +#define USED_PORTMAP_TUNNEL (1) + /** * @brief WireGuard key ×î´ó³¤¶È */ diff --git a/NetTunnelSDK/tunnel/tunnel.cpp b/NetTunnelSDK/tunnel/tunnel.cpp index 42fadba..4f363bb 100644 --- a/NetTunnelSDK/tunnel/tunnel.cpp +++ b/NetTunnelSDK/tunnel/tunnel.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include "usrerr.h" @@ -66,7 +67,8 @@ static void InitTunnelSDKLog(const TCHAR *pLogFile, LOG_LEVEL level) { const auto dupFileFilter = std::make_shared(std::chrono::seconds(5)); const auto dupStdFilter = std::make_shared(std::chrono::seconds(5)); - dupFileFilter->add_sink(std::make_shared(buf, 1024 * 1024 * 5, 10)); + dupFileFilter->add_sink(std::make_shared(buf, 2, 30)); + //dupFileFilter->add_sink(std::make_shared(buf, 1024 * 1024 * 5, 10)); dupStdFilter->add_sink(std::make_shared()); std::vector sinks {dupStdFilter, dupFileFilter};