Skip to content

Commit 5987f8e

Browse files
author
Skyxim
committed
Merge branch 'Beta' into Meta
2 parents 33abbdf + 3a8eb72 commit 5987f8e

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

adapter/outbound/hysteria.go

+3
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ func (h *Hysteria) ListenPacketContext(ctx context.Context, metadata *C.Metadata
7272
hyDialer: func() (net.PacketConn, error) {
7373
return dialer.ListenPacket(ctx, "udp", "", h.Base.DialOptions(opts...)...)
7474
},
75+
remoteAddr: func(addr string) (net.Addr, error) {
76+
return resolveUDPAddrWithPrefer("udp", addr, h.prefer)
77+
},
7578
}
7679
udpConn, err := h.client.DialUDP(&hdc)
7780
if err != nil {

adapter/outbound/util.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ func resolveUDPAddrWithPrefer(network, address string, prefer C.DNSPrefer) (*net
104104
ip = fallback
105105
}
106106
default:
107-
// C.IPv4Prefer, C.DualStack and other
107+
// C.IPv4Prefer, C.DualStack and other
108108
var ips []netip.Addr
109109
ips, err = resolver.ResolveAllIPProxyServerHost(host)
110110
var fallback netip.Addr
@@ -119,7 +119,10 @@ func resolveUDPAddrWithPrefer(network, address string, prefer C.DNSPrefer) (*net
119119
}
120120
}
121121
}
122-
ip = fallback
122+
123+
if !ip.IsValid() && fallback.IsValid() {
124+
ip = fallback
125+
}
123126
}
124127
}
125128

docs/config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ proxies:
169169
# ipv4-prefer:优先使用 IPv4 对于 TCP 会进行双栈解析,并发链接但是优先使用 IPv4 链接,
170170
# UDP 则为双栈解析,获取结果中的第一个 IPv4
171171
# ipv6-prefer 同 ipv4-prefer
172-
# 现有协议都支持此参数
172+
# 现有协议都支持此参数,TCP 效果仅在开启 tcp-concurrent 生效
173173
- name: "ss2"
174174
type: ss
175175
server: server

0 commit comments

Comments
 (0)