Joyit 1 月之前
父節點
當前提交
efbc44b863
共有 4 個文件被更改,包括 4 次插入3 次删除
  1. 1 0
      conn/type.go
  2. 1 1
      host.go
  3. 1 1
      hub.go
  4. 1 1
      line.go

+ 1 - 0
conn/conn.go → conn/type.go

@@ -29,6 +29,7 @@ func (t MsgType) String() string {
 
 // 连接接口,代表一个原始的连接
 type Connect interface {
+	// io.ReadWriteCloser
 	WriteAuthInfo(channel string, auth []byte) (err error)
 	ReadAuthInfo() (proto string, version uint8, channel string, auth []byte, err error)
 	WriteRequest(id uint16, cmd string, data []byte) error

+ 1 - 1
host.go

@@ -21,7 +21,7 @@ type HostInfo struct {
 	Hash     string    `json:"hash,omitempty" yaml:"hash"`         // 连接验证使用,格式 method:key
 	Proxy    bool      `json:"proxy,omitempty" yaml:"proxy"`       // 是否代理
 	Nat      bool      `json:"nat,omitempty" yaml:"nat"`           // 是否是前端nat的方式处理
-	Priority int16     `json:"priority,omitempty" yaml:"priority"` // 优先级,-1 表示不可用,0 表示最高优先级(为了兼容没有优先级的节点),1-100 表示优先级别,数值越高优先级越高
+	Priority int16     `json:"priority,omitempty" yaml:"priority"` // 优先级,-1 表示不可用,0 表示最高优先级(为了兼容没有优先级的节点),1-100 表示优先级别,数值越高优先级越高,不过这是由应用端决定的规则
 	Errors   uint16    `json:"errors,omitempty" yaml:"errors"`     // 连接失败计数,如果成功了则重置为0
 	Updated  time.Time `json:"updated" yaml:"updated"`             // 节点信息刷新时间
 }

+ 1 - 1
hub.go

@@ -324,7 +324,7 @@ func (h *Hub) sendRequest(gd *GetData) (count int, err error) {
 		} else {
 			h.lines.Range(doit)
 		}
-		if count > 0 {
+		if count > 0 || gd.backchan == nil {
 			break
 		}
 		// 如果是客户端,并且有机会自动连接,则尝试自动连接

+ 1 - 1
line.go

@@ -252,7 +252,7 @@ func (c *Line) writePump() {
 			dr := time.Since(c.lastRead)
 			if dr > time.Duration(c.cf.PingInterval*3*int(time.Millisecond)) {
 				// 超时关闭当前的连接
-				log.Println("[Connect timeout and stop it]", c.channel)
+				log.Println("[Connect timeout]", c.channel)
 				// 有可能连接出现问题,断开并重新连接
 				// 检测到浏览器会出现休眠的状态,服务端就不主动关闭,只有客户端关闭
 				if c.host != nil {