From 83d7cf638e0f93bb36c6793452341b932ec466e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E6=98=95?= Date: Thu, 17 Aug 2023 10:03:59 +0800 Subject: [PATCH] =?UTF-8?q?OCT=201.=20=E5=A2=9E=E5=8A=A0=E9=9A=A7=E9=81=93?= =?UTF-8?q?=E7=AB=AF=E5=8F=A3=E6=98=A0=E5=B0=84=E4=B8=B4=E6=97=B6=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E6=94=AF=E6=8C=81=202.=20=E5=A2=9E=E5=8A=A0=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E8=A7=84=E8=8C=83=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- NetTunnelSDK/UserManager.cpp | 9 +++++++-- NetTunnelSDK/include/common.h | 2 ++ NetTunnelSDK/include/protocol.h | 35 +++++++++++++++++++++++++-------- NetTunnelSDK/sdk/common.h | 2 ++ NetTunnelSDK/tunnel/tunnel.cpp | 4 +++- 5 files changed, 41 insertions(+), 11 deletions(-) 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};