From b9005b7acc164ac18694509165aea7c7293b26a7 Mon Sep 17 00:00:00 2001 From: wangdongpo <544209413@qq.com> Date: Fri, 21 Feb 2025 23:49:18 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E6=9B=B4=E6=96=B0=E3=80=91=E6=8E=88?= =?UTF-8?q?=E6=9D=83=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/AppCfg.cpp | 4 ++-- src/util/AuthModule.cpp | 34 ++++++++++++++++++++++------------ 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/src/AppCfg.cpp b/src/AppCfg.cpp index f107517..bb44c8b 100644 --- a/src/AppCfg.cpp +++ b/src/AppCfg.cpp @@ -5,7 +5,7 @@ std::string AppCfg::m_work_path=""; std::string AppCfg::m_license=""; float AppCfg::m_face_match_threshold = 0.78f; void AppCfg::SetWorkPath(const std::string& work_path) { - + m_work_path = work_path; } const std::string AppCfg::GetWorkPath() { @@ -18,6 +18,6 @@ bool AppCfg::SetLicense(const std::string& license) { } void AppCfg::SetFaceMatchThreshold(float threshold) { - + m_face_match_threshold = threshold; } diff --git a/src/util/AuthModule.cpp b/src/util/AuthModule.cpp index 0f35f51..5b55f03 100644 --- a/src/util/AuthModule.cpp +++ b/src/util/AuthModule.cpp @@ -8,6 +8,7 @@ #include #include "openssl/aes.h" #include "AuthModule.h" +#include "DeviceInfo.h" #include "Base64.h" #include "HttpRequest.h" // 获取时间戳 @@ -115,8 +116,7 @@ void TimeInfo::Show() { } AuthInfo::AuthInfo() : - m_type(AUTH_TYPE_INVALID) { -} + m_type(AUTH_TYPE_INVALID) { } AuthInfo::AuthInfo(const std::string& key_data) { std::istringstream iss(key_data); @@ -144,6 +144,7 @@ AuthInfo::AuthInfo(const std::string& key_data) { ret_t AuthModule::CheckKey(const std::string& key) { + return RET_AUTH_FAILED; } @@ -155,18 +156,19 @@ ret_t AuthModule::CheckKeyFile(const std::string& key_file) { } m_auth_info = AuthInfo(key_data); // m_auth_info.m_expire_time.Show(); - switch (m_auth_info.m_type){ + switch (m_auth_info.m_type) { case AUTH_TYPE_OFFLINE_TIME: ret = CheckOfflineTime(); - break; - case AUTH_TYPE_OFFLINE_MAC: - ret = CheckOfflineMac(); - case AUTH_TYPE_ONLINE: - ret = CheckOnline(); - break; - default: - ret = RET_AUTH_FAILED; - break; + break; + case AUTH_TYPE_OFFLINE_MAC: + ret = CheckOfflineMac(); + break; + case AUTH_TYPE_ONLINE: + ret = CheckOnline(); + break; + default: + ret = RET_AUTH_FAILED; + break; } return ret; } @@ -242,6 +244,14 @@ ret_t AuthModule::CheckOfflineTime() { } ret_t AuthModule::CheckOfflineMac() { + std::vector mac_list = DeviceInfo::GetInstance().GetMacAddress(); + for (auto& mac : mac_list) { + for (auto& auth_mac : m_auth_info.m_mac_list) { + if (mac == auth_mac) { + return RET_OK; + } + } + } return RET_AUTH_FAILED; }