Balance multiple stamps with the same name

This commit is contained in:
YX Hao 2023-07-02 10:21:15 +08:00
parent 16b2c84147
commit a29b218b5c

View file

@ -297,6 +297,10 @@ func (proxy *Proxy) updateRegisteredServers() error {
len(registeredServers), len(registeredServers),
) )
} }
// Balance multiple stamps with the same name
rand.Shuffle(len(registeredServers), func(i, j int) {
registeredServers[i], registeredServers[j] = registeredServers[j], registeredServers[i]
})
for _, registeredServer := range registeredServers { for _, registeredServer := range registeredServers {
if registeredServer.stamp.Proto != stamps.StampProtoTypeDNSCryptRelay && if registeredServer.stamp.Proto != stamps.StampProtoTypeDNSCryptRelay &&
registeredServer.stamp.Proto != stamps.StampProtoTypeODoHRelay { registeredServer.stamp.Proto != stamps.StampProtoTypeODoHRelay {