Pick random upstream servers; we'll do better later

This commit is contained in:
Frank Denis 2018-01-09 17:19:03 +01:00
parent 805c8a822f
commit 7279699210
1 changed files with 2 additions and 1 deletions

View File

@ -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
}