feature remove the mac address on bury point

This commit is contained in:
alves
2025-12-24 14:26:00 +08:00
parent ed81bf6cbe
commit a6b6151b0f
3 changed files with 5 additions and 82 deletions

View File

@@ -8,12 +8,12 @@
#pragma comment(lib, "iphlpapi.lib")
#elif __APPLE__
#include <stdlib.h>
#import <IOKit/IOKitLib.h>
#include <IOKit/IOKitLib.h>
#include <CoreFoundation/CoreFoundation.h>
#include <unistd.h>
#include <dlfcn.h>
#include <CoreServices/CoreServices.h>
#include <IOKit/IOKitLib.h>
#include <IOKit/network/IONetworkInterface.h>
#include <IOKit/network/IONetworkController.h>
#include <AvailabilityMacros.h>
#endif
#include <fstream>
@@ -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()
{

View File

@@ -25,7 +25,6 @@ namespace common
std::string getMachineId();
std::string getMacAddress();
} // namespace common
#endif

View File

@@ -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());