fix(超时时间): 修复超时时间硬编码

This commit is contained in:
2026-01-22 20:18:47 +08:00
parent 1107d353e3
commit 32b8a908db
3 changed files with 6 additions and 6 deletions
+3 -3
View File
@@ -180,9 +180,9 @@ func (c *socks5PacketConn) SetWriteDeadline(t time.Time) error {
}
// DialSocks5UDP 建立SOCKS5 UDP关联
// 入参: proxyAddr 代理服务器地址, network 网络协议(udp/udp4/udp6)
// 入参: proxyAddr 代理服务器地址, network 网络协议(udp/udp4/udp6), timeout 超时时间
// 返回: conn 数据包连接, err 连接错误
func DialSocks5UDP(proxyAddr, network string) (net.PacketConn, error) {
func DialSocks5UDP(proxyAddr, network string, timeout time.Duration) (net.PacketConn, error) {
var host string
if strings.Contains(proxyAddr, "://") {
u, err := url.Parse(proxyAddr)
@@ -200,7 +200,7 @@ func DialSocks5UDP(proxyAddr, network string) (net.PacketConn, error) {
case "udp6":
tcpNetwork = "tcp6"
}
conn, err := net.DialTimeout(tcpNetwork, host, 5*time.Second)
conn, err := net.DialTimeout(tcpNetwork, host, timeout)
if err != nil {
return nil, err
}