Skip to content

Commit

Permalink
Merge branch 'bug/resolve-addr' @Release
Browse files Browse the repository at this point in the history
  • Loading branch information
wweir committed Feb 16, 2019
2 parents 4883e24 + 092e3cf commit e8c6d84
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions proxy/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit e8c6d84

Please sign in to comment.