refactor(server): remove Ratio field from Server struct and update adapter logic

This commit is contained in:
Chang lue Tsen 2025-09-28 11:18:33 -04:00
parent 42a31048b4
commit 5aa9bb61b7
2 changed files with 17 additions and 10 deletions

View File

@ -123,7 +123,7 @@ func (l *MigrateServerNodeLogic) adapterServer(info *server.Server) (*node.Serve
Name: info.Name,
Country: info.Country,
City: info.City,
Ratio: info.TrafficRatio,
//Ratio: info.TrafficRatio,
Address: info.ServerAddr,
Sort: int(info.Sort),
Protocols: "",
@ -142,6 +142,7 @@ func (l *MigrateServerNodeLogic) adapterServer(info *server.Server) (*node.Serve
Cipher: src.Method,
Port: uint16(src.Port),
ServerKey: src.ServerKey,
Ratio: float64(info.TrafficRatio),
})
case Vmess:
var src server.Vmess
@ -166,6 +167,7 @@ func (l *MigrateServerNodeLogic) adapterServer(info *server.Server) (*node.Serve
Path: src.TransportConfig.Path,
ServiceName: src.TransportConfig.ServiceName,
Flow: src.Flow,
Ratio: float64(info.TrafficRatio),
}
protocols = append(protocols, protocol)
protocols = append(protocols, protocol)
@ -192,6 +194,7 @@ func (l *MigrateServerNodeLogic) adapterServer(info *server.Server) (*node.Serve
Path: src.TransportConfig.Path,
ServiceName: src.TransportConfig.ServiceName,
Flow: src.Flow,
Ratio: float64(info.TrafficRatio),
}
protocols = append(protocols, protocol)
case Trojan:
@ -217,6 +220,7 @@ func (l *MigrateServerNodeLogic) adapterServer(info *server.Server) (*node.Serve
Path: src.TransportConfig.Path,
ServiceName: src.TransportConfig.ServiceName,
Flow: src.Flow,
Ratio: float64(info.TrafficRatio),
}
protocols = append(protocols, protocol)
case Hysteria2:
@ -239,6 +243,7 @@ func (l *MigrateServerNodeLogic) adapterServer(info *server.Server) (*node.Serve
RealityPrivateKey: src.SecurityConfig.RealityPrivateKey,
RealityPublicKey: src.SecurityConfig.RealityPublicKey,
RealityShortId: src.SecurityConfig.RealityShortId,
Ratio: float64(info.TrafficRatio),
}
protocols = append(protocols, protocol)
case Tuic:
@ -262,6 +267,7 @@ func (l *MigrateServerNodeLogic) adapterServer(info *server.Server) (*node.Serve
RealityPrivateKey: src.SecurityConfig.RealityPrivateKey,
RealityPublicKey: src.SecurityConfig.RealityPublicKey,
RealityShortId: src.SecurityConfig.RealityShortId,
Ratio: float64(info.TrafficRatio),
}
protocols = append(protocols, protocol)
case AnyTLS:
@ -281,6 +287,7 @@ func (l *MigrateServerNodeLogic) adapterServer(info *server.Server) (*node.Serve
RealityPrivateKey: src.SecurityConfig.RealityPrivateKey,
RealityPublicKey: src.SecurityConfig.RealityPublicKey,
RealityShortId: src.SecurityConfig.RealityShortId,
Ratio: float64(info.TrafficRatio),
}
protocols = append(protocols, protocol)
}

View File

@ -14,7 +14,7 @@ type Server struct {
Name string `gorm:"type:varchar(100);not null;default:'';comment:Server Name"`
Country string `gorm:"type:varchar(128);not null;default:'';comment:Country"`
City string `gorm:"type:varchar(128);not null;default:'';comment:City"`
Ratio float32 `gorm:"type:DECIMAL(4,2);not null;default:0;comment:Traffic Ratio"`
//Ratio float32 `gorm:"type:DECIMAL(4,2);not null;default:0;comment:Traffic Ratio"`
Address string `gorm:"type:varchar(100);not null;default:'';comment:Server Address"`
Sort int `gorm:"type:int;not null;default:0;comment:Sort"`
Protocols string `gorm:"type:text;default:null;comment:Protocol"`