diff --git a/proxy/client.go b/proxy/client.go index 5a03de6..f6256da 100644 --- a/proxy/client.go +++ b/proxy/client.go @@ -31,17 +31,21 @@ func NewClient(netType string) Client { func StartClient(netType, server, cipher, password, listenIP string) { connCh := listenLocal(listenIP, []string{"80", "443"}) client := NewClient(netType) - if addr, err := net.ResolveTCPAddr("tcp", server); err != nil { - glog.Fatalln(err) - } else { - server = addr.String() - } + resolved := false glog.Infoln("Client started.") for { conn := <-connCh glog.V(1).Infof("new conn from (%s) to (%s)", conn.RemoteAddr(), server) + if !resolved { + if addr, err := net.ResolveTCPAddr("tcp", server); err != nil { + glog.Fatalln(err) + } else { + server = addr.String() + } + } + rc, err := client.Dial(server) if err != nil { conn.Close()