移除不必要的 user_host 字段及相关索引;优化通道缓存方式,直接缓存通道授权信息

This commit is contained in:
2025-05-12 17:04:20 +08:00
parent 2c37dcc2be
commit 2be1a18e91
5 changed files with 43 additions and 68 deletions

View File

@@ -36,7 +36,6 @@ func newChannel(db *gorm.DB, opts ...gen.DOOption) channel {
_channel.NodeHost = field.NewString(tableName, "node_host")
_channel.Protocol = field.NewInt32(tableName, "protocol")
_channel.AuthIP = field.NewBool(tableName, "auth_ip")
_channel.UserHost = field.NewString(tableName, "user_host")
_channel.AuthPass = field.NewBool(tableName, "auth_pass")
_channel.Username = field.NewString(tableName, "username")
_channel.Password = field.NewString(tableName, "password")
@@ -63,7 +62,6 @@ type channel struct {
NodeHost field.String // 节点地址
Protocol field.Int32 // 协议类型1-http2-https3-socks5
AuthIP field.Bool // IP认证
UserHost field.String // 用户地址
AuthPass field.Bool // 密码认证
Username field.String // 用户名
Password field.String // 密码
@@ -96,7 +94,6 @@ func (c *channel) updateTableName(table string) *channel {
c.NodeHost = field.NewString(table, "node_host")
c.Protocol = field.NewInt32(table, "protocol")
c.AuthIP = field.NewBool(table, "auth_ip")
c.UserHost = field.NewString(table, "user_host")
c.AuthPass = field.NewBool(table, "auth_pass")
c.Username = field.NewString(table, "username")
c.Password = field.NewString(table, "password")
@@ -120,7 +117,7 @@ func (c *channel) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
}
func (c *channel) fillFieldMap() {
c.fieldMap = make(map[string]field.Expr, 17)
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
@@ -130,7 +127,6 @@ func (c *channel) fillFieldMap() {
c.fieldMap["node_host"] = c.NodeHost
c.fieldMap["protocol"] = c.Protocol
c.fieldMap["auth_ip"] = c.AuthIP
c.fieldMap["user_host"] = c.UserHost
c.fieldMap["auth_pass"] = c.AuthPass
c.fieldMap["username"] = c.Username
c.fieldMap["password"] = c.Password