From 7279699210e6c4cf4fc8732ac6dfcee00cfcedfe Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Tue, 9 Jan 2018 17:19:03 +0100 Subject: [PATCH] Pick random upstream servers; we'll do better later --- serversInfo.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/serversInfo.go b/serversInfo.go index 8b481fe1..b732e561 100644 --- a/serversInfo.go +++ b/serversInfo.go @@ -3,6 +3,7 @@ package main import ( "encoding/hex" "log" + "math/rand" "net" "strings" "sync" @@ -64,7 +65,7 @@ func (serversInfo *ServersInfo) registerServer(proxy *Proxy, name string, server func (serversInfo *ServersInfo) getOne() *ServerInfo { serversInfo.RLock() - serverInfo := &serversInfo.inner[0] + serverInfo := &serversInfo.inner[rand.Intn(len(serversInfo.inner))] serversInfo.RUnlock() return serverInfo }