Pick random upstream servers; we'll do better later
This commit is contained in:
parent
805c8a822f
commit
7279699210
|
@ -3,6 +3,7 @@ package main
|
||||||
import (
|
import (
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"log"
|
"log"
|
||||||
|
"math/rand"
|
||||||
"net"
|
"net"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
@ -64,7 +65,7 @@ func (serversInfo *ServersInfo) registerServer(proxy *Proxy, name string, server
|
||||||
|
|
||||||
func (serversInfo *ServersInfo) getOne() *ServerInfo {
|
func (serversInfo *ServersInfo) getOne() *ServerInfo {
|
||||||
serversInfo.RLock()
|
serversInfo.RLock()
|
||||||
serverInfo := &serversInfo.inner[0]
|
serverInfo := &serversInfo.inner[rand.Intn(len(serversInfo.inner))]
|
||||||
serversInfo.RUnlock()
|
serversInfo.RUnlock()
|
||||||
return serverInfo
|
return serverInfo
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue