修复bug

This commit is contained in:
qaq
2025-08-08 19:52:53 +08:00
parent 791cde3eb2
commit d675effd58
14 changed files with 123 additions and 732 deletions
BIN
View File
Binary file not shown.
+1 -1
View File
@@ -119,7 +119,7 @@ func main() {
log := xlogger.NewLogger()
logger.SetDefault(log)
wsReporter := socket.StartWebSocketReporterWithConfig(config.Addr, config.Secret, "1.1.0")
wsReporter := socket.StartWebSocketReporterWithConfig(config.Addr, config.Secret, "1.1.1")
defer wsReporter.Stop()
service.SetHTTPReportURL(config.Addr, config.Secret)
+2 -17
View File
@@ -2,9 +2,9 @@ package port
import (
"fmt"
"net"
"os/exec"
"strconv"
"strings"
"time"
)
@@ -21,7 +21,7 @@ func ForceClosePortConnections(addr string) (err error) {
return nil
}
_, portStr, err := splitHostPort(addr)
_, portStr, err := net.SplitHostPort(addr)
if err != nil {
fmt.Printf("⚠️ 地址解析失败: %v\n", err)
return nil
@@ -56,18 +56,3 @@ func ForceClosePortConnections(addr string) (err error) {
fmt.Printf("✅ 正在断开端口 %d 上的所有连接...\n", port)
return nil
}
func splitHostPort(addr string) (string, string, error) {
if !strings.Contains(addr, ":") {
return "", "", fmt.Errorf("missing port in address")
}
return netSplitHostPortCompat(addr)
}
func netSplitHostPortCompat(addr string) (string, string, error) {
lastColon := strings.LastIndex(addr, ":")
if lastColon < 0 {
return "", "", fmt.Errorf("missing port")
}
return addr[:lastColon], addr[lastColon+1:], nil
}