添加 WebSocket VPN 接口及用户认证
- 移动 config 包到 internal/config,新增 DatabaseConfig - 使用 GORM + SQLite 管理用户数据,预留 MySQL 支持 - 新增 internal/model/user.go GORM 用户模型 - 新增 internal/db/db.go 数据库初始化及默认管理员 - 新增 internal/vpn/ WebSocket 鉴权与隧道骨架 - /ws 路径支持用户名+密码鉴权 (bcrypt) - 心跳保活 + echo 隧道模式
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
package model
|
||||
|
||||
import "time"
|
||||
|
||||
type User struct {
|
||||
ID uint `gorm:"primaryKey;autoIncrement"`
|
||||
Username string `gorm:"uniqueIndex;size:64;not null"`
|
||||
Password string `gorm:"size:128;not null"`
|
||||
Role string `gorm:"size:16;default:user"`
|
||||
Status int `gorm:"default:1"`
|
||||
CreatedAt time.Time `gorm:"autoCreateTime"`
|
||||
UpdatedAt time.Time `gorm:"autoUpdateTime"`
|
||||
}
|
||||
|
||||
func (User) TableName() string {
|
||||
return "users"
|
||||
}
|
||||
Reference in New Issue
Block a user