fix #134
This commit is contained in:
arraykeys@gmail.com
2018-12-19 17:28:24 +08:00
parent db43daea0b
commit ed1e7253f3
2 changed files with 16 additions and 6 deletions

View File

@ -2,6 +2,8 @@ proxy更新日志
v6.7
1.HTTP(S)\SOCKS5代理,API认证功能,发送给认证接口的参数增加了本地IP,local_ip字段,
代表用户访问的是本地服务器的哪个IP.
2.fix #194
3.fix #134
v6.6
1.优化了limitconn的关闭逻辑,释放更多资源.

View File

@ -210,7 +210,7 @@ func (s *HTTP) InitService() (err error) {
return
}
conn, err := utils.ConnectHost(s.Resolve(s.lb.Select("", *s.cfg.LoadBalanceOnlyHA)), *s.cfg.Timeout*2)
if err == nil {
if err == nil && conn != nil {
conn.SetDeadline(time.Now().Add(time.Millisecond * time.Duration(*s.cfg.Timeout)))
_, err = conn.Write([]byte{0})
conn.SetDeadline(time.Time{})
@ -386,12 +386,17 @@ func (s *HTTP) OutToTCP(useProxy bool, address string, inConn *net.Conn, req *ut
}
if useProxy {
// s.log.Printf("%v", s.outPool)
if *s.cfg.ParentType == "ssh" {
outConn, err = s.getSSHConn(address)
} else {
selectAddr := (*inConn).RemoteAddr().String()
if utils.LBMethod(*s.cfg.LoadBalanceMethod) == lb.SELECT_HASH && *s.cfg.LoadBalanceHashTarget {
selectAddr = address
}
lbAddr = s.lb.Select(selectAddr, *s.cfg.LoadBalanceOnlyHA)
outConn, err = s.GetParentConn(lbAddr)
}
} else {
outConn, err = s.GetDirectConn(s.Resolve(address), inLocalAddr)
}
@ -515,6 +520,9 @@ func (s *HTTP) ConnectSSH() (err error) {
s.sshClient.Close()
}
s.sshClient, err = ssh.Dial("tcp", s.Resolve(s.lb.Select("", *s.cfg.LoadBalanceOnlyHA)), &config)
if err != nil {
s.log.Printf("connect to ssh %s fail", s.sshClient.RemoteAddr())
}
<-s.lockChn
return
}