From a6b6151b0f305a70c683b62bd6c8cfd0a798d6b5 Mon Sep 17 00:00:00 2001 From: alves Date: Wed, 24 Dec 2025 14:26:00 +0800 Subject: [PATCH] feature remove the mac address on bury point --- src/common_func/common_func.cpp | 82 ++-------------------------- src/common_func/common_func.hpp | 1 - src/sentry_wrapper/SentryWrapper.cpp | 4 -- 3 files changed, 5 insertions(+), 82 deletions(-) diff --git a/src/common_func/common_func.cpp b/src/common_func/common_func.cpp index e18b524b32..cdde23d3c6 100644 --- a/src/common_func/common_func.cpp +++ b/src/common_func/common_func.cpp @@ -8,12 +8,12 @@ #pragma comment(lib, "iphlpapi.lib") #elif __APPLE__ #include -#import +#include #include -#include -#include - -#include +#include +#include +#include +#include #endif #include @@ -72,78 +72,6 @@ namespace common return machineId; } - std::string getMacAddress() - { - std::string macAddress = std::string(); - -#ifndef __APPLE__ - ULONG ulBufferSize = 0; - DWORD dwResult = ::GetAdaptersInfo(NULL, &ulBufferSize); - if (ERROR_BUFFER_OVERFLOW != dwResult) { - return std::string(); - } - - PIP_ADAPTER_INFO pAdapterInfo = (PIP_ADAPTER_INFO) new BYTE[ulBufferSize]; - if (!pAdapterInfo) { - return std::string(); - } - - dwResult = ::GetAdaptersInfo(pAdapterInfo, &ulBufferSize); - if (ERROR_SUCCESS != dwResult) { - delete[] pAdapterInfo; - return std::string(); - } - - BYTE pMac[MAX_ADAPTER_ADDRESS_LENGTH] = {0}; - int nLen = MAX_ADAPTER_ADDRESS_LENGTH; - - if (NULL != pAdapterInfo) { - PIP_ADDR_STRING pAddTemp = &(pAdapterInfo->IpAddressList); - - if (NULL != pAddTemp) { - for (int i = 0; i < (int) pAdapterInfo->AddressLength; ++i) { - pMac[i] = pAdapterInfo->Address[i]; - } - nLen = pAdapterInfo->AddressLength; - } - } - delete[] pAdapterInfo; - - auto Encode16 = [](const BYTE* buf, int len) -> std::wstring { - const WCHAR strHex[] = L"0123456789ABCDEF"; - std::wstring wstr; - wstr.resize(len * 2); - for (int i = 0; i < len; ++i) { - wstr[i * 2 + 0] = strHex[buf[i] >> 4]; - wstr[i * 2 + 1] = strHex[buf[i] & 0xf]; - } - return wstr; - }; - - auto wstringTostring = [](std::wstring wTmpStr) -> std::string { - std::string resStr = std::string(); - int len = WideCharToMultiByte(CP_UTF8, 0, wTmpStr.c_str(), -1, nullptr, 0, nullptr, nullptr); - - if (len <= 0) - return std::string(); - std::string desStr(len, 0); - - WideCharToMultiByte(CP_UTF8, 0, wTmpStr.c_str(), -1, &desStr[0], len, nullptr, nullptr); - - resStr = desStr; - - return resStr; - }; - - std::wstring strMac = Encode16(pMac, nLen); - macAddress = wstringTostring(strMac); -#else - // todo get mac macaddress -#endif - return macAddress; - } - - std::string get_flutter_version() { diff --git a/src/common_func/common_func.hpp b/src/common_func/common_func.hpp index 32838ed652..352d71a4a4 100644 --- a/src/common_func/common_func.hpp +++ b/src/common_func/common_func.hpp @@ -25,7 +25,6 @@ namespace common std::string getMachineId(); - std::string getMacAddress(); } // namespace common #endif \ No newline at end of file diff --git a/src/sentry_wrapper/SentryWrapper.cpp b/src/sentry_wrapper/SentryWrapper.cpp index a7d7595754..5d63702722 100644 --- a/src/sentry_wrapper/SentryWrapper.cpp +++ b/src/sentry_wrapper/SentryWrapper.cpp @@ -220,10 +220,6 @@ void initSentryEx() if (!machineID.empty()) sentry_set_tag("machine_id", machineID.c_str()); - std::string macAdress = common::getMacAddress(); - if (!macAdress.empty()) - sentry_set_tag("macaddress", macAdress.c_str()); - std::string pcName = common::get_pc_name(); if (!pcName.empty()) sentry_set_tag("pc_name", pcName.c_str());