|
|
@@ -784,7 +784,8 @@ func (h *Hub) ConnectToServerX(channel string, force bool, host *conn.HostInfo)
|
|
|
} else {
|
|
|
hostType = HostTypeProxy
|
|
|
}
|
|
|
- count++
|
|
|
+ // 循环不同类型,避免一直使用代理
|
|
|
+ count = (count + 1) % 8
|
|
|
hx, err := h.connectHostFunc(channel, hostType)
|
|
|
if err == nil {
|
|
|
err := h.ConnectToServer(channel, force, hx, true)
|
|
|
@@ -823,13 +824,13 @@ func (h *Hub) checkConnect() {
|
|
|
case <-proxyTicker.C:
|
|
|
now := time.Now().UnixMilli()
|
|
|
h.lines.Range(func(id int, line *Line) bool {
|
|
|
- if line.host != nil && now-line.lastRead.UnixMilli() > int64(h.cf.ProxyTimeout) {
|
|
|
+ if line.host != nil && line.state == StateProxied && now-line.started.UnixMilli() > int64(h.cf.ProxyTimeout) {
|
|
|
host, err := h.connectHostFunc(line.channel, HostTypeDirect)
|
|
|
if err != nil {
|
|
|
log.Println("[proxyTicker connectHostFunc]", err)
|
|
|
return false
|
|
|
}
|
|
|
- if host != nil {
|
|
|
+ if host != nil && !host.Proxy {
|
|
|
err = h.ConnectToServer(line.channel, true, host, line.autoReconnect)
|
|
|
if err != nil {
|
|
|
log.Println("[checkProxyConnect ConnectToServer]", err)
|