OCT 1. 联调基本功能完成
This commit is contained in:
parent
4eb3a1da22
commit
dc9d15267a
|
@ -69,6 +69,18 @@
|
||||||
}
|
}
|
||||||
"Entry"
|
"Entry"
|
||||||
{
|
{
|
||||||
|
"MsmKey" = "8:_C492C60DB8E550E830CE1C2C460B4AD3"
|
||||||
|
"OwnerKey" = "8:_051B58ED18044668A8D8F5D293AEFB1B"
|
||||||
|
"MsmSig" = "8:_UNDEFINED"
|
||||||
|
}
|
||||||
|
"Entry"
|
||||||
|
{
|
||||||
|
"MsmKey" = "8:_D0A1E4927356B199FDD97B12CBDBC86E"
|
||||||
|
"OwnerKey" = "8:_051B58ED18044668A8D8F5D293AEFB1B"
|
||||||
|
"MsmSig" = "8:_UNDEFINED"
|
||||||
|
}
|
||||||
|
"Entry"
|
||||||
|
{
|
||||||
"MsmKey" = "8:_D64BF7F7A4C54240763CB0C07962C5D9"
|
"MsmKey" = "8:_D64BF7F7A4C54240763CB0C07962C5D9"
|
||||||
"OwnerKey" = "8:_051B58ED18044668A8D8F5D293AEFB1B"
|
"OwnerKey" = "8:_051B58ED18044668A8D8F5D293AEFB1B"
|
||||||
"MsmSig" = "8:_UNDEFINED"
|
"MsmSig" = "8:_UNDEFINED"
|
||||||
|
@ -81,6 +93,12 @@
|
||||||
}
|
}
|
||||||
"Entry"
|
"Entry"
|
||||||
{
|
{
|
||||||
|
"MsmKey" = "8:_DC0B62A757A10195CC98D20A71CB2871"
|
||||||
|
"OwnerKey" = "8:_051B58ED18044668A8D8F5D293AEFB1B"
|
||||||
|
"MsmSig" = "8:_UNDEFINED"
|
||||||
|
}
|
||||||
|
"Entry"
|
||||||
|
{
|
||||||
"MsmKey" = "8:_E42C46DD524A1F15E4C053C79430527B"
|
"MsmKey" = "8:_E42C46DD524A1F15E4C053C79430527B"
|
||||||
"OwnerKey" = "8:_051B58ED18044668A8D8F5D293AEFB1B"
|
"OwnerKey" = "8:_051B58ED18044668A8D8F5D293AEFB1B"
|
||||||
"MsmSig" = "8:_UNDEFINED"
|
"MsmSig" = "8:_UNDEFINED"
|
||||||
|
@ -127,6 +145,22 @@
|
||||||
"PrivateKeyFile" = "8:"
|
"PrivateKeyFile" = "8:"
|
||||||
"TimeStampServer" = "8:"
|
"TimeStampServer" = "8:"
|
||||||
"InstallerBootstrapper" = "3:2"
|
"InstallerBootstrapper" = "3:2"
|
||||||
|
"BootstrapperCfg:{63ACBE69-63AA-4F98-B2B6-99F9E24495F2}"
|
||||||
|
{
|
||||||
|
"Enabled" = "11:TRUE"
|
||||||
|
"PromptEnabled" = "11:TRUE"
|
||||||
|
"PrerequisitesLocation" = "2:1"
|
||||||
|
"Url" = "8:"
|
||||||
|
"ComponentsUrl" = "8:"
|
||||||
|
"Items"
|
||||||
|
{
|
||||||
|
"{EDC2488A-8267-493A-A98E-7D9C3B36CDF3}:.NETFramework,Version=v4.7.2"
|
||||||
|
{
|
||||||
|
"Name" = "8:Microsoft .NET Framework 4.7.2 (x86 and x64)"
|
||||||
|
"ProductCode" = "8:.NETFramework,Version=v4.7.2"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
"Release"
|
"Release"
|
||||||
{
|
{
|
||||||
|
@ -143,6 +177,14 @@
|
||||||
"PrivateKeyFile" = "8:"
|
"PrivateKeyFile" = "8:"
|
||||||
"TimeStampServer" = "8:"
|
"TimeStampServer" = "8:"
|
||||||
"InstallerBootstrapper" = "3:2"
|
"InstallerBootstrapper" = "3:2"
|
||||||
|
"BootstrapperCfg:{63ACBE69-63AA-4F98-B2B6-99F9E24495F2}"
|
||||||
|
{
|
||||||
|
"Enabled" = "11:TRUE"
|
||||||
|
"PromptEnabled" = "11:TRUE"
|
||||||
|
"PrerequisitesLocation" = "2:1"
|
||||||
|
"Url" = "8:"
|
||||||
|
"ComponentsUrl" = "8:"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"Deployable"
|
"Deployable"
|
||||||
|
@ -304,6 +346,46 @@
|
||||||
"IsDependency" = "11:TRUE"
|
"IsDependency" = "11:TRUE"
|
||||||
"IsolateTo" = "8:"
|
"IsolateTo" = "8:"
|
||||||
}
|
}
|
||||||
|
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_C492C60DB8E550E830CE1C2C460B4AD3"
|
||||||
|
{
|
||||||
|
"SourcePath" = "8:libssl-3-x64.dll"
|
||||||
|
"TargetName" = "8:libssl-3-x64.dll"
|
||||||
|
"Tag" = "8:"
|
||||||
|
"Folder" = "8:_0777490231CD48A0970C1FCD623EA32A"
|
||||||
|
"Condition" = "8:"
|
||||||
|
"Transitive" = "11:FALSE"
|
||||||
|
"Vital" = "11:TRUE"
|
||||||
|
"ReadOnly" = "11:FALSE"
|
||||||
|
"Hidden" = "11:FALSE"
|
||||||
|
"System" = "11:FALSE"
|
||||||
|
"Permanent" = "11:FALSE"
|
||||||
|
"SharedLegacy" = "11:FALSE"
|
||||||
|
"PackageAs" = "3:1"
|
||||||
|
"Register" = "3:1"
|
||||||
|
"Exclude" = "11:FALSE"
|
||||||
|
"IsDependency" = "11:TRUE"
|
||||||
|
"IsolateTo" = "8:"
|
||||||
|
}
|
||||||
|
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_D0A1E4927356B199FDD97B12CBDBC86E"
|
||||||
|
{
|
||||||
|
"SourcePath" = "8:CRYPT32.dll"
|
||||||
|
"TargetName" = "8:CRYPT32.dll"
|
||||||
|
"Tag" = "8:"
|
||||||
|
"Folder" = "8:_0777490231CD48A0970C1FCD623EA32A"
|
||||||
|
"Condition" = "8:"
|
||||||
|
"Transitive" = "11:FALSE"
|
||||||
|
"Vital" = "11:TRUE"
|
||||||
|
"ReadOnly" = "11:FALSE"
|
||||||
|
"Hidden" = "11:FALSE"
|
||||||
|
"System" = "11:FALSE"
|
||||||
|
"Permanent" = "11:FALSE"
|
||||||
|
"SharedLegacy" = "11:FALSE"
|
||||||
|
"PackageAs" = "3:1"
|
||||||
|
"Register" = "3:1"
|
||||||
|
"Exclude" = "11:TRUE"
|
||||||
|
"IsDependency" = "11:TRUE"
|
||||||
|
"IsolateTo" = "8:"
|
||||||
|
}
|
||||||
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_D64BF7F7A4C54240763CB0C07962C5D9"
|
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_D64BF7F7A4C54240763CB0C07962C5D9"
|
||||||
{
|
{
|
||||||
"SourcePath" = "8:ucrtbased.dll"
|
"SourcePath" = "8:ucrtbased.dll"
|
||||||
|
@ -324,6 +406,26 @@
|
||||||
"IsDependency" = "11:TRUE"
|
"IsDependency" = "11:TRUE"
|
||||||
"IsolateTo" = "8:"
|
"IsolateTo" = "8:"
|
||||||
}
|
}
|
||||||
|
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_DC0B62A757A10195CC98D20A71CB2871"
|
||||||
|
{
|
||||||
|
"SourcePath" = "8:libcrypto-3-x64.dll"
|
||||||
|
"TargetName" = "8:libcrypto-3-x64.dll"
|
||||||
|
"Tag" = "8:"
|
||||||
|
"Folder" = "8:_0777490231CD48A0970C1FCD623EA32A"
|
||||||
|
"Condition" = "8:"
|
||||||
|
"Transitive" = "11:FALSE"
|
||||||
|
"Vital" = "11:TRUE"
|
||||||
|
"ReadOnly" = "11:FALSE"
|
||||||
|
"Hidden" = "11:FALSE"
|
||||||
|
"System" = "11:FALSE"
|
||||||
|
"Permanent" = "11:FALSE"
|
||||||
|
"SharedLegacy" = "11:FALSE"
|
||||||
|
"PackageAs" = "3:1"
|
||||||
|
"Register" = "3:1"
|
||||||
|
"Exclude" = "11:FALSE"
|
||||||
|
"IsDependency" = "11:TRUE"
|
||||||
|
"IsolateTo" = "8:"
|
||||||
|
}
|
||||||
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_E42C46DD524A1F15E4C053C79430527B"
|
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_E42C46DD524A1F15E4C053C79430527B"
|
||||||
{
|
{
|
||||||
"SourcePath" = "8:VCRUNTIME140D.dll"
|
"SourcePath" = "8:VCRUNTIME140D.dll"
|
||||||
|
@ -441,7 +543,7 @@
|
||||||
"Name" = "8:Microsoft Visual Studio"
|
"Name" = "8:Microsoft Visual Studio"
|
||||||
"ProductName" = "8:SCCServer"
|
"ProductName" = "8:SCCServer"
|
||||||
"ProductCode" = "8:{E00CE8DB-D79F-4890-910F-64AE0F37AEED}"
|
"ProductCode" = "8:{E00CE8DB-D79F-4890-910F-64AE0F37AEED}"
|
||||||
"PackageCode" = "8:{2881D34B-31F4-4DA0-AE7A-7FAF55389480}"
|
"PackageCode" = "8:{4A613EBB-74F1-4F04-9B7F-CC39E5BDC4D4}"
|
||||||
"UpgradeCode" = "8:{3089869A-5F6B-4EC2-B2CA-54B51499079F}"
|
"UpgradeCode" = "8:{3089869A-5F6B-4EC2-B2CA-54B51499079F}"
|
||||||
"AspNetVersion" = "8:2.0.50727.0"
|
"AspNetVersion" = "8:2.0.50727.0"
|
||||||
"RestartWWWService" = "11:FALSE"
|
"RestartWWWService" = "11:FALSE"
|
||||||
|
|
|
@ -45,8 +45,8 @@ public partial class MainForm : Form
|
||||||
var path = Environment.CurrentDirectory + "\\tunnelsdk_" +
|
var path = Environment.CurrentDirectory + "\\tunnelsdk_" +
|
||||||
string.Format("{0:yyyyMMdd}", DateTime.Now) + ".log";
|
string.Format("{0:yyyyMMdd}", DateTime.Now) + ".log";
|
||||||
//NetTunnelLib.InitTunnelSDKLog(path, LogLevel.LOG_DEBUG);
|
//NetTunnelLib.InitTunnelSDKLog(path, LogLevel.LOG_DEBUG);
|
||||||
NetTunnelLib.TunnelSDKInitEnv(Environment.CurrentDirectory, "http://xajhuang.com:9276", path, LogLevel.LOG_TRACE, menuSetModeServer.Checked);
|
NetTunnelLib.TunnelSDKInitEnv(Environment.CurrentDirectory, "http://172.21.40.39:32549", path, LogLevel.LOG_TRACE, menuSetModeServer.Checked);
|
||||||
NetTunnelLib.EnableSCGProxy(true, "efc.xajhuang.com", 10001);
|
//NetTunnelLib.EnableSCGProxy(true, "efc.xajhuang.com", 10001);
|
||||||
GetCurrentNetCard();
|
GetCurrentNetCard();
|
||||||
|
|
||||||
NetCardMenuItems menuItems = new NetCardMenuItems(_curNetCard);
|
NetCardMenuItems menuItems = new NetCardMenuItems(_curNetCard);
|
||||||
|
@ -189,7 +189,7 @@ public partial class MainForm : Form
|
||||||
IntPtr pt = new IntPtr();
|
IntPtr pt = new IntPtr();
|
||||||
|
|
||||||
if (NetTunnelLib.GetUserClientConfigure(args.HashArgs["UserName"] as string,
|
if (NetTunnelLib.GetUserClientConfigure(args.HashArgs["UserName"] as string,
|
||||||
args.HashArgs["Password"] as string,
|
"1689189114026041344",
|
||||||
out pt) == 0)
|
out pt) == 0)
|
||||||
{
|
{
|
||||||
IntPtr p = new IntPtr(pt.ToInt64());
|
IntPtr p = new IntPtr(pt.ToInt64());
|
||||||
|
@ -334,21 +334,22 @@ public partial class MainForm : Form
|
||||||
|
|
||||||
private void menuControlSvrStop_Click(object sender, EventArgs e)
|
private void menuControlSvrStop_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var ret = NetTunnelLib.RemoteWireGuardControl(false);
|
var ret = NetTunnelLib.LocalWireGuardControl(false);
|
||||||
|
|
||||||
if (ret != 0)
|
|
||||||
{
|
|
||||||
MessageBox.Show("RemoteWireGuardControl Error: " + ret.ToString());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = NetTunnelLib.LocalWireGuardControl(false);
|
|
||||||
|
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
{
|
{
|
||||||
MessageBox.Show("LocalWireGuardControl Error: " + ret.ToString());
|
MessageBox.Show("LocalWireGuardControl Error: " + ret.ToString());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ret = NetTunnelLib.RemoteWireGuardControl(false);
|
||||||
|
|
||||||
|
|
||||||
|
if (ret != 0)
|
||||||
|
{
|
||||||
|
MessageBox.Show("RemoteWireGuardControl Error: " + ret.ToString());
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void menuControlHeartStart_Click(object sender, EventArgs e)
|
private void menuControlHeartStart_Click(object sender, EventArgs e)
|
||||||
|
|
|
@ -233,7 +233,7 @@ int RemoteCtrlSvrCfgUserTunnel(int vmId, const TCHAR *pCliNetwork) {
|
||||||
GetIpV4InfoFromCIDR(pUserCfg->cliAddress, &ipInfo);
|
GetIpV4InfoFromCIDR(pUserCfg->cliAddress, &ipInfo);
|
||||||
req.msgContent.cliTunnelAddr = ipInfo.ip;
|
req.msgContent.cliTunnelAddr = ipInfo.ip;
|
||||||
|
|
||||||
GetGlobalCfgInfo()->curConnVmId = vmId;
|
GetGlobalCfgInfo()->curConnVmId = vmId;
|
||||||
SPDLOG_DEBUG(TEXT("Current VMID: {0}"), vmId);
|
SPDLOG_DEBUG(TEXT("Current VMID: {0}"), vmId);
|
||||||
|
|
||||||
// 连接到服务端控制服务
|
// 连接到服务端控制服务
|
||||||
|
@ -404,8 +404,13 @@ int GetUserServerConfigure(const TCHAR *pUserName, const TCHAR *pToken, PUSER_SE
|
||||||
PUSER_CONFIG pUser = &GetGlobalCfgInfo()->userCfg;
|
PUSER_CONFIG pUser = &GetGlobalCfgInfo()->userCfg;
|
||||||
PUSER_SERVER_CONFIG pUserCfg = &pUser->svrConfig;
|
PUSER_SERVER_CONFIG pUserCfg = &pUser->svrConfig;
|
||||||
|
|
||||||
|
#if USER_REAL_PLATFORM
|
||||||
ProtocolRequest<ReqGetUserCfgParams> req;
|
ProtocolRequest<ReqGetUserCfgParams> req;
|
||||||
ProtocolResponse<RspUserSevrCfgParams> rsp;
|
ProtocolResponse<RspUserSevrCfgParams> rsp;
|
||||||
|
#else
|
||||||
|
PlatformReqServerCfgParms req;
|
||||||
|
PlatformRspServerCfgParams rsp;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (pSvrCfg == nullptr) {
|
if (pSvrCfg == nullptr) {
|
||||||
SPDLOG_ERROR(TEXT("Input pSvrCfg params error"));
|
SPDLOG_ERROR(TEXT("Input pSvrCfg params error"));
|
||||||
|
@ -426,6 +431,7 @@ int GetUserServerConfigure(const TCHAR *pUserName, const TCHAR *pToken, PUSER_SE
|
||||||
|
|
||||||
StringCbCopy(pUser->userToken, MAX_PATH, pToken);
|
StringCbCopy(pUser->userToken, MAX_PATH, pToken);
|
||||||
|
|
||||||
|
#if USER_REAL_PLATFORM
|
||||||
req.msgContent.token = pToken;
|
req.msgContent.token = pToken;
|
||||||
req.msgContent.user = pUser->userName;
|
req.msgContent.user = pUser->userName;
|
||||||
|
|
||||||
|
@ -439,6 +445,26 @@ int GetUserServerConfigure(const TCHAR *pUserName, const TCHAR *pToken, PUSER_SE
|
||||||
StringCbCopy(pUserCfg->svrPrivateKey, 64, rsp.msgContent.svrPrivateKey.c_str());
|
StringCbCopy(pUserCfg->svrPrivateKey, 64, rsp.msgContent.svrPrivateKey.c_str());
|
||||||
StringCbCopy(pUserCfg->svrAddress, MAX_IP_LEN, rsp.msgContent.svrAddress.c_str());
|
StringCbCopy(pUserCfg->svrAddress, MAX_IP_LEN, rsp.msgContent.svrAddress.c_str());
|
||||||
|
|
||||||
|
#else
|
||||||
|
req.vmIp = pToken;
|
||||||
|
ret = PlatformProtolPostMessage(GET_SERVERCFG_PATH, &req, &rsp);
|
||||||
|
|
||||||
|
if (ret != ERR_SUCCESS) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = strtol(rsp.code.c_str(), nullptr, 10);
|
||||||
|
|
||||||
|
if (ret != 0) {
|
||||||
|
SPDLOG_ERROR(TEXT("Server response error code: {0}"), ret);
|
||||||
|
return -ERR_HTTP_SERVER_RSP;
|
||||||
|
}
|
||||||
|
|
||||||
|
pUserCfg->svrListenPort = rsp.data.svrPort;
|
||||||
|
StringCbCopy(pUserCfg->svrPrivateKey, 64, rsp.data.svrPriKey.c_str());
|
||||||
|
StringCbCopy(pUserCfg->svrAddress, MAX_IP_LEN, rsp.data.svrHost.c_str());
|
||||||
|
#endif
|
||||||
|
|
||||||
*pSvrCfg = pUserCfg;
|
*pSvrCfg = pUserCfg;
|
||||||
return ERR_SUCCESS;
|
return ERR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -449,8 +475,13 @@ int GetUserClientConfigure(const TCHAR *pUserName, const TCHAR *pToken, PUSER_CL
|
||||||
TCHAR userPath[MAX_PATH];
|
TCHAR userPath[MAX_PATH];
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
#if USER_REAL_PLATFORM
|
||||||
ProtocolRequest<ReqGetUserCfgParams> req;
|
ProtocolRequest<ReqGetUserCfgParams> req;
|
||||||
ProtocolResponse<RspUsrCliConfigParams> rsp;
|
ProtocolResponse<RspUsrCliConfigParams> rsp;
|
||||||
|
#else
|
||||||
|
PlatformReqClientCfgParms req;
|
||||||
|
PlatformRspClientCfgParams rsp;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (pUserName == nullptr || lstrlen(pUserName) == 0) {
|
if (pUserName == nullptr || lstrlen(pUserName) == 0) {
|
||||||
SPDLOG_ERROR(TEXT("Input pUserName params error: {0}"), pUserName);
|
SPDLOG_ERROR(TEXT("Input pUserName params error: {0}"), pUserName);
|
||||||
|
@ -482,6 +513,7 @@ int GetUserClientConfigure(const TCHAR *pUserName, const TCHAR *pToken, PUSER_CL
|
||||||
}
|
}
|
||||||
StringCbCopy(pUser->userToken, MAX_PATH, pToken);
|
StringCbCopy(pUser->userToken, MAX_PATH, pToken);
|
||||||
|
|
||||||
|
#if USER_REAL_PLATFORM
|
||||||
req.msgContent.token = pToken;
|
req.msgContent.token = pToken;
|
||||||
req.msgContent.user = pUserName;
|
req.msgContent.user = pUserName;
|
||||||
|
|
||||||
|
@ -490,7 +522,7 @@ int GetUserClientConfigure(const TCHAR *pUserName, const TCHAR *pToken, PUSER_CL
|
||||||
if (ret != ERR_SUCCESS) {
|
if (ret != ERR_SUCCESS) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
StringCbCopy(pUserCfg->cliPrivateKey, 64, rsp.msgContent.cliPrivateKey.c_str());
|
StringCbCopy(pUserCfg->cliPrivateKey, 64, rsp.msgContent.cliPrivateKey.c_str());
|
||||||
StringCbCopy(pUserCfg->cliPublicKey, 64, rsp.msgContent.cliPublicKey.c_str());
|
StringCbCopy(pUserCfg->cliPublicKey, 64, rsp.msgContent.cliPublicKey.c_str());
|
||||||
StringCbCopy(pUserCfg->cliAddress, MAX_IP_LEN, rsp.msgContent.cliAddress.c_str());
|
StringCbCopy(pUserCfg->cliAddress, MAX_IP_LEN, rsp.msgContent.cliAddress.c_str());
|
||||||
|
@ -523,7 +555,55 @@ int GetUserClientConfigure(const TCHAR *pUserName, const TCHAR *pToken, PUSER_CL
|
||||||
pVm++;
|
pVm++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
req.userName = pUserName;
|
||||||
|
req.token = pToken;
|
||||||
|
|
||||||
|
ret = PlatformProtolPostMessage(GET_CLIENTCFG_PATH, &req, &rsp);
|
||||||
|
|
||||||
|
if (ret != ERR_SUCCESS) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = strtol(rsp.code.c_str(), nullptr, 10);
|
||||||
|
|
||||||
|
if (ret != 0) {
|
||||||
|
SPDLOG_ERROR(TEXT("Server response error code: {0}"), ret);
|
||||||
|
return -ERR_HTTP_SERVER_RSP;
|
||||||
|
}
|
||||||
|
|
||||||
|
StringCbCopy(pUserCfg->cliPrivateKey, 64, rsp.data.cliPriKey.c_str());
|
||||||
|
StringCbCopy(pUserCfg->cliPublicKey, 64, rsp.data.cliPubKey.c_str());
|
||||||
|
StringCbCopy(pUserCfg->cliAddress, MAX_IP_LEN, rsp.data.cliHost.c_str());
|
||||||
|
|
||||||
|
if (!rsp.data.vmInfoList.empty()) {
|
||||||
|
PVM_CFG pVm;
|
||||||
|
unsigned int memSize = sizeof(VM_CFG) * static_cast<UINT>(rsp.data.vmInfoList.size());
|
||||||
|
pUserCfg->pVMConfig = static_cast<PVM_CFG>(CoTaskMemAlloc(memSize));
|
||||||
|
if (pUserCfg->pVMConfig == nullptr) {
|
||||||
|
SPDLOG_ERROR(TEXT("Error allocating memory {0} bytes"), memSize);
|
||||||
|
return -ERR_MALLOC_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
memset(pUserCfg->pVMConfig, 0, memSize);
|
||||||
|
|
||||||
|
pUserCfg->tolVM = static_cast<int>(rsp.data.vmInfoList.size());
|
||||||
|
pVm = pUserCfg->pVMConfig;
|
||||||
|
|
||||||
|
for (auto vm : rsp.data.vmInfoList) {
|
||||||
|
pVm->vmId = vm.vmId;
|
||||||
|
StringCbCopy(pVm->vmName, MAX_PATH, vm.vmName.c_str());
|
||||||
|
StringCbCopy(pVm->svrPublicKey, 64, vm.svrPubKey.c_str());
|
||||||
|
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);
|
||||||
|
pVm++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
*pCliCfg = pUserCfg;
|
*pCliCfg = pUserCfg;
|
||||||
return ERR_SUCCESS;
|
return ERR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "AIGCJson.hpp"
|
#include "AIGCJson.hpp"
|
||||||
|
|
||||||
|
#define USER_REAL_PLATFORM (0)
|
||||||
|
|
||||||
class ProtocolBase {
|
class ProtocolBase {
|
||||||
public:
|
public:
|
||||||
ProtocolBase() {
|
ProtocolBase() {
|
||||||
|
@ -15,8 +17,8 @@ public:
|
||||||
|
|
||||||
AIGC_JSON_HELPER(ver, cryptoType, timeStamp)
|
AIGC_JSON_HELPER(ver, cryptoType, timeStamp)
|
||||||
|
|
||||||
void SetVersion(unsigned int ver) {
|
void SetVersion(unsigned int versino) {
|
||||||
this->ver = ver;
|
this->ver = versino;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetTimeStamp(unsigned int ts) {
|
void SetTimeStamp(unsigned int ts) {
|
||||||
|
@ -24,7 +26,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetCryptoType(unsigned int crypto) {
|
void SetCryptoType(unsigned int crypto) {
|
||||||
this->cryptoType = cryptoType;
|
this->cryptoType = crypto;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,15 @@
|
||||||
*/
|
*/
|
||||||
#define MAX_NETCARD_NAME (64)
|
#define MAX_NETCARD_NAME (64)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief SCG 服务 ID
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
typedef enum {
|
||||||
|
WG_TUNNEL_SCG_ID = 3, ///< 隧道服务
|
||||||
|
WG_CTRL_SCG_ID = 4 ///< 隧道控制服务
|
||||||
|
} SCG_SVR_ID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 协议加密类型
|
* @brief 协议加密类型
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN // 从 Windows 头文件中排除极少使用的内容
|
#define WIN32_LEAN_AND_MEAN // 从 Windows 头文件中排除极少使用的内容
|
||||||
|
#define CPPHTTPLIB_OPENSSL_SUPPORT
|
||||||
|
|
||||||
// Windows 头文件
|
// Windows 头文件
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
|
@ -1,6 +1,94 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "ProtocolBase.h"
|
#include "ProtocolBase.h"
|
||||||
|
|
||||||
|
#if !USER_REAL_PLATFORM
|
||||||
|
class PlatformReqServerCfgParms {
|
||||||
|
public:
|
||||||
|
std::string vmIp;
|
||||||
|
AIGC_JSON_HELPER(vmIp)
|
||||||
|
};
|
||||||
|
|
||||||
|
class PlatformReqClientCfgParms {
|
||||||
|
public:
|
||||||
|
std::string userName;
|
||||||
|
std::string token;
|
||||||
|
AIGC_JSON_HELPER(userName)
|
||||||
|
};
|
||||||
|
|
||||||
|
class PlatformRspUserSvrCfgParams {
|
||||||
|
public:
|
||||||
|
PlatformRspUserSvrCfgParams() {
|
||||||
|
this->svrHost = TEXT("");
|
||||||
|
this->svrPort = 0;
|
||||||
|
this->svrPriKey = TEXT("");
|
||||||
|
}
|
||||||
|
|
||||||
|
int svrPort;
|
||||||
|
std::string svrPriKey;
|
||||||
|
std::string svrHost;
|
||||||
|
|
||||||
|
AIGC_JSON_HELPER(svrPort, svrPriKey, svrHost)
|
||||||
|
};
|
||||||
|
|
||||||
|
class VitrualMathineInfo {
|
||||||
|
public:
|
||||||
|
VitrualMathineInfo() {
|
||||||
|
this->vmId = 0;
|
||||||
|
this->scgPort = 0;
|
||||||
|
this->vmName = TEXT("");
|
||||||
|
this->scgIp = TEXT("");
|
||||||
|
this->vmNetwork = TEXT("");
|
||||||
|
this->svrPubKey = TEXT("");
|
||||||
|
}
|
||||||
|
|
||||||
|
int vmId;
|
||||||
|
std::string vmName;
|
||||||
|
std::string svrPubKey;
|
||||||
|
std::string vmNetwork;
|
||||||
|
std::string scgIp;
|
||||||
|
int scgPort;
|
||||||
|
|
||||||
|
AIGC_JSON_HELPER(vmId, vmName, svrPubKey, vmNetwork, scgIp, scgPort)
|
||||||
|
};
|
||||||
|
|
||||||
|
class PlatformRspUserClientCfgParams {
|
||||||
|
public:
|
||||||
|
PlatformRspUserClientCfgParams() {
|
||||||
|
this->scgTunnelAppId = WG_TUNNEL_SCG_ID;
|
||||||
|
this->scgCtrlAppId = WG_CTRL_SCG_ID;
|
||||||
|
this->cliHost = TEXT("");
|
||||||
|
}
|
||||||
|
|
||||||
|
int scgCtrlAppId;
|
||||||
|
int scgTunnelAppId;
|
||||||
|
std::string cliPriKey;
|
||||||
|
std::string cliPubKey;
|
||||||
|
std::string cliHost;
|
||||||
|
std::list<VitrualMathineInfo> vmInfoList;
|
||||||
|
|
||||||
|
AIGC_JSON_HELPER(scgCtrlAppId, scgTunnelAppId, cliPriKey, cliPubKey, vmInfoList, cliHost)
|
||||||
|
};
|
||||||
|
|
||||||
|
class PlatformRspServerCfgParams {
|
||||||
|
public:
|
||||||
|
std::string code;
|
||||||
|
std::string message;
|
||||||
|
PlatformRspUserSvrCfgParams data;
|
||||||
|
|
||||||
|
AIGC_JSON_HELPER(code, data)
|
||||||
|
};
|
||||||
|
|
||||||
|
class PlatformRspClientCfgParams {
|
||||||
|
public:
|
||||||
|
std::string code;
|
||||||
|
std::string message;
|
||||||
|
PlatformRspUserClientCfgParams data;
|
||||||
|
|
||||||
|
AIGC_JSON_HELPER(code, data)
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
class ReqClientCfgParams {
|
class ReqClientCfgParams {
|
||||||
public:
|
public:
|
||||||
std::string identifier;
|
std::string identifier;
|
||||||
|
@ -102,8 +190,13 @@ public:
|
||||||
AIGC_JSON_HELPER(scgCtrlAppId, scgTunnelAppId, cliPrivateKey, cliPublicKey, cliAddress, vmConfig)
|
AIGC_JSON_HELPER(scgCtrlAppId, scgTunnelAppId, cliPrivateKey, cliPublicKey, cliAddress, vmConfig)
|
||||||
};
|
};
|
||||||
|
|
||||||
#define GET_CLIENTCFG_PATH TEXT("/tunnel/getuserconfig")
|
#if USER_REAL_PLATFORM
|
||||||
#define GET_SERVERCFG_PATH TEXT("/tunnel/getserverconfig")
|
#define GET_CLIENTCFG_PATH TEXT("/tunnel/getuserconfig")
|
||||||
|
#define GET_SERVERCFG_PATH TEXT("/tunnel/getserverconfig")
|
||||||
|
#else
|
||||||
|
#define GET_CLIENTCFG_PATH TEXT("/sc/open-portal/openapi/scc/cliTunnelCfg")
|
||||||
|
#define GET_SERVERCFG_PATH TEXT("/sc/open-portal/openapi/scc/svrTunnelCfg")
|
||||||
|
#endif
|
||||||
|
|
||||||
#define SET_CLIENTCFG_PATH TEXT("/tunnel/setconfig")
|
#define SET_CLIENTCFG_PATH TEXT("/tunnel/setconfig")
|
||||||
#define SET_CLIENTSTART_TUNNEL TEXT("/tunnel/start")
|
#define SET_CLIENTSTART_TUNNEL TEXT("/tunnel/start")
|
||||||
|
@ -156,4 +249,23 @@ extern template int ProtolPostMessage(const TCHAR *pUr
|
||||||
extern template int ProtolPostMessage(const TCHAR *pUrlPath,
|
extern template int ProtolPostMessage(const TCHAR *pUrlPath,
|
||||||
ProtocolRequest<ReqHeartParams> *pReq,
|
ProtocolRequest<ReqHeartParams> *pReq,
|
||||||
ProtocolResponse<RspHeartParams> *pRsp,
|
ProtocolResponse<RspHeartParams> *pRsp,
|
||||||
bool platformServer);
|
bool platformServer);
|
||||||
|
|
||||||
|
#if !USER_REAL_PLATFORM
|
||||||
|
template<class T1, class T2> int PlatformProtolPostMessage(const TCHAR *pUrlPath, T1 *pReq, T2 *pRsp);
|
||||||
|
|
||||||
|
extern template int PlatformProtolPostMessage(const TCHAR *pUrlPath,
|
||||||
|
PlatformReqServerCfgParms *pReq,
|
||||||
|
PlatformRspServerCfgParams *pRsp);
|
||||||
|
|
||||||
|
extern template int PlatformProtolPostMessage(const TCHAR *pUrlPath,
|
||||||
|
PlatformReqClientCfgParms *pReq,
|
||||||
|
PlatformRspClientCfgParams *pRsp);
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
template<class T1> int PlatformProtolGetMessage(const TCHAR *pUrlPath, T1 *pRsp);
|
||||||
|
|
||||||
|
extern template int PlatformProtolGetMessage(const TCHAR *pUrlPath,
|
||||||
|
PlatformRspUserClientCfgParams *pRsp);
|
||||||
|
#endif
|
||||||
|
#endif
|
|
@ -2,15 +2,15 @@
|
||||||
// Microsoft Visual C++ 生成的包含文件。
|
// Microsoft Visual C++ 生成的包含文件。
|
||||||
// 供 NetTunnelSDK.rc 使用
|
// 供 NetTunnelSDK.rc 使用
|
||||||
//
|
//
|
||||||
#define IDR_TXT1 105
|
#define IDR_TXT1 105
|
||||||
|
|
||||||
// Next default values for new objects
|
// Next default values for new objects
|
||||||
//
|
//
|
||||||
#ifdef APSTUDIO_INVOKED
|
#ifdef APSTUDIO_INVOKED
|
||||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||||
#define _APS_NEXT_RESOURCE_VALUE 106
|
#define _APS_NEXT_RESOURCE_VALUE 106
|
||||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||||
#define _APS_NEXT_CONTROL_VALUE 1001
|
#define _APS_NEXT_CONTROL_VALUE 1001
|
||||||
#define _APS_NEXT_SYMED_VALUE 101
|
#define _APS_NEXT_SYMED_VALUE 101
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,11 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "sccsdk.h"
|
#include "sccsdk.h"
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
WG_TUNNEL_SCG_ID = 3,
|
|
||||||
WG_CTRL_SCG_ID = 4
|
|
||||||
} SCG_SVR_ID;
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
CHK_SYSTEM_INIT,
|
CHK_SYSTEM_INIT,
|
||||||
CHK_WIREGUARD_CONFIG,
|
CHK_WIREGUARD_CONFIG,
|
||||||
|
|
|
@ -45,7 +45,7 @@ int SetTunnelConfigure(const TCHAR *pCliPrivateKey,
|
||||||
const TCHAR *pSvrNetwork,
|
const TCHAR *pSvrNetwork,
|
||||||
const TCHAR *pCliNetwork,
|
const TCHAR *pCliNetwork,
|
||||||
const TCHAR *pSvrTunnelAddr,
|
const TCHAR *pSvrTunnelAddr,
|
||||||
const TCHAR *pSvrEndPoint);
|
const TCHAR *pSvrEndPoint);
|
||||||
|
|
||||||
int GetUserConfigFiles(const TCHAR *pUserName, PUSER_CFGFILE* pCfgFile, int *pItems);
|
int GetUserConfigFiles(const TCHAR *pUserName, PUSER_CFGFILE* pCfgFile, int *pItems);
|
||||||
|
|
||||||
|
|
|
@ -219,6 +219,190 @@ int ProtolPostMessage(const TCHAR *pUrlPath,
|
||||||
return ERR_SUCCESS;
|
return ERR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
template<class T1> int PlatformProtolGetMessage(const TCHAR *pUrlPath, T1 *pRsp) {
|
||||||
|
httplib::Result res;
|
||||||
|
TCHAR *pJson = nullptr;
|
||||||
|
std::string timestamp = std::to_string(time(nullptr)) + "000";
|
||||||
|
TCHAR hashValeu[MAX_PATH] = {0};
|
||||||
|
TCHAR hashBuf[1024] = {};
|
||||||
|
|
||||||
|
if (lstrlen(GetGlobalCfgInfo()->platformServerUrl) == 0) {
|
||||||
|
SPDLOG_ERROR(TEXT("Platform Server URL uninitialize."));
|
||||||
|
return -ERR_SYSTEM_UNINITIALIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pRsp == nullptr) {
|
||||||
|
SPDLOG_ERROR(TEXT("Input ProtocolResponse<T2> *pRsp params error"));
|
||||||
|
return -ERR_INPUT_PARAMS;
|
||||||
|
}
|
||||||
|
|
||||||
|
StringCbPrintf(hashBuf,
|
||||||
|
1024,
|
||||||
|
TEXT("%s|%s|%s|%s"),
|
||||||
|
GetGlobalCfgInfo()->clientId,
|
||||||
|
GetGlobalCfgInfo()->clientSecret,
|
||||||
|
timestamp.c_str(),
|
||||||
|
pJson);
|
||||||
|
|
||||||
|
if (lstrlen(GetGlobalCfgInfo()->clientSecret) > 0 &&
|
||||||
|
CalcHmacHash(HASH_SHA256,
|
||||||
|
reinterpret_cast<PUCHAR>(hashBuf),
|
||||||
|
lstrlen(hashBuf),
|
||||||
|
reinterpret_cast<PUCHAR>(GetGlobalCfgInfo()->clientSecret),
|
||||||
|
lstrlen(GetGlobalCfgInfo()->clientSecret),
|
||||||
|
hashValeu,
|
||||||
|
true) == ERR_SUCCESS) {
|
||||||
|
const httplib::Headers headers = {
|
||||||
|
{"gzs-client-id", GetGlobalCfgInfo()->clientId},
|
||||||
|
{"gzs-sign", hashValeu },
|
||||||
|
{"gzs-timestamp", timestamp },
|
||||||
|
};
|
||||||
|
res = g_httpCtx->Get(pUrlPath, headers);
|
||||||
|
} else {
|
||||||
|
res = g_httpCtx->Get(pUrlPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (res.error() != httplib::Error::Success) {
|
||||||
|
SPDLOG_ERROR(TEXT("[{0}]:Post Data {1} error: {2}"), pUrlPath, pJson, httplib::to_string(res.error()));
|
||||||
|
free(pJson);
|
||||||
|
return -ERR_HTTP_POST_DATA;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (res->status != 200) {
|
||||||
|
SPDLOG_ERROR(TEXT("[{0}]:Post Data {1} server return HTTP error: {2}"), pUrlPath, pJson, res->status);
|
||||||
|
free(pJson);
|
||||||
|
return -ERR_HTTP_SERVER_RSP;
|
||||||
|
}
|
||||||
|
|
||||||
|
SPDLOG_DEBUG(TEXT("+++++ Http Request {0}\n---- Http Response {1}"), pJson, res->body.c_str());
|
||||||
|
|
||||||
|
free(pJson);
|
||||||
|
|
||||||
|
if (lstrlen(res->body.c_str()) == 0) {
|
||||||
|
SPDLOG_ERROR(TEXT("Server response empty message"));
|
||||||
|
return -ERR_READ_FILE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (DecodeProtocolResponse(pRsp, res->body.c_str()) != ERR_SUCCESS) {
|
||||||
|
SPDLOG_ERROR(TEXT("Decode JSON {0} to ProtocolResponse<{1}> error"), res->body, typeid(T1).name());
|
||||||
|
return -ERR_JSON_DECODE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ERR_SUCCESS;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
template<class T1, class T2> int PlatformProtolPostMessage(const TCHAR *pUrlPath, T1 *pReq, T2 *pRsp) {
|
||||||
|
int ret;
|
||||||
|
httplib::Result res;
|
||||||
|
TCHAR *pJson = nullptr;
|
||||||
|
std::string timestamp = std::to_string(time(nullptr)) + "000";
|
||||||
|
TCHAR hashValeu[MAX_PATH] = {0};
|
||||||
|
TCHAR hashBuf[1024] = {};
|
||||||
|
|
||||||
|
if (lstrlen(GetGlobalCfgInfo()->platformServerUrl) == 0) {
|
||||||
|
SPDLOG_ERROR(TEXT("Platform Server URL uninitialize."));
|
||||||
|
return -ERR_SYSTEM_UNINITIALIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pReq == nullptr) {
|
||||||
|
SPDLOG_ERROR(TEXT("Input pToken params error"));
|
||||||
|
SPDLOG_ERROR(TEXT("Input ProtocolRequest<T1> *pReq params error"));
|
||||||
|
return -ERR_INPUT_PARAMS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pRsp == nullptr) {
|
||||||
|
SPDLOG_ERROR(TEXT("Input ProtocolResponse<T2> *pRsp params error"));
|
||||||
|
return -ERR_INPUT_PARAMS;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = CreateProtocolRequest(pReq, &pJson);
|
||||||
|
|
||||||
|
if (ret != ERR_SUCCESS) {
|
||||||
|
if (pJson) {
|
||||||
|
free(pJson);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
StringCbPrintf(hashBuf,
|
||||||
|
1024,
|
||||||
|
TEXT("%s|%s|%s|%s"),
|
||||||
|
GetGlobalCfgInfo()->clientId,
|
||||||
|
GetGlobalCfgInfo()->clientSecret,
|
||||||
|
timestamp.c_str(),
|
||||||
|
pJson);
|
||||||
|
|
||||||
|
if (lstrlen(GetGlobalCfgInfo()->clientSecret) > 0 &&
|
||||||
|
CalcHmacHash(HASH_SHA256,
|
||||||
|
reinterpret_cast<PUCHAR>(hashBuf),
|
||||||
|
lstrlen(hashBuf),
|
||||||
|
reinterpret_cast<PUCHAR>(GetGlobalCfgInfo()->clientSecret),
|
||||||
|
lstrlen(GetGlobalCfgInfo()->clientSecret),
|
||||||
|
hashValeu,
|
||||||
|
true) == ERR_SUCCESS) {
|
||||||
|
|
||||||
|
if (lstrcmp(typeid(T1).name(), TEXT("class PlatformReqClientCfgParms")) == 0) {
|
||||||
|
const auto *p = reinterpret_cast<PlatformReqClientCfgParms *>(pReq);
|
||||||
|
const httplib::Headers headers = {
|
||||||
|
{"gzs-client-id", GetGlobalCfgInfo()->clientId},
|
||||||
|
{"gzs-sign", hashValeu },
|
||||||
|
{"gzs-timestamp", timestamp },
|
||||||
|
{"gzs-userid", p->token.c_str() },
|
||||||
|
};
|
||||||
|
|
||||||
|
res = g_httpCtx->Post(pUrlPath, headers, pJson, HTTP_JSON_CONTENT);
|
||||||
|
} else {
|
||||||
|
const httplib::Headers headers = {
|
||||||
|
{"gzs-client-id", GetGlobalCfgInfo()->clientId},
|
||||||
|
{"gzs-sign", hashValeu },
|
||||||
|
{"gzs-timestamp", timestamp },
|
||||||
|
};
|
||||||
|
|
||||||
|
res = g_httpCtx->Post(pUrlPath, headers, pJson, HTTP_JSON_CONTENT);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (lstrcmp(typeid(T1).name(), TEXT("class PlatformReqClientCfgParms")) == 0) {
|
||||||
|
const auto *p = reinterpret_cast<PlatformReqClientCfgParms *>(pReq);
|
||||||
|
const httplib::Headers headers = {
|
||||||
|
{"gzs-userid", p->token.c_str()},
|
||||||
|
};
|
||||||
|
res = g_httpCtx->Post(pUrlPath, headers, pJson, HTTP_JSON_CONTENT);
|
||||||
|
} else {
|
||||||
|
res = g_httpCtx->Post(pUrlPath, pJson, HTTP_JSON_CONTENT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (res.error() != httplib::Error::Success) {
|
||||||
|
SPDLOG_ERROR(TEXT("[{0}]:Post Data {1} error: {2}"), pUrlPath, pJson, httplib::to_string(res.error()));
|
||||||
|
free(pJson);
|
||||||
|
return -ERR_HTTP_POST_DATA;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (res->status != 200) {
|
||||||
|
SPDLOG_ERROR(TEXT("[{0}]:Post Data {1} server return HTTP error: {2}"), pUrlPath, pJson, res->status);
|
||||||
|
free(pJson);
|
||||||
|
return -ERR_HTTP_SERVER_RSP;
|
||||||
|
}
|
||||||
|
|
||||||
|
SPDLOG_DEBUG(TEXT("+++++ Http Request {0}\n---- Http Response {1}"), pJson, res->body.c_str());
|
||||||
|
|
||||||
|
free(pJson);
|
||||||
|
|
||||||
|
if (lstrlen(res->body.c_str()) == 0) {
|
||||||
|
SPDLOG_ERROR(TEXT("Server response empty message"));
|
||||||
|
return -ERR_READ_FILE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (DecodeProtocolResponse(pRsp, res->body.c_str()) != ERR_SUCCESS) {
|
||||||
|
SPDLOG_ERROR(TEXT("Decode JSON {0} to ProtocolResponse<{1}> error"), res->body, typeid(T2).name());
|
||||||
|
return -ERR_JSON_DECODE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ERR_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
template int ProtolPostMessage(const TCHAR *pUrlPath,
|
template int ProtolPostMessage(const TCHAR *pUrlPath,
|
||||||
ProtocolRequest<ReqGetUserCfgParams> *pReq,
|
ProtocolRequest<ReqGetUserCfgParams> *pReq,
|
||||||
ProtocolResponse<RspUserSevrCfgParams> *pRsp,
|
ProtocolResponse<RspUserSevrCfgParams> *pRsp,
|
||||||
|
@ -242,4 +426,16 @@ template int ProtolPostMessage(const TCHAR *pUrlPath,
|
||||||
template int ProtolPostMessage(const TCHAR *pUrlPath,
|
template int ProtolPostMessage(const TCHAR *pUrlPath,
|
||||||
ProtocolRequest<ReqHeartParams> *pReq,
|
ProtocolRequest<ReqHeartParams> *pReq,
|
||||||
ProtocolResponse<RspHeartParams> *pRsp,
|
ProtocolResponse<RspHeartParams> *pRsp,
|
||||||
bool platformServer);
|
bool platformServer);
|
||||||
|
|
||||||
|
#if !USER_REAL_PLATFORM
|
||||||
|
template int PlatformProtolPostMessage(const TCHAR *pUrlPath,
|
||||||
|
PlatformReqServerCfgParms *pReq,
|
||||||
|
PlatformRspServerCfgParams *pRsp);
|
||||||
|
|
||||||
|
template int PlatformProtolPostMessage(const TCHAR *pUrlPath,
|
||||||
|
PlatformReqClientCfgParms *pReq,
|
||||||
|
PlatformRspClientCfgParams *pRsp);
|
||||||
|
|
||||||
|
//template int PlatformProtolGetMessage(const TCHAR *pUrlPath, PlatformRspUserClientCfgParams *pRsp);
|
||||||
|
#endif
|
|
@ -25,6 +25,15 @@
|
||||||
*/
|
*/
|
||||||
#define MAX_NETCARD_NAME (64)
|
#define MAX_NETCARD_NAME (64)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief SCG ·þÎñ ID
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
typedef enum {
|
||||||
|
WG_TUNNEL_SCG_ID = 3, ///< ËíµÀ·þÎñ
|
||||||
|
WG_CTRL_SCG_ID = 4 ///< ËíµÀ¿ØÖÆ·þÎñ
|
||||||
|
} SCG_SVR_ID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief ĐŇéźÓĂÜŔŕĐÍ
|
* @brief ĐŇéźÓĂÜŔŕĐÍ
|
||||||
*
|
*
|
||||||
|
|
|
@ -35,7 +35,7 @@ int InitializeWireGuardLibrary() {
|
||||||
TCHAR dllPath[MAX_PATH];
|
TCHAR dllPath[MAX_PATH];
|
||||||
|
|
||||||
StringCbPrintf(dllPath, MAX_PATH, TEXT("%s\\wireguard.dll"), GetGlobalCfgInfo()->workDirectory);
|
StringCbPrintf(dllPath, MAX_PATH, TEXT("%s\\wireguard.dll"), GetGlobalCfgInfo()->workDirectory);
|
||||||
if(!PathFileExists(dllPath)) {
|
if (!PathFileExists(dllPath)) {
|
||||||
SPDLOG_ERROR(TEXT("WireGuard DLL Not Found: {0}"), dllPath);
|
SPDLOG_ERROR(TEXT("WireGuard DLL Not Found: {0}"), dllPath);
|
||||||
return -ERR_ITEM_UNEXISTS;
|
return -ERR_ITEM_UNEXISTS;
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,7 @@ int GetWireGuradTunnelInfo(const TCHAR *pTunnelName) {
|
||||||
SPDLOG_ERROR("Failed to get configuration: {0}", GetLastError());
|
SPDLOG_ERROR("Failed to get configuration: {0}", GetLastError());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ERR_SUCCESS;
|
return ERR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -141,6 +141,7 @@ int TunnelSDKInitEnv(const TCHAR *pWorkDir,
|
||||||
|
|
||||||
StringCbCat(g_globalConfig.configDirectory, MAX_PATH, "\\NetTunnel");
|
StringCbCat(g_globalConfig.configDirectory, MAX_PATH, "\\NetTunnel");
|
||||||
SPDLOG_DEBUG(TEXT("Configure directory: {0}."), g_globalConfig.configDirectory);
|
SPDLOG_DEBUG(TEXT("Configure directory: {0}."), g_globalConfig.configDirectory);
|
||||||
|
SPDLOG_DEBUG(TEXT("Platform Server: {}, Work Module: {}"), pSvrUrl, isWorkServer? TEXT("SERVER") : TEXT("Client"));
|
||||||
|
|
||||||
// 如果配置目录不存在则自动创建
|
// 如果配置目录不存在则自动创建
|
||||||
if (!PathFileExists(g_globalConfig.configDirectory)) {
|
if (!PathFileExists(g_globalConfig.configDirectory)) {
|
||||||
|
@ -169,7 +170,7 @@ int TunnelSDKInitEnv(const TCHAR *pWorkDir,
|
||||||
return -ERR_ITEM_UNEXISTS;
|
return -ERR_ITEM_UNEXISTS;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return ERR_SUCCESS;
|
return ERR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ int GetWireGuardWorkMode(bool *pIsWorkServer) {
|
||||||
|
|
||||||
int WireGuardInstallDefaultServerService(bool bInstall) {
|
int WireGuardInstallDefaultServerService(bool bInstall) {
|
||||||
TCHAR cfgVal[MAX_PATH];
|
TCHAR cfgVal[MAX_PATH];
|
||||||
|
|
||||||
GetPrivateProfileString(CFG_WIREGUARD_SECTION,
|
GetPrivateProfileString(CFG_WIREGUARD_SECTION,
|
||||||
CFG_WGCFG_PATH,
|
CFG_WGCFG_PATH,
|
||||||
TEXT(""),
|
TEXT(""),
|
||||||
|
@ -51,7 +51,7 @@ int WireGuardInstallDefaultServerService(bool bInstall) {
|
||||||
StringCbCopy(svrName, MAX_PATH, cfgVal);
|
StringCbCopy(svrName, MAX_PATH, cfgVal);
|
||||||
PathStripPath(svrName);
|
PathStripPath(svrName);
|
||||||
PathRemoveExtension(svrName);
|
PathRemoveExtension(svrName);
|
||||||
|
|
||||||
if (bInstall) {
|
if (bInstall) {
|
||||||
ret = WireGuardInstallServerService(cfgVal); //CreateWireGuardService(svrName, cfgVal);
|
ret = WireGuardInstallServerService(cfgVal); //CreateWireGuardService(svrName, cfgVal);
|
||||||
} else {
|
} else {
|
||||||
|
@ -103,14 +103,14 @@ int WireGuardInstallServerService(const TCHAR *pTunnelCfgPath) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int WireGuardUnInstallServerService(const TCHAR *pTunnelName) {
|
int WireGuardUnInstallServerService(const TCHAR *pTunnelName) {
|
||||||
// 卸载服务
|
// 卸载服务
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (pTunnelName == nullptr || lstrlen(pTunnelName) == 0) {
|
if (pTunnelName == nullptr || lstrlen(pTunnelName) == 0) {
|
||||||
SPDLOG_ERROR(TEXT("Input pTunnelName params error"));
|
SPDLOG_ERROR(TEXT("Input pTunnelName params error"));
|
||||||
return -ERR_INPUT_PARAMS;
|
return -ERR_INPUT_PARAMS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ret = RemoveGuardService(pTunnelName, true)) != ERR_SUCCESS) {
|
if ((ret = RemoveGuardService(pTunnelName, true)) != ERR_SUCCESS) {
|
||||||
SPDLOG_ERROR(TEXT("Stop WireGuard Service Error: {0}"), ret);
|
SPDLOG_ERROR(TEXT("Stop WireGuard Service Error: {0}"), ret);
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -8,8 +8,9 @@
|
||||||
int main() {
|
int main() {
|
||||||
PUSER_SERVER_CONFIG pSvrCfg;
|
PUSER_SERVER_CONFIG pSvrCfg;
|
||||||
int ret;
|
int ret;
|
||||||
|
//https://xajhuang.com:9276
|
||||||
if ((ret = TunnelSDKInitEnv(nullptr, "http://xajhuang.com:9276", nullptr, LOG_DEBUG, true)) != ERR_SUCCESS) {
|
//http://172.21.40.39:32549
|
||||||
|
if ((ret = TunnelSDKInitEnv(nullptr, "http://172.21.40.39:32549", nullptr, LOG_DEBUG, true)) != ERR_SUCCESS) {
|
||||||
wprintf(L"Init SCC SDK Error: %d\n", ret);
|
wprintf(L"Init SCC SDK Error: %d\n", ret);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,13 +14,13 @@ TEST_MODULE_INITIALIZE(ModuleInitialize) {
|
||||||
Logger::WriteMessage("In Module Initialize");
|
Logger::WriteMessage("In Module Initialize");
|
||||||
Assert::AreEqual(0,
|
Assert::AreEqual(0,
|
||||||
TunnelSDKInitEnv(path,
|
TunnelSDKInitEnv(path,
|
||||||
"http://xajhuang.com:9276",
|
"http://172.21.40.39:32549",
|
||||||
TEXT("C:\\Users\\HuangXin\\Documents\\development\\visual_studio\\tunnel_"
|
TEXT("C:\\Users\\HuangXin\\Documents\\development\\visual_studio\\tunnel_"
|
||||||
"windows\\NetTunnelApp\\bin\\Debug\\utest.log"),
|
"windows\\NetTunnelApp\\bin\\Debug\\utest.log"),
|
||||||
LOG_TRACE,
|
LOG_TRACE,
|
||||||
false));
|
false));
|
||||||
Assert::AreEqual(0, EnableVerifySignature(TEXT("123"), TEXT("123456")));
|
//Assert::AreEqual(0, EnableVerifySignature(TEXT("123"), TEXT("123456")));
|
||||||
Assert::AreEqual(0, EnableSCGProxy(true, TEXT("efc.xajhuang.com"), 10001));
|
//Assert::AreEqual(0, EnableSCGProxy(true, TEXT("efc.xajhuang.com"), 10001));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_MODULE_CLEANUP(ModuleCleanup) {
|
TEST_MODULE_CLEANUP(ModuleCleanup) {
|
||||||
|
@ -194,7 +194,7 @@ public:
|
||||||
|
|
||||||
TEST_METHOD(TestUserLogin) {
|
TEST_METHOD(TestUserLogin) {
|
||||||
PUSER_CLIENT_CONFIG pCfg;
|
PUSER_CLIENT_CONFIG pCfg;
|
||||||
Assert::AreEqual(RET_OK, GetUserClientConfigure(TEXT("admin"), TEXT("123455"), &pCfg));
|
Assert::AreEqual(RET_OK, GetUserClientConfigure(TEXT("admin"), TEXT("1689189114026041344"), &pCfg));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_METHOD(TestClientProgress) {
|
TEST_METHOD(TestClientProgress) {
|
||||||
|
@ -209,13 +209,13 @@ public:
|
||||||
//EnableSCGProxy(true, 10000);
|
//EnableSCGProxy(true, 10000);
|
||||||
|
|
||||||
//Sleep(30 * 1000);
|
//Sleep(30 * 1000);
|
||||||
Assert::AreEqual(RET_OK, RemoteWireGuardControl(false));
|
|
||||||
Assert::AreEqual(RET_OK, LocalWireGuardControl(false, false));
|
Assert::AreEqual(RET_OK, LocalWireGuardControl(false, false));
|
||||||
|
Assert::AreEqual(RET_OK, RemoteWireGuardControl(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_METHOD(TestClientProgressFree) {
|
TEST_METHOD(TestClientProgressFree) {
|
||||||
Assert::AreEqual(RET_OK, RemoteWireGuardControl(false));
|
|
||||||
Assert::AreEqual(RET_OK, LocalWireGuardControl(false, false));
|
Assert::AreEqual(RET_OK, LocalWireGuardControl(false, false));
|
||||||
|
Assert::AreEqual(RET_OK, RemoteWireGuardControl(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_METHOD(TestGetSDKErrorMessage) {
|
TEST_METHOD(TestGetSDKErrorMessage) {
|
||||||
|
|
Loading…
Reference in New Issue