Commit 5a816d62 authored by Jordan Sissel's avatar Jordan Sissel
Browse files

Do DNS lookups and select a random host.

This fixes a regression entered during the C -> Go port where the dns
randomizer feature was lost.
parent 4a9df195
......@@ -142,8 +142,18 @@ func connect(config *NetworkConfig) (socket *tls.Conn) {
for {
// Pick a random server from the list.
address := config.Servers[rand.Int() % len(config.Servers)]
log.Printf("Connecting to %s\n", address)
host := config.Servers[rand.Int() % len(config.Servers)]
addresses, err := net.LookupHost(host)
if err != nil {
log.Printf("DNS lookup failure \"%s\": %s\n", host, err);
time.Sleep(1 * time.Second)
address := addresses[rand.Int() % len(addresses)]
log.Printf("Connecting to %s (%s) \n", address, host)
tcpsocket, err := net.DialTimeout("tcp", address, config.timeout)
if err != nil {
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment