实现云端控制的动态节点分配逻辑

This commit is contained in:
2025-03-28 10:03:29 +08:00
parent e337a9c08e
commit e61f0bef32
16 changed files with 1313 additions and 138 deletions

View File

@@ -29,12 +29,14 @@ func newChannel(db *gorm.DB, opts ...gen.DOOption) channel {
_channel.ALL = field.NewAsterisk(tableName)
_channel.ID = field.NewInt32(tableName, "id")
_channel.UserID = field.NewInt32(tableName, "user_id")
_channel.ProxyID = field.NewInt32(tableName, "proxy_id")
_channel.NodeID = field.NewInt32(tableName, "node_id")
_channel.ProxyPort = field.NewInt32(tableName, "proxy_port")
_channel.Protocol = field.NewString(tableName, "protocol")
_channel.UserHost = field.NewString(tableName, "user_host")
_channel.NodePort = field.NewInt32(tableName, "node_port")
_channel.NodeHost = field.NewString(tableName, "node_host")
_channel.AuthIP = field.NewBool(tableName, "auth_ip")
_channel.AuthPass = field.NewBool(tableName, "auth_pass")
_channel.Protocol = field.NewString(tableName, "protocol")
_channel.Username = field.NewString(tableName, "username")
_channel.Password = field.NewString(tableName, "password")
_channel.Expiration = field.NewTime(tableName, "expiration")
@@ -53,12 +55,14 @@ type channel struct {
ALL field.Asterisk
ID field.Int32 // 通道ID
UserID field.Int32 // 用户ID
ProxyID field.Int32 // 代理ID
NodeID field.Int32 // 节点ID
ProxyPort field.Int32 // 转发端口
Protocol field.String // 协议
UserHost field.String // 用户地址
NodePort field.Int32 // 节点端口
NodeHost field.String // 节点地址
AuthIP field.Bool // IP认证
AuthPass field.Bool // 密码认证
Protocol field.String // 协议
Username field.String // 用户名
Password field.String // 密码
Expiration field.Time // 过期时间
@@ -83,12 +87,14 @@ func (c *channel) updateTableName(table string) *channel {
c.ALL = field.NewAsterisk(table)
c.ID = field.NewInt32(table, "id")
c.UserID = field.NewInt32(table, "user_id")
c.ProxyID = field.NewInt32(table, "proxy_id")
c.NodeID = field.NewInt32(table, "node_id")
c.ProxyPort = field.NewInt32(table, "proxy_port")
c.Protocol = field.NewString(table, "protocol")
c.UserHost = field.NewString(table, "user_host")
c.NodePort = field.NewInt32(table, "node_port")
c.NodeHost = field.NewString(table, "node_host")
c.AuthIP = field.NewBool(table, "auth_ip")
c.AuthPass = field.NewBool(table, "auth_pass")
c.Protocol = field.NewString(table, "protocol")
c.Username = field.NewString(table, "username")
c.Password = field.NewString(table, "password")
c.Expiration = field.NewTime(table, "expiration")
@@ -111,15 +117,17 @@ func (c *channel) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
}
func (c *channel) fillFieldMap() {
c.fieldMap = make(map[string]field.Expr, 14)
c.fieldMap = make(map[string]field.Expr, 16)
c.fieldMap["id"] = c.ID
c.fieldMap["user_id"] = c.UserID
c.fieldMap["proxy_id"] = c.ProxyID
c.fieldMap["node_id"] = c.NodeID
c.fieldMap["proxy_port"] = c.ProxyPort
c.fieldMap["protocol"] = c.Protocol
c.fieldMap["user_host"] = c.UserHost
c.fieldMap["node_port"] = c.NodePort
c.fieldMap["node_host"] = c.NodeHost
c.fieldMap["auth_ip"] = c.AuthIP
c.fieldMap["auth_pass"] = c.AuthPass
c.fieldMap["protocol"] = c.Protocol
c.fieldMap["username"] = c.Username
c.fieldMap["password"] = c.Password
c.fieldMap["expiration"] = c.Expiration