From d85d697fc23019a1ea05ef722c65896f0b617f8e Mon Sep 17 00:00:00 2001 From: xiwangly <1334850101@qq.com> Date: Wed, 23 Aug 2023 13:02:42 +0800 Subject: [PATCH] Fix: SignServer TCP ping for custom port (#2353) --- cmd/gocq/login.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/cmd/gocq/login.go b/cmd/gocq/login.go index 80442b938..8087cbeeb 100644 --- a/cmd/gocq/login.go +++ b/cmd/gocq/login.go @@ -7,6 +7,7 @@ import ( "fmt" "image" "image/png" + "net" "net/http" "net/url" "os" @@ -541,7 +542,18 @@ func signWaitServer() bool { log.Warnf("连接到签名服务器出现错误: %v", err) continue } - r := utils.RunTCPPingLoop(u.Host, 4) + host := u.Hostname() + port := u.Port() + if port == "" { + switch u.Scheme { + case "https": + port = "443" + case "http": + port = "80" + } + } + hostPort := net.JoinHostPort(host, port) + r := utils.RunTCPPingLoop(hostPort, 4) if r.PacketsLoss > 0 { log.Warnf("连接到签名服务器出现错误: 丢包%d/%d 时延%dms", r.PacketsLoss, r.PacketsSent, r.AvgTimeMill) continue