mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-11-16 11:42:43 +08:00
fix: unmap 4in6 ip in wireguard
This commit is contained in:
parent
284b01ca38
commit
9c08e936f9
|
@ -146,7 +146,12 @@ func NewWireGuard(option WireGuardOption) (*WireGuard, error) {
|
|||
return address.AddrPort(), nil
|
||||
}
|
||||
udpAddr, err := resolveUDPAddrWithPrefer(ctx, "udp", address.String(), outbound.prefer)
|
||||
return udpAddr.AddrPort(), err
|
||||
if err != nil {
|
||||
return netip.AddrPort{}, err
|
||||
}
|
||||
// net.ResolveUDPAddr maybe return 4in6 address, so unmap at here
|
||||
addrPort := udpAddr.AddrPort()
|
||||
return netip.AddrPortFrom(addrPort.Addr().Unmap(), addrPort.Port()), nil
|
||||
}
|
||||
|
||||
var reserved [3]uint8
|
||||
|
|
|
@ -324,7 +324,7 @@ func (r *Resolver) ipExchange(ctx context.Context, m *D.Msg) (msg *D.Msg, err er
|
|||
func (r *Resolver) lookupIP(ctx context.Context, host string, dnsType uint16) (ips []netip.Addr, err error) {
|
||||
ip, err := netip.ParseAddr(host)
|
||||
if err == nil {
|
||||
isIPv4 := ip.Is4()
|
||||
isIPv4 := ip.Is4() || ip.Is4In6()
|
||||
if dnsType == D.TypeAAAA && !isIPv4 {
|
||||
return []netip.Addr{ip}, nil
|
||||
} else if dnsType == D.TypeA && isIPv4 {
|
||||
|
|
Loading…
Reference in New Issue
Block a user