mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2026-03-04 12:57:31 +00:00
chore: more unmap for 4in6 address
This commit is contained in:
@@ -77,7 +77,7 @@ func NewHostValue(value any) (HostValue, error) {
|
||||
isDomain = false
|
||||
for _, str := range valueArr {
|
||||
if ip, err := netip.ParseAddr(str); err == nil {
|
||||
ips = append(ips, ip)
|
||||
ips = append(ips, ip.Unmap())
|
||||
} else {
|
||||
return HostValue{}, err
|
||||
}
|
||||
@@ -85,7 +85,7 @@ func NewHostValue(value any) (HostValue, error) {
|
||||
} else if len(valueArr) == 1 {
|
||||
host := valueArr[0]
|
||||
if ip, err := netip.ParseAddr(host); err == nil {
|
||||
ips = append(ips, ip)
|
||||
ips = append(ips, ip.Unmap())
|
||||
isDomain = false
|
||||
} else {
|
||||
domain = host
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/netip"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/metacubex/mihomo/common/utils"
|
||||
@@ -68,7 +67,8 @@ func LookupIPv4WithResolver(ctx context.Context, host string, r Resolver) ([]net
|
||||
|
||||
ip, err := netip.ParseAddr(host)
|
||||
if err == nil {
|
||||
if ip.Is4() || ip.Is4In6() {
|
||||
ip = ip.Unmap()
|
||||
if ip.Is4() {
|
||||
return []netip.Addr{ip}, nil
|
||||
}
|
||||
return []netip.Addr{}, ErrIPVersion
|
||||
@@ -117,7 +117,8 @@ func LookupIPv6WithResolver(ctx context.Context, host string, r Resolver) ([]net
|
||||
}
|
||||
|
||||
if ip, err := netip.ParseAddr(host); err == nil {
|
||||
if strings.Contains(host, ":") {
|
||||
ip = ip.Unmap()
|
||||
if ip.Is6() {
|
||||
return []netip.Addr{ip}, nil
|
||||
}
|
||||
return nil, ErrIPVersion
|
||||
@@ -166,6 +167,7 @@ func LookupIPWithResolver(ctx context.Context, host string, r Resolver) ([]netip
|
||||
}
|
||||
|
||||
if ip, err := netip.ParseAddr(host); err == nil {
|
||||
ip = ip.Unmap()
|
||||
return []netip.Addr{ip}, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user