1
0
mirror of https://github.com/Mrs4s/go-cqhttp.git synced 2025-05-04 19:17:37 +08:00

Fix: SignServer TCP ping for custom port (#2353)

This commit is contained in:
xiwangly 2023-08-23 13:02:42 +08:00 committed by GitHub
parent da9f03fa47
commit d85d697fc2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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