将 maxConnsPerUser 从硬编码常量(3)改为数据库动态配置项,管理员可在 /admin/vpn 隧道设置中调整,保存后对新连接立即生效。 - model/vpn.go: VpnSetting 新增 MaxConnsPerUser 字段,gorm default:30 - db/db.go: 种子数据设默认 30;旧库回填 0 值为 30 - vpn/tunnel.go: 删除 maxConnsPerUser 常量,改读 VPN.Settings(),兜底 30 - handler/vpn.go: API 响应/请求结构体新增字段,校验范围 1-1000 - VpnView.vue: 隧道设置表单新增"每用户最大连接数"输入框 - zh.ts/en.ts: 新增 maxConnsPerUser 文案,更新首页多设备描述 - docs/client-development.md: 更新常量表为可配置项
48 lines
1.3 KiB
Go
48 lines
1.3 KiB
Go
package model
|
|
|
|
import "time"
|
|
|
|
const VpnSettingSingletonID = 1
|
|
|
|
type VpnSetting struct {
|
|
ID uint `gorm:"primaryKey"`
|
|
Enabled bool `gorm:"default:false"`
|
|
Subnet string `gorm:"size:64;not null"`
|
|
Subnet6 string `gorm:"size:64"`
|
|
MTU int `gorm:"default:1420"`
|
|
InterfaceName string `gorm:"size:16"`
|
|
AllowClientToClient bool `gorm:"default:false"`
|
|
DoLocalIPConfig bool `gorm:"default:true"`
|
|
DoRemoteIPConfig bool `gorm:"default:true"`
|
|
MaxConnsPerUser int `gorm:"default:30"`
|
|
UpdatedAt time.Time
|
|
}
|
|
|
|
func (VpnSetting) TableName() string {
|
|
return "vpn_settings"
|
|
}
|
|
|
|
type VpnReservation struct {
|
|
ID uint `gorm:"primaryKey;autoIncrement"`
|
|
UserID uint `gorm:"uniqueIndex;not null"`
|
|
IPAddress string `gorm:"size:64;uniqueIndex"`
|
|
IPAddress6 string `gorm:"size:64"`
|
|
CreatedAt time.Time `gorm:"autoCreateTime"`
|
|
}
|
|
|
|
func (VpnReservation) TableName() string {
|
|
return "vpn_reservations"
|
|
}
|
|
|
|
type TrafficStat struct {
|
|
ID uint `gorm:"primaryKey;autoIncrement"`
|
|
Date string `gorm:"uniqueIndex;size:10;not null"`
|
|
RxBytes int64 `gorm:"default:0"`
|
|
TxBytes int64 `gorm:"default:0"`
|
|
UpdatedAt time.Time
|
|
}
|
|
|
|
func (TrafficStat) TableName() string {
|
|
return "traffic_stats"
|
|
}
|