From 092e3cf60ab0273f8f98912a7f67823a8d7b5caf Mon Sep 17 00:00:00 2001 From: wweir Date: Sat, 16 Feb 2019 22:12:42 +0800 Subject: [PATCH] Fix resolve for dhcp --- proxy/client.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) 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()