This commit is contained in:
2026-07-18 17:07:34 +08:00
parent 70f8d2a35d
commit 7406d4f6ee
5 changed files with 59 additions and 32 deletions

View File

@@ -1,6 +1,4 @@
# =============================================
# 文件管理系统配置
# =============================================
server:
port: 8075
@@ -8,7 +6,7 @@ server:
public_url: "http://127.0.0.1:5173"
database:
type: mysql # mysql / sqlserver / postgres
type: mysql
host: 127.0.0.1
port: 3306
username: root
@@ -22,10 +20,9 @@ jwt:
storage:
default_policy_id: 1
local_base_path: D:/Seeyon/A8/localfile
cdn_host: "http://127.0.0.1:3090"
cdn_path_prefix: "/public"
cdn_host: ""
cdn_path_prefix: ""
# 备份工具路径(留空则自动搜索)
backup:
mysqldump_path: ""
mysql_path: ""
@@ -33,7 +30,7 @@ backup:
psql_path: ""
sqlcmd_path: ""
# 授权配置
license:
file_path: "" # 授权文件路径, 留空则默认 ./license.json
verify_url: "" # 远程验证接口(可选), 如 http://verify.example.com/api/license/verify
file_path: ""
verify_url: ""
network: internal

View File

@@ -24,8 +24,9 @@ type Config struct {
// LicenseConfig 授权配置
type LicenseConfig struct {
VerifyURL string `mapstructure:"verify_url"` // 远程验证接口地址(可选)
VerifyURL string `mapstructure:"verify_url"` // 远程验证接口地址(外网必填)
FilePath string `mapstructure:"file_path"` // 授权文件路径, 默认 ./license.json
Network string `mapstructure:"network"` // 网络类型: internal=内网(仅本地校验) / external=外网(需远程验证)
}
// BackupConfig 备份工具配置

View File

@@ -3,7 +3,11 @@ package main
import (
"fmt"
"io"
"log"
"os"
"path/filepath"
"time"
"seeyon-filesystem/api"
"seeyon-filesystem/config"
@@ -14,8 +18,16 @@ import (
)
func main() {
// 日志输出接入环形缓冲区(同时保留控制台输出)
log.SetOutput(utils.LogBuf)
// 日志输出: 控制台 + 内存缓冲区 + 按日期分割的文件
logDir := "logs"
os.MkdirAll(logDir, 0755)
logPath := filepath.Join(logDir, fmt.Sprintf("server_%s.log", time.Now().Format("20060102")))
logFile, err := os.OpenFile(logPath, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0644)
if err == nil {
log.SetOutput(io.MultiWriter(os.Stderr, logFile, utils.LogBuf))
} else {
log.SetOutput(io.MultiWriter(os.Stderr, utils.LogBuf))
}
cfg, err := config.Load()
if err != nil {
@@ -339,34 +351,47 @@ func checkLicense(cfg config.LicenseConfig) error {
licensePath = "license.json"
}
resp, err := utils.ReadAndVerifyLicense(licensePath, cfg.VerifyURL, "seeyon-filesystem", "1.0")
// 读取授权文件
license, err := utils.ReadLicenseFile(licensePath)
if err != nil {
return err
}
if !resp.Valid {
return fmt.Errorf("%s", resp.Message)
}
// 设置当前授权信息
licPath := cfg.FilePath
if licPath == "" {
licPath = "license.json"
}
if licData, licErr := utils.ReadLicenseFile(licPath); licErr == nil {
utils.SetCurrentLicense(licData)
utils.SetCurrentLicense(license)
// 根据网络类型选择验证方式
network := cfg.Network
if network == "" {
network = "internal"
}
lic := utils.GetCurrentLicense()
features := ""
if lic != nil {
features = lic.Features
}
if resp.ExpireDays == -1 {
log.Printf("[授权] 企业版 - 永久授权, 用户上限: %d, 功能: %s", resp.MaxUsers, features)
if network == "external" && cfg.VerifyURL != "" {
// 外网: 调远程接口验证
resp, err := utils.ReadAndVerifyLicense(licensePath, cfg.VerifyURL, "seeyon-filesystem", "1.0")
if err != nil {
return err
}
if !resp.Valid {
return fmt.Errorf("%s", resp.Message)
}
if resp.ExpireDays == -1 {
log.Printf("[授权] 企业版(外网) - 永久授权, 用户上限: %d, 功能: %s", resp.MaxUsers, license.Features)
} else {
log.Printf("[授权] 企业版(外网) - 有效期剩余 %d 天, 用户上限: %d, 功能: %s", resp.ExpireDays, resp.MaxUsers, license.Features)
}
} else {
log.Printf("[授权] 企业版 - 有效期剩余 %d 天, 用户上限: %d, 功能: %s", resp.ExpireDays, resp.MaxUsers, features)
// 内网: 仅本地校验(解密 + 签名 + 机器码比对)
if err := utils.VerifyLicense(license); err != nil {
return err
}
days := utils.GetLicenseExpireDays(license)
if days == -1 {
log.Printf("[授权] 企业版(内网) - 永久授权, 用户上限: %d, 功能: %s", license.MaxUsers, license.Features)
} else {
log.Printf("[授权] 企业版(内网) - 有效期剩余 %d 天, 用户上限: %d, 功能: %s", days, license.MaxUsers, license.Features)
}
}
return nil
}

Binary file not shown.