Feat: Sub-license count limit - LicenseLimit field in licenses.ini + context menu

- Add LicenseLimit field to LicenseInfo struct (0 = not set, unlimited)
- Add GetLicenseLimit/SetLicenseLimit: read/write LicenseLimit key in licenses.ini
- Append |lic:N to reserved field in TOKEN_AUTH response only when
  LicenseLimit > 0; absent |lic: means no limit (client defaults to 9999),
  so super admin authenticating to its own server is never falsely terminated
- Add "Sub-license limit" item in CLicenseDlg right-click menu (1-9999,
  empty = clear limit); menu label shows current value in real time
- Limit change takes effect when sub-client re-authenticates

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
yuanyuanxiang
2026-06-20 12:30:43 +02:00
parent c1433b4b5d
commit 837d89c8b5
6 changed files with 122 additions and 3 deletions

View File

@@ -27,6 +27,7 @@ struct LicenseInfo {
std::string PendingExpireDate; // 预设的新过期日期(如 20270221空表示无预设
int PendingHostNum = 0; // 预设的并发连接数
int PendingQuota = 0; // 预设的配额数量(支持多机器续期)
int LicenseLimit = 0; // 下级数量上限0=未设置下发时默认10
};
// 续期信息结构体
@@ -99,6 +100,7 @@ public:
afx_msg void OnLicenseDelete();
afx_msg void OnLicenseAutoFrp();
afx_msg void OnLicenseRevokeFrp();
afx_msg void OnLicenseSetLimit();
};
// 获取所有授权信息
@@ -130,5 +132,10 @@ int GetIPCountFromList(const std::string& ipListStr);
std::string GetFirstIPFromList(const std::string& ipListStr);
std::string FormatIPDisplay(const std::string& ipListStr); // 格式化显示: "[3] 192.168.1.1, ..."
// 下级数量限制(写 licenses.ini读取见 GetLicenseLimit
bool SetLicenseLimit(const std::string& deviceID, int limit);
// 读取下级数量上限0 = 未设置,调用方应视为 10默认值
int GetLicenseLimit(const std::string& deviceID);
// 检查 IP+机器名 是否在授权数据库中存在
bool FindLicenseByIPAndMachine(const std::string& ip, const std::string& machineName, std::string* outSN = nullptr);