Repair server randomization

This commit is contained in:
Frank Denis 2021-01-02 19:04:53 +01:00
parent 5398dab58e
commit 7ec5ed127e
2 changed files with 8 additions and 4 deletions

View File

@ -806,10 +806,15 @@ func (config *Config) loadSources(proxy *Proxy) error {
} }
proxy.registeredServers = append(proxy.registeredServers, RegisteredServer{name: serverName, stamp: stamp}) proxy.registeredServers = append(proxy.registeredServers, RegisteredServer{name: serverName, stamp: stamp})
} }
rand.Shuffle(len(proxy.registeredServers), func(i, j int) {
proxy.registeredServers[i], proxy.registeredServers[j] = proxy.registeredServers[j], proxy.registeredServers[i]
})
proxy.updateRegisteredServers() proxy.updateRegisteredServers()
rs1 := proxy.registeredServers
rs2 := proxy.serversInfo.registeredServers
rand.Shuffle(len(rs1), func(i, j int) {
rs1[i], rs1[j] = rs1[j], rs1[i]
})
rand.Shuffle(len(rs2), func(i, j int) {
rs2[i], rs2[j] = rs2[j], rs2[i]
})
return nil return nil
} }

View File

@ -348,7 +348,6 @@ func (proxy *Proxy) updateRegisteredServers() error {
} }
} }
} }
} }
for _, registeredServer := range proxy.registeredServers { for _, registeredServer := range proxy.registeredServers {
proxy.serversInfo.registerServer(registeredServer.name, registeredServer.stamp) proxy.serversInfo.registerServer(registeredServer.name, registeredServer.stamp)