Joyit пре 4 недеља
родитељ
комит
4aef3e2436
1 измењених фајлова са 4 додато и 3 уклоњено
  1. 4 3
      hub.go

+ 4 - 3
hub.go

@@ -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)