Skip to content

Commit

Permalink
Merge branch 'Beta' into Meta
Browse files Browse the repository at this point in the history
  • Loading branch information
Skyxim committed Aug 29, 2022
2 parents 33abbdf + 3a8eb72 commit 5987f8e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
3 changes: 3 additions & 0 deletions adapter/outbound/hysteria.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ func (h *Hysteria) ListenPacketContext(ctx context.Context, metadata *C.Metadata
hyDialer: func() (net.PacketConn, error) {
return dialer.ListenPacket(ctx, "udp", "", h.Base.DialOptions(opts...)...)
},
remoteAddr: func(addr string) (net.Addr, error) {
return resolveUDPAddrWithPrefer("udp", addr, h.prefer)
},
}
udpConn, err := h.client.DialUDP(&hdc)
if err != nil {
Expand Down
7 changes: 5 additions & 2 deletions adapter/outbound/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func resolveUDPAddrWithPrefer(network, address string, prefer C.DNSPrefer) (*net
ip = fallback
}
default:
// C.IPv4Prefer, C.DualStack and other
// C.IPv4Prefer, C.DualStack and other
var ips []netip.Addr
ips, err = resolver.ResolveAllIPProxyServerHost(host)
var fallback netip.Addr
Expand All @@ -119,7 +119,10 @@ func resolveUDPAddrWithPrefer(network, address string, prefer C.DNSPrefer) (*net
}
}
}
ip = fallback

if !ip.IsValid() && fallback.IsValid() {
ip = fallback
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion docs/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ proxies:
# ipv4-prefer:优先使用 IPv4 对于 TCP 会进行双栈解析,并发链接但是优先使用 IPv4 链接,
# UDP 则为双栈解析,获取结果中的第一个 IPv4
# ipv6-prefer 同 ipv4-prefer
# 现有协议都支持此参数
# 现有协议都支持此参数,TCP 效果仅在开启 tcp-concurrent 生效
- name: "ss2"
type: ss
server: server
Expand Down

0 comments on commit 5987f8e

Please sign in to comment.