OCT 1. 支持32位操作系统
This commit is contained in:
parent
b7f98fcdd6
commit
ba79f478ed
|
@ -31,7 +31,7 @@
|
|||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
|
@ -72,6 +72,10 @@
|
|||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<IntDir>$(Platform)\$(Configuration)\</IntDir>
|
||||
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
|
@ -80,12 +84,29 @@
|
|||
<ConformanceMode>true</ConformanceMode>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<AdditionalIncludeDirectories>.\depends\WinDivert\include;.\include;.\depends\WireGuardNT\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableUAC>false</EnableUAC>
|
||||
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>copy /y $(ProjectDir)depends\tunnel\x86\tunnel.dll $(TargetDir)
|
||||
copy /y $(ProjectDir)depends\WireGuardNT\amd64\wireguard.dll $(TargetDir)
|
||||
copy /y $(TargetDir)fmtd.dll $(SolutionDir)NetTunnelApp\bin\$(ConfigurationName)\
|
||||
copy /y $(TargetDir)NetTunnelSDK.dll $(SolutionDir)NetTunnelApp\bin\$(ConfigurationName)\
|
||||
copy /y $(ProjectDir)include\sccsdk.h $(ProjectDir)sdk\
|
||||
copy /y $(ProjectDir)include\common.h $(ProjectDir)sdk\
|
||||
copy /y $(ProjectDir)include\usrerr.h $(ProjectDir)sdk\
|
||||
$(ProjectDir)scripts\gensdk.bat</Command>
|
||||
</PostBuildEvent>
|
||||
<PreBuildEvent>
|
||||
<Command>$(ProjectDir)scripts\cleansdk.bat</Command>
|
||||
</PreBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
|
|
|
@ -438,13 +438,17 @@ int GetUserServerConfigure(const TCHAR *pUserName, const TCHAR *pToken, PUSER_SE
|
|||
return -ERR_INPUT_PARAMS;
|
||||
}
|
||||
|
||||
if (pUserName && lstrlen(pUserName) > 0) {
|
||||
memset(pUser->userName, 0, MAX_PATH);
|
||||
memset(pUser->userName, 0, MAX_PATH);
|
||||
|
||||
#if 0
|
||||
if (pUserName && lstrlen(pUserName) > 0) {
|
||||
StringCbCopy(pUser->userName, MAX_PATH, pUserName);
|
||||
} else {
|
||||
StringCbCopy(pUser->userName, MAX_PATH, TEXT("tunnel_svr"));
|
||||
}
|
||||
|
||||
#else
|
||||
StringCbCopy(pUser->userName, MAX_PATH, TEXT("tunnel_scc"));
|
||||
#endif
|
||||
StringCbCopy(pUser->userToken, MAX_PATH, pToken);
|
||||
|
||||
#if USER_REAL_PLATFORM
|
||||
|
@ -525,9 +529,13 @@ int GetUserClientConfigure(const TCHAR *pUserName, const TCHAR *pToken, PUSER_CL
|
|||
}
|
||||
|
||||
memset(pUser->userName, 0, MAX_PATH);
|
||||
#if 0
|
||||
if (pUserName && lstrlen(pUserName) > 0) {
|
||||
StringCbCopy(pUser->userName, MAX_PATH, pUserName);
|
||||
}
|
||||
#else
|
||||
StringCbCopy(pUser->userName, MAX_PATH, TEXT("tunnel_scc"));
|
||||
#endif
|
||||
StringCbCopy(pUser->userToken, MAX_PATH, pToken);
|
||||
|
||||
#if USER_REAL_PLATFORM
|
||||
|
|
|
@ -364,7 +364,7 @@ public:
|
|||
std::map<std::string, std::string> GetMembersValueMap(const std::string valueStr) {
|
||||
std::vector<std::string> array = StringSplit(valueStr);
|
||||
std::map<std::string, std::string> ret;
|
||||
for (int i = 0; i < array.size(); i++) {
|
||||
for (unsigned int i = 0; i < array.size(); i++) {
|
||||
std::vector<std::string> keyValue = StringSplit(array[i], '=');
|
||||
if (keyValue.size() != 2) {
|
||||
continue;
|
||||
|
|
|
@ -271,7 +271,7 @@ int GetWindowsServiceStatus(const TCHAR *pSvrName, PDWORD pStatus) {
|
|||
|
||||
int WideCharToTChar(const WCHAR *pWStr, TCHAR *pOutStr, int maxOutLen) {
|
||||
if constexpr (sizeof(TCHAR) == sizeof(WCHAR)) {
|
||||
if (wcslen(pWStr) * sizeof(WCHAR) >= maxOutLen) {
|
||||
if (wcslen(pWStr) * sizeof(WCHAR) >= static_cast<unsigned int>(maxOutLen)) {
|
||||
SPDLOG_ERROR(TEXT("Output buffer is to short: {0} need {1}"), maxOutLen, wcslen(pWStr) * sizeof(WCHAR));
|
||||
return -ERR_INPUT_PARAMS;
|
||||
}
|
||||
|
@ -293,7 +293,7 @@ int WideCharToTChar(const WCHAR *pWStr, TCHAR *pOutStr, int maxOutLen) {
|
|||
|
||||
int TCharToWideChar(const TCHAR *pTStr, WCHAR *pOutStr, int maxOutLen) {
|
||||
if constexpr (sizeof(TCHAR) == sizeof(WCHAR)) {
|
||||
if (lstrlen(pTStr) * sizeof(WCHAR) >= maxOutLen) {
|
||||
if (lstrlen(pTStr) * sizeof(WCHAR) >= static_cast<unsigned int>(maxOutLen)) {
|
||||
SPDLOG_ERROR(TEXT("Output buffer is to short: {0} need {1}"), maxOutLen, lstrlen(pTStr) * sizeof(WCHAR));
|
||||
return -ERR_INPUT_PARAMS;
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#include <spdlog/fmt/bin_to_hex.h>
|
||||
#include <array>
|
||||
|
||||
#define SCG_UDP_HEAD_SIZE (13)
|
||||
#define SCG_UDP_HEAD_SIZE (14)
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -42,7 +42,7 @@ void StopUDPProxyServer() {
|
|||
}
|
||||
|
||||
#if !USED_PORTMAP_TUNNEL
|
||||
static DWORD UDPProxvRemoteThread(LPVOID lpParameter) {
|
||||
static DWORD WINAPI UDPProxvRemoteThread(LPVOID lpParameter) {
|
||||
const auto pPeerSock = static_cast<sockaddr_in *>(lpParameter);
|
||||
const PSCG_PROXY_INFO pProxy = &GetGlobalCfgInfo()->scgProxy;
|
||||
|
||||
|
@ -104,7 +104,7 @@ static DWORD UDPProxvRemoteThread(LPVOID lpParameter) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static DWORD UDPProxyRecvThread(LPVOID lpParameter) {
|
||||
static DWORD WINAPI UDPProxyRecvThread(LPVOID lpParameter) {
|
||||
bool isRemoteInit = false;
|
||||
sockaddr_in localWgAddr {};
|
||||
sockaddr_in scgAddr {};
|
||||
|
@ -121,19 +121,21 @@ static DWORD UDPProxyRecvThread(LPVOID lpParameter) {
|
|||
InetPton(AF_INET, pProxy->scgIpAddr, &scgAddr.sin_addr.s_addr);
|
||||
|
||||
// 构建 SCG UDP 包头
|
||||
recvBuf[0] = 0x01; // VERSION
|
||||
recvBuf[1] = 0x0A; // Length 0
|
||||
recvBuf[2] = 0x09; // Length 1
|
||||
recvBuf[3] = 0xF0; // ++++++ INFO[0] TYPE
|
||||
recvBuf[4] = 0x04; // INFO[0] LENGTH
|
||||
recvBuf[5] = 0; // INFO[0] VMID[0]
|
||||
recvBuf[6] = 0; // INFO[0] VMID[1]
|
||||
recvBuf[7] = 0; // INFO[0] VMID[2]
|
||||
recvBuf[8] = 0; // INFO[0] VMID[3]
|
||||
recvBuf[9] = 0xF1; // INFO[1] TYPE
|
||||
recvBuf[10] = 0x00; // INFO[1] LENGTH 0
|
||||
recvBuf[11] = 0x01; // INFO[1] LENGTH 1
|
||||
recvBuf[12] = svrId; // ------ INFO[1] SCG Service ID
|
||||
recvBuf[0] = 0x01; // VERSION
|
||||
recvBuf[1] = 0x00; // Length 0
|
||||
recvBuf[2] = SCG_UDP_HEAD_SIZE - 3; // Length 1
|
||||
recvBuf[3] = 0xF0; // ++++++ INFO[0] TYPE
|
||||
recvBuf[4] = 0x00; // INFO[0] LENGTH 0
|
||||
recvBuf[5] = 0x04; // INFO[0] LENGTH 1
|
||||
recvBuf[6] = 0; // INFO[0] VMID[0]
|
||||
recvBuf[7] = 0; // INFO[0] VMID[1]
|
||||
recvBuf[8] = 0; // INFO[0] VMID[2]
|
||||
recvBuf[9] = 0; // INFO[0] VMID[3]
|
||||
recvBuf[10] = 0xF1; // INFO[1] TYPE
|
||||
recvBuf[11] = 0x00; // INFO[1] LENGTH 0
|
||||
recvBuf[12] = 0x01; // INFO[1] LENGTH 1
|
||||
recvBuf[13] = svrId; // ------ INFO[1] SCG Service ID
|
||||
|
||||
|
||||
pProxy->exitNow = false;
|
||||
while (!pProxy->exitNow) {
|
||||
|
@ -196,10 +198,10 @@ static DWORD UDPProxyRecvThread(LPVOID lpParameter) {
|
|||
pProxy->hProxySCGThread = handle;
|
||||
}
|
||||
|
||||
recvBuf[5] = vmid[0]; // INFO[0] VMID[0]
|
||||
recvBuf[6] = vmid[1]; // INFO[0] VMID[1]
|
||||
recvBuf[7] = vmid[2]; // INFO[0] VMID[2]
|
||||
recvBuf[8] = vmid[3]; // INFO[0] VMID[3]
|
||||
recvBuf[6] = vmid[0]; // INFO[0] VMID[0]
|
||||
recvBuf[7] = vmid[1]; // INFO[0] VMID[1]
|
||||
recvBuf[8] = vmid[2]; // INFO[0] VMID[2]
|
||||
recvBuf[9] = vmid[3]; // INFO[0] VMID[3]
|
||||
|
||||
// 增加SCG包头数据长度
|
||||
iRecvBytes += SCG_UDP_HEAD_SIZE;
|
||||
|
|
|
@ -48,9 +48,10 @@ int InitControlServer(const TCHAR *pUserSvrUrl) {
|
|||
const auto svrId = static_cast<UINT8>(GetGlobalCfgInfo()->userCfg.cliConfig.scgCtrlAppId);
|
||||
unsigned char scgProxy[] = {0x01, // VERSION
|
||||
0x00, // Length 0
|
||||
0x0A, // Length 1
|
||||
0x0B, // Length 1
|
||||
0xF0, // ++++++ INFO[0] TYPE
|
||||
0x04, // INFO[0] LENGTH
|
||||
0x00, // INFO[0] LENGTH 0
|
||||
0x04, // INFO[0] LENGTH 1
|
||||
0, // INFO[0] VMID[0]
|
||||
0, // INFO[0] VMID[1]
|
||||
0, // INFO[0] VMID[2]
|
||||
|
@ -61,10 +62,10 @@ int InitControlServer(const TCHAR *pUserSvrUrl) {
|
|||
svrId}; // ------ INFO[1] SCG Service ID
|
||||
p = scgProxy;
|
||||
memcpy(vmid, &id, 4);
|
||||
scgProxy[5] = vmid[0];
|
||||
scgProxy[6] = vmid[1];
|
||||
scgProxy[7] = vmid[2];
|
||||
scgProxy[8] = vmid[3];
|
||||
scgProxy[6] = vmid[0];
|
||||
scgProxy[7] = vmid[1];
|
||||
scgProxy[8] = vmid[2];
|
||||
scgProxy[9] = vmid[3];
|
||||
|
||||
if (GetGlobalCfgInfo()->logLevel == spdlog::level::trace) {
|
||||
std::array<unsigned char, sizeof(scgProxy)> arr;
|
||||
|
|
|
@ -79,10 +79,15 @@
|
|||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)NetTunnelSDK\sdk;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)$(Platform)\$(Configuration)\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>NetTunnelSDK.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<UACExecutionLevel>RequireAdministrator</UACExecutionLevel>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
|
|
Loading…
Reference in New Issue