fix: harden address parsing edge cases

This commit is contained in:
ZacharyZcR
2026-06-01 04:03:46 +08:00
parent 8ec96bfe6d
commit 569d21a8bc
43 changed files with 273 additions and 137 deletions
+3 -2
View File
@@ -2,7 +2,8 @@ package common
import (
"errors"
"fmt"
"net"
"strconv"
"strings"
"sync"
@@ -30,7 +31,7 @@ type HostInfo struct {
// Target 返回 host:port 格式字符串
func (h *HostInfo) Target() string {
return fmt.Sprintf("%s:%d", h.Host, h.Port)
return net.JoinHostPort(h.Host, strconv.Itoa(h.Port))
}
// =============================================================================