From 2d9da7b21586caf9ffc472bf453875acd8d916bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E6=98=95?= Date: Mon, 21 Aug 2023 09:22:52 +0800 Subject: [PATCH] =?UTF-8?q?OCT=201.=20=E8=8E=B7=E5=8F=96=E7=BD=91=E5=8D=A1?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E5=A2=9E=E5=8A=A0=E7=BD=91=E5=8D=A1=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E5=AD=97=E6=AE=B5=202.=20=E9=9A=A7=E9=81=93=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E7=AB=AF=E5=8F=A3=E6=98=A0=E5=B0=84=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=EF=BC=8C=E4=BB=A5=E5=8F=8A=E9=85=8D=E7=BD=AE=E5=8D=8F=E8=AE=AE?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E9=9C=80=E6=B1=82=203.=20=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=8C=89=E5=A4=A9=E5=88=86=E5=89=B2=E6=96=87?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- NetTunnelApp/NetTunnelLib.cs | 2 ++ NetTunnelSDK/UserManager.cpp | 2 +- NetTunnelSDK/include/common.h | 34 ++++++++++++++++++++----- NetTunnelSDK/include/network.h | 3 ++- NetTunnelSDK/include/sccsdk.h | 17 +++++++------ NetTunnelSDK/network/ProxyService.cpp | 14 ++++++++--- NetTunnelSDK/network/network.cpp | 17 +++++++++---- NetTunnelSDK/protocol/protocol.cpp | 22 ++++++++-------- NetTunnelSDK/sdk/common.h | 36 +++++++++++++++++++++------ NetTunnelSDK/sdk/sccsdk.h | 17 +++++++------ NetTunnelSDK/tunnel/tunnel.cpp | 1 + TestNetTunnelSDK/TestNetTunnelSDK.cpp | 33 ++++++++++++++++-------- 12 files changed, 138 insertions(+), 60 deletions(-) diff --git a/NetTunnelApp/NetTunnelLib.cs b/NetTunnelApp/NetTunnelLib.cs index 40fc68d..903861c 100644 --- a/NetTunnelApp/NetTunnelLib.cs +++ b/NetTunnelApp/NetTunnelLib.cs @@ -104,6 +104,8 @@ public struct NetCard { public int IfIndex; + public int netConnStatus; + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)] public string UUID; diff --git a/NetTunnelSDK/UserManager.cpp b/NetTunnelSDK/UserManager.cpp index ecda78c..f66e933 100644 --- a/NetTunnelSDK/UserManager.cpp +++ b/NetTunnelSDK/UserManager.cpp @@ -598,7 +598,7 @@ int GetUserClientConfigure(const TCHAR *pUserName, const TCHAR *pToken, PUSER_CL //StringCbCopy(pVm->scgGateWay, MAX_PATH, vm.scgGateway.c_str()); StringCbPrintf(pVm->scgGateWay, MAX_PATH, TEXT("http://%s:%d"), vm.scgIp.c_str(), vm.scgPort); #if USED_PORTMAP_TUNNEL - StringCbPrintf(pVm->scgTunnelGw, MAX_PATH, TEXT("%s:%d"), vm.portMapIp.c_str(), vm.portMapPort - 1); + StringCbPrintf(pVm->scgTunnelGw, MAX_PATH, TEXT("%s:%d"), vm.portMapIp.c_str(), vm.portMapPort); #else StringCbPrintf(pVm->scgTunnelGw, MAX_PATH, TEXT("%s:%d"), vm.scgIp.c_str(), vm.scgPort - 1); #endif diff --git a/NetTunnelSDK/include/common.h b/NetTunnelSDK/include/common.h index 41f00d0..387c1dc 100644 --- a/NetTunnelSDK/include/common.h +++ b/NetTunnelSDK/include/common.h @@ -1,31 +1,30 @@ #pragma once #define USED_PORTMAP_TUNNEL (1) - /** * @brief WireGuard key 最大长度 */ -#define WG_KEY_MAX (64) +#define WG_KEY_MAX (64) /** * @brief 操作系统最大网卡数 */ -#define NET_CARD_MAX (32) +#define NET_CARD_MAX (32) /** * @brief IP 字符串最大长度(支持IPv6) */ -#define MAX_IP_LEN (48) +#define MAX_IP_LEN (48) /** * @brief IP 字符串最小长度 */ -#define MIN_IP_LEN (7) +#define MIN_IP_LEN (7) /** * @brief 网卡名称字符串最大长度(支持IPv6) */ -#define MAX_NETCARD_NAME (64) +#define MAX_NETCARD_NAME (64) /** * @brief SCG 服务 ID @@ -49,6 +48,29 @@ typedef enum { CRYPTO_MAX, } PROTO_CRYPTO_TYPE; +/** + * @brief 网络连接状态 + * + */ +typedef enum { + STATUS_DISCONNECTED = 0, ///< 连接已断开连接 + STATUS_CONNECTING, ///< 连接正在进行连接 + STATUS_CONNECTED, ///< 连接处于连接状态 + STATUS_DISCONNECTING, ///< 连接正在断开连接 + STATUS_HARDWARE_NOT_PRESENT, ///< 连接的硬件(例如网络接口卡 (NIC) )不存在 + STATUS_HARDWARE_DISABLED, ///< 连接的硬件存在,但未启用 + STATUS_HARDWARE_MALFUNCTION, ///< 连接的硬件中发生了故障 + STATUS_MEDIA_DISCONNECTED, ///< 媒体(例如网络电缆)断开连接 + STATUS_AUTHENTICATING, ///< 连接正在等待身份验证发生 + STATUS_AUTHENTICATION_SUCCEEDED, ///< 身份验证在此连接上成功 + STATUS_AUTHENTICATION_FAILED, ///< 此连接上身份验证失败 + STATUS_INVALID_ADDRESS, ///< 地址无效 + STATUS_CREDENTIALS_REQUIRED, ///< 需要安全凭据 + STATUS_ACTION_REQUIRED, ///< 连接需要其它动作 + STATUS_ACTION_REQUIRED_RETRY, ///< 重试连接其它动作 + STATUS_CONNECT_FAILED, ///< 连接失败 +} NET_CONNECT_STATUS; + /** * @brief 日志等级 * diff --git a/NetTunnelSDK/include/network.h b/NetTunnelSDK/include/network.h index 1d10d5e..1d8e3a6 100644 --- a/NetTunnelSDK/include/network.h +++ b/NetTunnelSDK/include/network.h @@ -24,6 +24,7 @@ int GetInterfaceIfIndexByIpAddr(const TCHAR *pIpAddr, ULONG *pIfIndex); * @brief 根据网卡 GUDI 获取网卡名称 * @param[in] pGUID 网卡 GUID * @param[out] ifName 网卡名称 + * @param[out] pConnStatus 网卡连接状态 * @return 函数执行结果 0: 成功, 小于0 失败 @see USER_ERRNO * - -ERR_INPUT_PARAMS 输入参数错误 * - -ERR_MALLOC_MEMORY 分配内存失败 @@ -32,7 +33,7 @@ int GetInterfaceIfIndexByIpAddr(const TCHAR *pIpAddr, ULONG *pIfIndex); * - -ERR_ITEM_UNEXISTS GUID 不存在 * - ERR_SUCCESS 成功 */ -int GetInterfaceNameByGUID(const TCHAR *pGUID, TCHAR ifName[MAX_NETCARD_NAME]); +int GetInterfaceNameByGUID(const TCHAR *pGUID, TCHAR ifName[MAX_NETCARD_NAME], int* pConnStatus); /** * @brief 根据网卡名获取网卡索引 diff --git a/NetTunnelSDK/include/sccsdk.h b/NetTunnelSDK/include/sccsdk.h index fb0af36..d4fcef3 100644 --- a/NetTunnelSDK/include/sccsdk.h +++ b/NetTunnelSDK/include/sccsdk.h @@ -17,14 +17,15 @@ typedef PTUNNEL_HEART_ROUTINE LPTUNNEL_HEART_ROUTINE; * @brief 本地计算机网卡信息 */ typedef struct { - int InterfaceIndex; ///< 网卡索引 - TCHAR NetCardUUID[260]; ///< 网卡名称, Windows标识为 UUID - TCHAR NetCardName[MAX_NETCARD_NAME]; ///< 网卡名称 - TCHAR NetCardDescription[132]; ///< 网卡描述 - TCHAR NetCardIpaddr[MAX_IP_LEN]; ///< 网卡 IP 地址 - TCHAR NetCardNetmask[MAX_IP_LEN]; ///< 网卡子网掩码 - TCHAR NetCardGateway[MAX_IP_LEN]; ///< 网卡网关 - TCHAR NetCardMacAddr[20]; ///< 网卡 MAC 地址 + int InterfaceIndex; ///< 网卡索引 + NET_CONNECT_STATUS netConnStatus; ///< 网卡状态 @see NET_CONNECT_STATUS + TCHAR NetCardUUID[260]; ///< 网卡名称, Windows标识为 UUID + TCHAR NetCardName[MAX_NETCARD_NAME]; ///< 网卡名称 + TCHAR NetCardDescription[132]; ///< 网卡描述 + TCHAR NetCardIpaddr[MAX_IP_LEN]; ///< 网卡 IP 地址 + TCHAR NetCardNetmask[MAX_IP_LEN]; ///< 网卡子网掩码 + TCHAR NetCardGateway[MAX_IP_LEN]; ///< 网卡网关 + TCHAR NetCardMacAddr[20]; ///< 网卡 MAC 地址 } NIC_CONTENT, *PNIC_CONTENT; #ifdef __cplusplus // If used by C++ code, diff --git a/NetTunnelSDK/network/ProxyService.cpp b/NetTunnelSDK/network/ProxyService.cpp index f8efa37..c81990d 100644 --- a/NetTunnelSDK/network/ProxyService.cpp +++ b/NetTunnelSDK/network/ProxyService.cpp @@ -2,17 +2,22 @@ #include #include -#include "globalcfg.h" #include "usrerr.h" #include "misc.h" +#if !USED_PORTMAP_TUNNEL +#include "globalcfg.h" #include #include #include #define SCG_UDP_HEAD_SIZE (11) +#endif + + void StopUDPProxyServer() { +#if !USED_PORTMAP_TUNNEL const PSCG_PROXY_INFO pProxy = &GetGlobalCfgInfo()->scgProxy; pProxy->exitNow = true; @@ -31,8 +36,10 @@ void StopUDPProxyServer() { closesocket(pProxy->scgGwSock); } +#endif } +#if !USED_PORTMAP_TUNNEL static DWORD UDPProxvRemoteThread(LPVOID lpParameter) { const auto pPeerSock = static_cast(lpParameter); const PSCG_PROXY_INFO pProxy = &GetGlobalCfgInfo()->scgProxy; @@ -207,8 +214,9 @@ static DWORD UDPProxyRecvThread(LPVOID lpParameter) { } return 0; } - +#endif int CreateUDPProxyServer() { +#if !USED_PORTMAP_TUNNEL HANDLE handle; int ret; int addrSize = sizeof(sockaddr_in); @@ -272,6 +280,6 @@ int CreateUDPProxyServer() { } pProxy->hProxyTunnelThread = handle; - +#endif return ERR_SUCCESS; } \ No newline at end of file diff --git a/NetTunnelSDK/network/network.cpp b/NetTunnelSDK/network/network.cpp index c564d6c..8dd9254 100644 --- a/NetTunnelSDK/network/network.cpp +++ b/NetTunnelSDK/network/network.cpp @@ -140,7 +140,7 @@ int GetInterfaceIfIndexByGUID(const TCHAR *pGUID, int *pIfIndex) { return -ERR_ITEM_UNEXISTS; } -int GetInterfaceNameByGUID(const TCHAR *pGUID, TCHAR ifName[MAX_NETCARD_NAME]) { +int GetInterfaceNameByGUID(const TCHAR *pGUID, TCHAR ifName[MAX_NETCARD_NAME], int *pConnStatus) { VARIANT v; INetConnection *pNC = nullptr; IEnumVARIANT *pEV = nullptr; @@ -245,6 +245,9 @@ int GetInterfaceNameByGUID(const TCHAR *pGUID, TCHAR ifName[MAX_NETCARD_NAME]) { return ret; } + if (pConnStatus) { + *pConnStatus = pNP->Status; + } return ERR_SUCCESS; } } @@ -425,7 +428,7 @@ int GetInterfaceIfIndexByName(const TCHAR *pInterfaceName, int *pIfIndex) { PIP_ADAPTER_INFO pAdapter = pAdapterInfo; while (pAdapter) { TCHAR NetCardName[MAX_NETCARD_NAME] = {}; - GetInterfaceNameByGUID(pAdapter->AdapterName, NetCardName); + GetInterfaceNameByGUID(pAdapter->AdapterName, NetCardName, nullptr); if (StrCmp(pInterfaceName, NetCardName) == 0) { *pIfIndex = static_cast(pAdapter->Index); @@ -485,7 +488,7 @@ int GetInterfaceGUIDByName(const TCHAR *pInterfaceName, GUID *pGuid) { while (pAdapter) { int ret; TCHAR NetCardName[MAX_NETCARD_NAME] = {}; - GetInterfaceNameByGUID(pAdapter->AdapterName, NetCardName); + GetInterfaceNameByGUID(pAdapter->AdapterName, NetCardName, nullptr); if (StrCmp(pInterfaceName, NetCardName) == 0) { WCHAR strGuid[MAX_PATH]; @@ -632,7 +635,8 @@ int GetAllNICInfo(PNIC_CONTENT *pInfo, int *pItemCounts) { } if ((dwRetVal = GetAdaptersInfo(pAdapterInfo, &ulOutBufLen)) == NO_ERROR) { - int id = 0; + int id = 0; + int ncStatus; PIP_ADAPTER_INFO pAdapter = pAdapterInfo; while (pAdapter && id < NET_CARD_MAX) { // @@ -660,7 +664,10 @@ int GetAllNICInfo(PNIC_CONTENT *pInfo, int *pItemCounts) { pAdapter->Address[4], pAdapter->Address[5]); - GetInterfaceNameByGUID(pAdapter->AdapterName, g_NetAdapterInfo[id].NetCardName); + if (GetInterfaceNameByGUID(pAdapter->AdapterName, g_NetAdapterInfo[id].NetCardName, &ncStatus) == + ERR_SUCCESS) { + g_NetAdapterInfo[id].netConnStatus = static_cast(ncStatus); + } id++; pAdapter = pAdapter->Next; diff --git a/NetTunnelSDK/protocol/protocol.cpp b/NetTunnelSDK/protocol/protocol.cpp index 5a06151..10f6252 100644 --- a/NetTunnelSDK/protocol/protocol.cpp +++ b/NetTunnelSDK/protocol/protocol.cpp @@ -38,6 +38,7 @@ int InitControlServer(const TCHAR *pUserSvrUrl) { g_tunnelHttpCtx->set_connection_timeout(0, 1000000); // 1 second g_tunnelHttpCtx->set_read_timeout(5, 0); // 5 seconds g_tunnelHttpCtx->set_write_timeout(5, 0); // 5 seconds + g_tunnelHttpCtx->set_keep_alive(true); g_tunnelHttpCtx->set_post_connect_cb([](socket_t sock) { if (UsedSCGProxy()) { int ret; @@ -96,10 +97,11 @@ template int CreateProtocolRequest(T *pReqParams, TCHAR **pOutJson) { if (!g_httpCtx && lstrlen(GetGlobalCfgInfo()->platformServerUrl) > 0) { g_httpCtx = new httplib::Client(GetGlobalCfgInfo()->platformServerUrl); if (g_httpCtx) { - g_httpCtx->enable_server_certificate_verification(false); g_httpCtx->set_connection_timeout(0, 300000); // 300 milliseconds g_httpCtx->set_read_timeout(5, 0); // 5 seconds g_httpCtx->set_write_timeout(5, 0); // 5 seconds + g_httpCtx->set_keep_alive(true); + g_httpCtx->enable_server_certificate_verification(false); } } @@ -344,30 +346,30 @@ template int PlatformProtolPostMessage(const TCHAR *pUrlPath lstrlen(GetGlobalCfgInfo()->clientSecret), hashValeu, true) == ERR_SUCCESS) { - if (lstrcmp(typeid(T1).name(), TEXT("class PlatformReqClientCfgParms")) == 0) { + if (typeid(T1) == typeid(PlatformReqClientCfgParms)) { const auto *p = reinterpret_cast(pReq); const httplib::Headers headers = { - {"gzs-client-id", GetGlobalCfgInfo()->clientId}, + {"gzs-client-id", GetGlobalCfgInfo()->clientId }, {"gzs-sign", hashValeu }, - {"gzs-timestamp", timestamp }, - {"gzs-userid", p->token.c_str() }, + {"gzs-timestamp", timestamp }, + {"Authorization", ("Bearer " + 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-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) { + if (typeid(T1) == typeid(PlatformReqClientCfgParms)) { const auto *p = reinterpret_cast(pReq); const httplib::Headers headers = { - {"gzs-userid", p->token.c_str()}, + {"Authorization", ("Bearer " + p->token).c_str()}, }; res = g_httpCtx->Post(pUrlPath, headers, pJson, HTTP_JSON_CONTENT); } else { @@ -375,6 +377,8 @@ template int PlatformProtolPostMessage(const TCHAR *pUrlPath } } + SPDLOG_DEBUG(TEXT("+++++ Http Request {0}\n---- Http Response {1}"), pJson, res->body.c_str()); + if (res.error() != httplib::Error::Success) { SPDLOG_ERROR(TEXT("[{0}]:Post Data {1} error: {2}"), pUrlPath, pJson, httplib::to_string(res.error())); free(pJson); @@ -387,8 +391,6 @@ template int PlatformProtolPostMessage(const TCHAR *pUrlPath 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) { diff --git a/NetTunnelSDK/sdk/common.h b/NetTunnelSDK/sdk/common.h index 1a5a1b7..fc6331f 100644 --- a/NetTunnelSDK/sdk/common.h +++ b/NetTunnelSDK/sdk/common.h @@ -1,31 +1,30 @@ #pragma once -#define USED_PORTMAP_TUNNEL (1) - +#define USED_PORTMAP_TUNNEL (0) /** * @brief WireGuard key 󳤶 */ -#define WG_KEY_MAX (64) +#define WG_KEY_MAX (64) /** * @brief ϵͳ */ -#define NET_CARD_MAX (32) +#define NET_CARD_MAX (32) /** * @brief IP ַ󳤶(֧IPv6) */ -#define MAX_IP_LEN (48) +#define MAX_IP_LEN (48) /** * @brief IP ַС */ -#define MIN_IP_LEN (7) +#define MIN_IP_LEN (7) /** * @brief ַ󳤶(֧IPv6) */ -#define MAX_NETCARD_NAME (64) +#define MAX_NETCARD_NAME (64) /** * @brief SCG ID @@ -49,6 +48,29 @@ typedef enum { CRYPTO_MAX, } PROTO_CRYPTO_TYPE; +/** + * @brief ״̬ + * + */ +typedef enum { + STATUS_DISCONNECTED = 0, ///< ѶϿ + STATUS_CONNECTING, ///< ڽ + STATUS_CONNECTED, ///< Ӵ״̬ + STATUS_DISCONNECTING, ///< ڶϿ + STATUS_HARDWARE_NOT_PRESENT, ///< ӵӲӿڿ (NIC) + STATUS_HARDWARE_DISABLED, ///< ӵӲڣδ + STATUS_HARDWARE_MALFUNCTION, ///< ӵӲз˹ + STATUS_MEDIA_DISCONNECTED, ///< ý壨£Ͽ + STATUS_AUTHENTICATING, ///< ڵȴ֤ + STATUS_AUTHENTICATION_SUCCEEDED, ///< ֤ڴϳɹ + STATUS_AUTHENTICATION_FAILED, ///< ֤ʧ + STATUS_INVALID_ADDRESS, ///< ַЧ + STATUS_CREDENTIALS_REQUIRED, ///< Ҫȫƾ + STATUS_ACTION_REQUIRED, ///< Ҫ + STATUS_ACTION_REQUIRED_RETRY, ///< + STATUS_CONNECT_FAILED, ///< ʧ +} NET_CONNECT_STATUS; + /** * @brief ־ȼ * diff --git a/NetTunnelSDK/sdk/sccsdk.h b/NetTunnelSDK/sdk/sccsdk.h index 7fb51e4..e36634f 100644 --- a/NetTunnelSDK/sdk/sccsdk.h +++ b/NetTunnelSDK/sdk/sccsdk.h @@ -17,14 +17,15 @@ typedef PTUNNEL_HEART_ROUTINE LPTUNNEL_HEART_ROUTINE; * @brief ؼϢ */ typedef struct { - int InterfaceIndex; ///< - CHAR NetCardUUID[260]; ///< ƣ WindowsʶΪ UUID - CHAR NetCardName[MAX_NETCARD_NAME]; ///< - CHAR NetCardDescription[132]; ///< - CHAR NetCardIpaddr[MAX_IP_LEN]; ///< IP ַ - CHAR NetCardNetmask[MAX_IP_LEN]; ///< - CHAR NetCardGateway[MAX_IP_LEN]; ///< - CHAR NetCardMacAddr[20]; ///< MAC ַ + int InterfaceIndex; ///< + NET_CONNECT_STATUS netConnStatus; ///< ״̬ @see NET_CONNECT_STATUS + CHAR NetCardUUID[260]; ///< ƣ WindowsʶΪ UUID + CHAR NetCardName[MAX_NETCARD_NAME]; ///< + CHAR NetCardDescription[132]; ///< + CHAR NetCardIpaddr[MAX_IP_LEN]; ///< IP ַ + CHAR NetCardNetmask[MAX_IP_LEN]; ///< + CHAR NetCardGateway[MAX_IP_LEN]; ///< + CHAR NetCardMacAddr[20]; ///< MAC ַ } NIC_CONTENT, *PNIC_CONTENT; #ifdef __cplusplus // If used by C++ code, diff --git a/NetTunnelSDK/tunnel/tunnel.cpp b/NetTunnelSDK/tunnel/tunnel.cpp index 4f363bb..8bf54b7 100644 --- a/NetTunnelSDK/tunnel/tunnel.cpp +++ b/NetTunnelSDK/tunnel/tunnel.cpp @@ -67,6 +67,7 @@ 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)); + //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()); diff --git a/TestNetTunnelSDK/TestNetTunnelSDK.cpp b/TestNetTunnelSDK/TestNetTunnelSDK.cpp index 593dbcd..32637b6 100644 --- a/TestNetTunnelSDK/TestNetTunnelSDK.cpp +++ b/TestNetTunnelSDK/TestNetTunnelSDK.cpp @@ -2,7 +2,6 @@ #include "CppUnitTest.h" #include "sccsdk.h" - #include #include #include @@ -16,10 +15,10 @@ TEST_MODULE_INITIALIZE(ModuleInitialize) { const TCHAR *path = TEXT( "C:\\Users\\HuangXin\\Documents\\development\\visual_studio\\tunnel_windows\\NetTunnelApp\\bin\\Debug"); - Logger::WriteMessage("In Module Initialize\n"); + Logger::WriteMessage("In Module Initialize:\n"); Assert::AreEqual(0, TunnelSDKInitEnv(path, - "http://172.21.40.39:32549", + "https://112.17.28.201:1443", TEXT("C:\\Users\\HuangXin\\Documents\\development\\visual_studio\\tunnel_" "windows\\NetTunnelApp\\bin\\Debug\\utest.log"), LOG_TRACE, @@ -199,18 +198,17 @@ public: TEST_METHOD(TestBase64UrlEncode) { const std::string src = "iTeBvsuhkSOIoLB/t8qC/dBOu1lhLWwIZ675nF37MwM="; - using base64urlunPad = cppcodec::base64_url_unpadded; - using base64url = cppcodec::base64_url; - using base64 = cppcodec::base64_rfc4648; + using base64urlunPad = cppcodec::base64_url_unpadded; + using base64url = cppcodec::base64_url; + using base64 = cppcodec::base64_rfc4648; - std::string base = base64::encode(src); - std::string baseurl = base64url::encode(src); + std::string base = base64::encode(src); + std::string baseurl = base64url::encode(src); std::string baseunpad = base64urlunPad::encode(src); //std::string dbase = base64::decode(base); - - //std::cout << base64::encode(pSrc, lstrlen(pSrc)) << std::endl; + //std::cout << base64::encode(pSrc, lstrlen(pSrc)) << std::endl; //std::string encode = ::encode(pSrc); Logger::WriteMessage("["); Logger::WriteMessage(base64::encode(src).c_str()); @@ -219,7 +217,20 @@ public: TEST_METHOD(TestUserLogin) { PUSER_CLIENT_CONFIG pCfg; - Assert::AreEqual(RET_OK, GetUserClientConfigure(TEXT("admin"), TEXT("1689189114026041344"), &pCfg)); + Assert::AreEqual( + RET_OK, + GetUserClientConfigure( + TEXT("admin"), + TEXT("eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9." + "eyJ1c2VyX25hbWUiOiIxNjg5MTAyMjczNzEzMTg0NzY4Iiwic2NvcGUiOlsiYWxsIl0sInVzZXJUeXBlIjoidXNlciIsImV4c" + "CI6MTY5NDg1NDM0MSwiYXV0aG9yaXRpZXMiOlsiUk9MRV9SRVRBSU58MCJdLCJqdGkiOiJDOG5HNFdFSWRIdGRDWDJ3X084a2" + "xORlpYNVUiLCJhY2NvdW50IjoiY2hlbnhpYW5nIiwiY2xpZW50X2lkIjoic2Mtd2ludmRpc2RrLWVmYTl2MTJ4d3R6NWVwcHI" + "ifQ.cPJaSruDAc1BAuDnSqyvYaswGhS0jNB7MIw6pWqEwgdCBVK2JZy42t9t8MQ2xlsS41nsE0ddm-" + "qzZPPS51T5cx7SYhp8eOJva_" + "HNfWbH0H2yfYYzwe6CzjrHIT0S7wegK75tT38ZUEGQJVdVliauDO1cfj7FjKKddauBZoycLuZf7QC4O1_" + "omRkhN7r4eHvh1ZmPXarONumc0BuR7eMEu9qfbEX9IkIWzBXX-7qyAeMEdsDjROohKn9g9M1xs1_" + "uPGVclhUxhwp24038EMeMkHT9WYinZokbKIaIfFF1MCioWNSJc3BnxMXLdOKzeegt8EqYOBbmjn0SkWwnHeAevQ"), + &pCfg)); } TEST_METHOD(TestClientProgress) {