1. 增加隧道端口映射临时功能支持
2. 增加日志规范支持
This commit is contained in:
黄昕 2023-08-17 10:03:59 +08:00
parent 4a046bd6e2
commit 83d7cf638e
5 changed files with 41 additions and 11 deletions

View File

@ -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->vmNetwork, MAX_IP_LEN, vm.vmNetwork.c_str());
//StringCbCopy(pVm->scgGateWay, MAX_PATH, vm.scgGateway.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); StringCbPrintf(pVm->scgGateWay, MAX_PATH, TEXT("http://%s:%d"), vm.scgIp.c_str(), vm.scgPort);
httplib::Client cli(pVm->scgGateWay); #if USED_PORTMAP_TUNNEL
StringCbPrintf(pVm->scgTunnelGw, MAX_PATH, TEXT("%s:%d"), cli.host().c_str(), cli.port() - 1); 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++; pVm++;
} }
} }

View File

@ -1,5 +1,7 @@
#pragma once #pragma once
#define USED_PORTMAP_TUNNEL (1)
/** /**
* @brief WireGuard key * @brief WireGuard key
*/ */

View File

@ -1,5 +1,6 @@
#pragma once #pragma once
#include "ProtocolBase.h" #include "ProtocolBase.h"
#include "common.h"
#if !USER_REAL_PLATFORM #if !USER_REAL_PLATFORM
class PlatformReqServerCfgParms { class PlatformReqServerCfgParms {
@ -39,6 +40,10 @@ public:
this->scgIp = TEXT(""); this->scgIp = TEXT("");
this->vmNetwork = TEXT(""); this->vmNetwork = TEXT("");
this->svrPubKey = TEXT(""); this->svrPubKey = TEXT("");
#if USED_PORTMAP_TUNNEL
this->portMapIp = TEXT("");
this->portMapPort = 0;
#endif
} }
int vmId; int vmId;
@ -47,8 +52,13 @@ public:
std::string vmNetwork; std::string vmNetwork;
std::string scgIp; std::string scgIp;
int scgPort; 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) AIGC_JSON_HELPER(vmId, vmName, svrPubKey, vmNetwork, scgIp, scgPort)
#endif
}; };
class PlatformRspUserClientCfgParams { class PlatformRspUserClientCfgParams {
@ -167,6 +177,10 @@ public:
this->scgGateway = TEXT(""); this->scgGateway = TEXT("");
this->vmNetwork = TEXT(""); this->vmNetwork = TEXT("");
this->svrPublicKey = TEXT(""); this->svrPublicKey = TEXT("");
#if USED_PORTMAP_TUNNEL
this->portMapIp = TEXT("");
this->portMapPort = 0;
#endif
} }
int vmId; int vmId;
@ -174,8 +188,13 @@ public:
std::string svrPublicKey; std::string svrPublicKey;
std::string vmNetwork; std::string vmNetwork;
std::string scgGateway; 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) AIGC_JSON_HELPER(vmId, vmName, svrPublicKey, vmNetwork, scgGateway)
#endif
}; };
class RspUsrCliConfigParams { class RspUsrCliConfigParams {

View File

@ -1,5 +1,7 @@
#pragma once #pragma once
#define USED_PORTMAP_TUNNEL (1)
/** /**
* @brief WireGuard key * @brief WireGuard key
*/ */

View File

@ -6,6 +6,7 @@
#include <spdlog/sinks/wincolor_sink.h> #include <spdlog/sinks/wincolor_sink.h>
#include <spdlog/sinks/rotating_file_sink.h> #include <spdlog/sinks/rotating_file_sink.h>
#include <spdlog/sinks/dup_filter_sink.h> #include <spdlog/sinks/dup_filter_sink.h>
#include <spdlog/sinks/daily_file_sink.h>
#include <dbghelp.h> #include <dbghelp.h>
#include "usrerr.h" #include "usrerr.h"
@ -66,7 +67,8 @@ static void InitTunnelSDKLog(const TCHAR *pLogFile, LOG_LEVEL level) {
const auto dupFileFilter = std::make_shared<spdlog::sinks::dup_filter_sink_st>(std::chrono::seconds(5)); const auto dupFileFilter = std::make_shared<spdlog::sinks::dup_filter_sink_st>(std::chrono::seconds(5));
const auto dupStdFilter = std::make_shared<spdlog::sinks::dup_filter_sink_st>(std::chrono::seconds(5)); const auto dupStdFilter = std::make_shared<spdlog::sinks::dup_filter_sink_st>(std::chrono::seconds(5));
dupFileFilter->add_sink(std::make_shared<spdlog::sinks::rotating_file_sink_mt>(buf, 1024 * 1024 * 5, 10)); dupFileFilter->add_sink(std::make_shared<spdlog::sinks::daily_file_sink_mt>(buf, 2, 30));
//dupFileFilter->add_sink(std::make_shared<spdlog::sinks::rotating_file_sink_mt>(buf, 1024 * 1024 * 5, 10));
dupStdFilter->add_sink(std::make_shared<spdlog::sinks::wincolor_stdout_sink_mt>()); dupStdFilter->add_sink(std::make_shared<spdlog::sinks::wincolor_stdout_sink_mt>());
std::vector<spdlog::sink_ptr> sinks {dupStdFilter, dupFileFilter}; std::vector<spdlog::sink_ptr> sinks {dupStdFilter, dupFileFilter};