Joyit преди 3 месеца
родител
ревизия
fc17436407
променени са 2 файла, в които са добавени 8 реда и са изтрити 1 реда
  1. 4 1
      hub.go
  2. 4 0
      type.go

+ 4 - 1
hub.go

@@ -835,7 +835,10 @@ func (h *Hub) ConnectToServerX(channel string, force bool, host *HostInfo) {
 			log.Println("[ConnectToServerX] not connect host func found")
 			return
 		}
-		host, _ = h.connectHostFunc(channel, Direct)
+		host, err := h.connectHostFunc(channel, Direct)
+		if err != nil {
+			log.Println("[ConnectToServerX] connectHostFunc:", err)
+		}
 		if host == nil {
 			log.Println("[ConnectToServerX] not host found for channel:", channel)
 			return

+ 4 - 0
type.go

@@ -254,6 +254,10 @@ func (h *HostInfo) Url() string {
 
 // 输出代表一个节点的关键信息
 func (h *HostInfo) Key() string {
+	if h == nil {
+		// 避免空出错
+		return ""
+	}
 	return fmt.Sprintf("%s%d://%s:%d%s", h.Proto, h.Version, h.Host, h.Port, h.Path)
 }