refactor(server): remove Ratio field from Server struct and update adapter logic
This commit is contained in:
parent
42a31048b4
commit
5aa9bb61b7
@ -119,11 +119,11 @@ func (l *MigrateServerNodeLogic) MigrateServerNode() (resp *types.MigrateServerN
|
|||||||
|
|
||||||
func (l *MigrateServerNodeLogic) adapterServer(info *server.Server) (*node.Server, error) {
|
func (l *MigrateServerNodeLogic) adapterServer(info *server.Server) (*node.Server, error) {
|
||||||
result := &node.Server{
|
result := &node.Server{
|
||||||
Id: info.Id,
|
Id: info.Id,
|
||||||
Name: info.Name,
|
Name: info.Name,
|
||||||
Country: info.Country,
|
Country: info.Country,
|
||||||
City: info.City,
|
City: info.City,
|
||||||
Ratio: info.TrafficRatio,
|
//Ratio: info.TrafficRatio,
|
||||||
Address: info.ServerAddr,
|
Address: info.ServerAddr,
|
||||||
Sort: int(info.Sort),
|
Sort: int(info.Sort),
|
||||||
Protocols: "",
|
Protocols: "",
|
||||||
@ -142,6 +142,7 @@ func (l *MigrateServerNodeLogic) adapterServer(info *server.Server) (*node.Serve
|
|||||||
Cipher: src.Method,
|
Cipher: src.Method,
|
||||||
Port: uint16(src.Port),
|
Port: uint16(src.Port),
|
||||||
ServerKey: src.ServerKey,
|
ServerKey: src.ServerKey,
|
||||||
|
Ratio: float64(info.TrafficRatio),
|
||||||
})
|
})
|
||||||
case Vmess:
|
case Vmess:
|
||||||
var src server.Vmess
|
var src server.Vmess
|
||||||
@ -166,6 +167,7 @@ func (l *MigrateServerNodeLogic) adapterServer(info *server.Server) (*node.Serve
|
|||||||
Path: src.TransportConfig.Path,
|
Path: src.TransportConfig.Path,
|
||||||
ServiceName: src.TransportConfig.ServiceName,
|
ServiceName: src.TransportConfig.ServiceName,
|
||||||
Flow: src.Flow,
|
Flow: src.Flow,
|
||||||
|
Ratio: float64(info.TrafficRatio),
|
||||||
}
|
}
|
||||||
protocols = append(protocols, protocol)
|
protocols = append(protocols, protocol)
|
||||||
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,
|
Path: src.TransportConfig.Path,
|
||||||
ServiceName: src.TransportConfig.ServiceName,
|
ServiceName: src.TransportConfig.ServiceName,
|
||||||
Flow: src.Flow,
|
Flow: src.Flow,
|
||||||
|
Ratio: float64(info.TrafficRatio),
|
||||||
}
|
}
|
||||||
protocols = append(protocols, protocol)
|
protocols = append(protocols, protocol)
|
||||||
case Trojan:
|
case Trojan:
|
||||||
@ -217,6 +220,7 @@ func (l *MigrateServerNodeLogic) adapterServer(info *server.Server) (*node.Serve
|
|||||||
Path: src.TransportConfig.Path,
|
Path: src.TransportConfig.Path,
|
||||||
ServiceName: src.TransportConfig.ServiceName,
|
ServiceName: src.TransportConfig.ServiceName,
|
||||||
Flow: src.Flow,
|
Flow: src.Flow,
|
||||||
|
Ratio: float64(info.TrafficRatio),
|
||||||
}
|
}
|
||||||
protocols = append(protocols, protocol)
|
protocols = append(protocols, protocol)
|
||||||
case Hysteria2:
|
case Hysteria2:
|
||||||
@ -239,6 +243,7 @@ func (l *MigrateServerNodeLogic) adapterServer(info *server.Server) (*node.Serve
|
|||||||
RealityPrivateKey: src.SecurityConfig.RealityPrivateKey,
|
RealityPrivateKey: src.SecurityConfig.RealityPrivateKey,
|
||||||
RealityPublicKey: src.SecurityConfig.RealityPublicKey,
|
RealityPublicKey: src.SecurityConfig.RealityPublicKey,
|
||||||
RealityShortId: src.SecurityConfig.RealityShortId,
|
RealityShortId: src.SecurityConfig.RealityShortId,
|
||||||
|
Ratio: float64(info.TrafficRatio),
|
||||||
}
|
}
|
||||||
protocols = append(protocols, protocol)
|
protocols = append(protocols, protocol)
|
||||||
case Tuic:
|
case Tuic:
|
||||||
@ -262,6 +267,7 @@ func (l *MigrateServerNodeLogic) adapterServer(info *server.Server) (*node.Serve
|
|||||||
RealityPrivateKey: src.SecurityConfig.RealityPrivateKey,
|
RealityPrivateKey: src.SecurityConfig.RealityPrivateKey,
|
||||||
RealityPublicKey: src.SecurityConfig.RealityPublicKey,
|
RealityPublicKey: src.SecurityConfig.RealityPublicKey,
|
||||||
RealityShortId: src.SecurityConfig.RealityShortId,
|
RealityShortId: src.SecurityConfig.RealityShortId,
|
||||||
|
Ratio: float64(info.TrafficRatio),
|
||||||
}
|
}
|
||||||
protocols = append(protocols, protocol)
|
protocols = append(protocols, protocol)
|
||||||
case AnyTLS:
|
case AnyTLS:
|
||||||
@ -281,6 +287,7 @@ func (l *MigrateServerNodeLogic) adapterServer(info *server.Server) (*node.Serve
|
|||||||
RealityPrivateKey: src.SecurityConfig.RealityPrivateKey,
|
RealityPrivateKey: src.SecurityConfig.RealityPrivateKey,
|
||||||
RealityPublicKey: src.SecurityConfig.RealityPublicKey,
|
RealityPublicKey: src.SecurityConfig.RealityPublicKey,
|
||||||
RealityShortId: src.SecurityConfig.RealityShortId,
|
RealityShortId: src.SecurityConfig.RealityShortId,
|
||||||
|
Ratio: float64(info.TrafficRatio),
|
||||||
}
|
}
|
||||||
protocols = append(protocols, protocol)
|
protocols = append(protocols, protocol)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,11 +10,11 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Server struct {
|
type Server struct {
|
||||||
Id int64 `gorm:"primary_key"`
|
Id int64 `gorm:"primary_key"`
|
||||||
Name string `gorm:"type:varchar(100);not null;default:'';comment:Server Name"`
|
Name string `gorm:"type:varchar(100);not null;default:'';comment:Server Name"`
|
||||||
Country string `gorm:"type:varchar(128);not null;default:'';comment:Country"`
|
Country string `gorm:"type:varchar(128);not null;default:'';comment:Country"`
|
||||||
City string `gorm:"type:varchar(128);not null;default:'';comment:City"`
|
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"`
|
Address string `gorm:"type:varchar(100);not null;default:'';comment:Server Address"`
|
||||||
Sort int `gorm:"type:int;not null;default:0;comment:Sort"`
|
Sort int `gorm:"type:int;not null;default:0;comment:Sort"`
|
||||||
Protocols string `gorm:"type:text;default:null;comment:Protocol"`
|
Protocols string `gorm:"type:text;default:null;comment:Protocol"`
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user