Signed-off-by: arraykeys@gmail.com <arraykeys@gmail.com>
This commit is contained in:
@ -190,6 +190,9 @@ func (s *HTTP) OutToTCP(useProxy bool, address string, inConn *net.Conn, req *ut
|
|||||||
}
|
}
|
||||||
var outConn net.Conn
|
var outConn net.Conn
|
||||||
var _outConn interface{}
|
var _outConn interface{}
|
||||||
|
tryCount := 0
|
||||||
|
maxTryCount := 5
|
||||||
|
for {
|
||||||
if useProxy {
|
if useProxy {
|
||||||
if *s.cfg.ParentType == "ssh" {
|
if *s.cfg.ParentType == "ssh" {
|
||||||
outConn, err = s.getSSHConn(address)
|
outConn, err = s.getSSHConn(address)
|
||||||
@ -202,6 +205,14 @@ func (s *HTTP) OutToTCP(useProxy bool, address string, inConn *net.Conn, req *ut
|
|||||||
} else {
|
} else {
|
||||||
outConn, err = utils.ConnectHost(address, *s.cfg.Timeout)
|
outConn, err = utils.ConnectHost(address, *s.cfg.Timeout)
|
||||||
}
|
}
|
||||||
|
tryCount++
|
||||||
|
if err == nil || tryCount > maxTryCount {
|
||||||
|
break
|
||||||
|
} else {
|
||||||
|
log.Printf("connect to %s , err:%s,retrying...", *s.cfg.Parent, err)
|
||||||
|
time.Sleep(time.Second * 2)
|
||||||
|
}
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("connect to %s , err:%s", *s.cfg.Parent, err)
|
log.Printf("connect to %s , err:%s", *s.cfg.Parent, err)
|
||||||
utils.CloseConn(inConn)
|
utils.CloseConn(inConn)
|
||||||
@ -242,7 +253,7 @@ RETRY:
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
wait := make(chan bool, 1)
|
wait := make(chan bool, 1)
|
||||||
func() {
|
go func() {
|
||||||
defer func() {
|
defer func() {
|
||||||
if err == nil {
|
if err == nil {
|
||||||
err = recover()
|
err = recover()
|
||||||
|
|||||||
@ -392,7 +392,7 @@ func (s *Socks) proxyTCP(inConn *net.Conn, methodReq socks.MethodsRequest, reque
|
|||||||
var err interface{}
|
var err interface{}
|
||||||
useProxy := true
|
useProxy := true
|
||||||
tryCount := 0
|
tryCount := 0
|
||||||
maxTryCount := 3
|
maxTryCount := 5
|
||||||
for {
|
for {
|
||||||
if *s.cfg.Always {
|
if *s.cfg.Always {
|
||||||
outConn, err = s.getOutConn(methodReq.Bytes(), request.Bytes(), request.Addr())
|
outConn, err = s.getOutConn(methodReq.Bytes(), request.Bytes(), request.Addr())
|
||||||
@ -414,6 +414,7 @@ func (s *Socks) proxyTCP(inConn *net.Conn, methodReq socks.MethodsRequest, reque
|
|||||||
break
|
break
|
||||||
} else {
|
} else {
|
||||||
log.Printf("get out conn fail,%s,retrying...", err)
|
log.Printf("get out conn fail,%s,retrying...", err)
|
||||||
|
time.Sleep(time.Second * 2)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user