feat(license): 首次安装 14 天 Pro 试用(无需授权码)
CI / Backend (go vet + test) (push) Canceled after 0s
CI / Frontend (lint + build + test) (push) Canceled after 0s

- 首次启动落试用起点(DATA_DIR/.trial-start 0600 + 库内 settings 双写,取最早防分次续命);
  窗口内 IsPro() 等效 Pro——日志分析/告警/AI 助手/审计全解锁,到期自动回免费版
- 防刷三层:时间戳双写(删任一不重发)+ 机器级指纹(machine-id / hostname+cpu,
  故意不含 DATA_DIR 特征——目录特征会因删除重建漂移等于后门);指纹命中则落已过期起点
- LicenseStatusPayload 返回 trial{active,daysLeft} 与 plan=trial;
  设置页授权区显示「Pro 试用中 · 剩余 N 天」提示条
- 单测:全新安装 14 天/到期回落/删时间戳重装不重发(指纹防刷)三用例
- 滥用评估:删库重装同机器被指纹拦截;换机器/VM 必然可重试(接受,Pro 功能零边际成本,
  追杀到硬件级得不偿失);正式授权随时激活覆盖试用
This commit is contained in:
opsx committed 2026-11-01 05:53:55 +08:00
1 parent f67b86e6bb
commit 9a477e9c9b
6 files changed
+355 -5

No files matched your search

+25 -4
View File
@@ -386,8 +386,20 @@ func LicenseStatusPayload() (map[string]interface{}, bool) {
current := CurrentLicense()
stored := StoredLicense()
instanceID := GetOrCreateInstanceID()
EnsureTrialStarted()
trialDaysLeft := 0
if TrialActive() {
trialDaysLeft = TrialRemainingDays()
}
if stored == nil {
return map[string]interface{}{"plan": "free", "instanceId": instanceID}, false
plan := "free"
if trialDaysLeft > 0 {
plan = "trial"
}
return map[string]interface{}{
"plan": plan, "instanceId": instanceID,
"trial": map[string]interface{}{"active": trialDaysLeft > 0, "daysLeft": trialDaysLeft},
}, trialDaysLeft > 0
}
out := stored.Sanitized()
out["instanceId"] = instanceID
@@ -400,7 +412,11 @@ func LicenseStatusPayload() (map[string]interface{}, bool) {
out["invalidReason"] = reason
}
out["plan"] = "free"
return out, false
if trialDaysLeft > 0 {
out["plan"] = "trial"
}
out["trial"] = map[string]interface{}{"active": trialDaysLeft > 0, "daysLeft": trialDaysLeft}
return out, trialDaysLeft > 0
}
// CurrentLicense 当前有效许可(nil = 免费版)
@@ -444,8 +460,13 @@ func CurrentLicense() *models.License {
return lic
}
// IsPro 是否为有效 Pro
func IsPro() bool { return CurrentLicense() != nil }
// IsPro 是否为有效 Pro:正式授权优先;无授权时 14 天试用窗口内等效 Pro
func IsPro() bool {
if CurrentLicense() != nil {
return true
}
return TrialActive()
}
// ProFeatureList Pro 功能标识(给前端展示)
func ProFeatureList() []string { return proFeatures }