feat: 客户端授权防护——响应签名/激活令牌/宽限期/换座限制/在线清扫/疑似共享标记
This commit is contained in:
1 parent
37d9e8ca56
commit
b76111dfc3
11 files changed
+437
-54
No files matched your search
@@ -53,6 +53,9 @@ type LicenseResponse struct {
|
||||
DaysLeft int `json:"days_left"`
|
||||
Notes string `json:"notes"`
|
||||
CreatedAt string `json:"created_at"`
|
||||
DistinctIPs int `json:"distinct_ips"` // 激活记录中的不重复 IP 数(疑似共享信号)
|
||||
NewDevices7d int `json:"new_devices_7d"` // 近 7 天新增设备数(换座频次信号)
|
||||
AbuseSuspected bool `json:"abuse_suspected"` // 疑似共享/滥用标记
|
||||
}
|
||||
|
||||
// ============ 客户端授权契约(无需认证) ============
|
||||
@@ -68,18 +71,23 @@ type LicenseVerifyRequest struct {
|
||||
|
||||
// LicenseVerifyResponse 验证响应 // Logan.Li
|
||||
type LicenseVerifyResponse struct {
|
||||
Valid bool `json:"valid"`
|
||||
LicenseKey string `json:"license_key,omitempty"`
|
||||
ProductID uint `json:"product_id,omitempty"`
|
||||
ProductName string `json:"product_name,omitempty"`
|
||||
ProductCode string `json:"product_code,omitempty"`
|
||||
Features []string `json:"features,omitempty"`
|
||||
Status string `json:"status,omitempty"`
|
||||
ExpiresAt string `json:"expires_at,omitempty"`
|
||||
DaysLeft int `json:"days_left,omitempty"`
|
||||
MaxDevices int `json:"max_devices,omitempty"`
|
||||
PlanType string `json:"plan_type,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Valid bool `json:"valid"`
|
||||
LicenseKey string `json:"license_key,omitempty"`
|
||||
ProductID uint `json:"product_id,omitempty"`
|
||||
ProductName string `json:"product_name,omitempty"`
|
||||
ProductCode string `json:"product_code,omitempty"`
|
||||
Features []string `json:"features,omitempty"`
|
||||
Status string `json:"status,omitempty"`
|
||||
ExpiresAt string `json:"expires_at,omitempty"`
|
||||
DaysLeft int `json:"days_left,omitempty"`
|
||||
MaxDevices int `json:"max_devices,omitempty"`
|
||||
PlanType string `json:"plan_type,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
InGrace bool `json:"in_grace,omitempty"` // 宽限期内(仅商业过期,吊销/暂停无宽限)
|
||||
GraceDaysLeft int `json:"grace_days_left,omitempty"` // 宽限剩余天数
|
||||
ExpiresAtUnix int64 `json:"expires_at_unix,omitempty"` // 到期时间 unix 秒(签名字段,客户端直接回用免时区换算)
|
||||
ServerTime int64 `json:"server_time,omitempty"` // 服务端时间(unix 秒),客户端据此防时钟回拨
|
||||
Sig string `json:"sig,omitempty"` // Ed25519 签名(hex),客户端用内嵌公钥验签防假服务器
|
||||
}
|
||||
|
||||
// LicenseActivateRequest 激活请求(客户端调用) // Logan.Li
|
||||
@@ -92,8 +100,9 @@ type LicenseActivateRequest struct {
|
||||
|
||||
// LicenseDeactivateRequest 停用请求(客户端调用) // Logan.Li
|
||||
type LicenseDeactivateRequest struct {
|
||||
LicenseKey string `json:"license_key" binding:"required"`
|
||||
DeviceID string `json:"device_id" binding:"required"`
|
||||
LicenseKey string `json:"license_key" binding:"required"`
|
||||
DeviceID string `json:"device_id" binding:"required"`
|
||||
ActivationToken string `json:"activation_token"` // 本机激活时下发的令牌;解绑他机需联系管理员
|
||||
}
|
||||
|
||||
// LicenseHeartbeatRequest 心跳请求(客户端调用) // Logan.Li
|
||||
@@ -123,7 +132,7 @@ type OfflineLicenseCreate struct {
|
||||
CustomerID uint `json:"customer_id"`
|
||||
CustomerName string `json:"customer_name"`
|
||||
ProductCode string `json:"product_code"`
|
||||
PlanType string `json:"plan_type"` // trial | yearly(禁止 perpetual)
|
||||
PlanType string `json:"plan_type"` // trial | yearly(禁止 perpetual)
|
||||
DurationDays int `json:"duration_days"` // 1–365,默认 365;trial 上限 180
|
||||
Notes string `json:"notes"`
|
||||
}
|
||||
@@ -142,4 +151,3 @@ type OfflineLicenseResponse struct {
|
||||
LicenseID uint `json:"license_id"`
|
||||
PublicKey string `json:"public_key_hex"`
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user