mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-12-22 01:57:12 -05:00
fix #1427
This commit is contained in:
parent
9d17221266
commit
39a092b178
@ -76,8 +76,9 @@ func NewStaticHosts(hosts []*Config_HostMapping, legacy map[string]*net.IPOrDoma
|
||||
func filterIP(ips []net.IP, option IPOption) []net.IP {
|
||||
filtered := make([]net.IP, 0, len(ips))
|
||||
for _, ip := range ips {
|
||||
if (len(ip) == net.IPv4len && option.IPv4Enable) || (len(ip) == net.IPv6len && option.IPv6Enable) {
|
||||
filtered = append(filtered, ip)
|
||||
parsed := net.IPAddress(ip)
|
||||
if (parsed.Family().IsIPv4() && option.IPv4Enable) || (parsed.Family().IsIPv6() && option.IPv6Enable) {
|
||||
filtered = append(filtered, parsed.IP())
|
||||
}
|
||||
}
|
||||
if len(filtered) == 0 {
|
||||
|
@ -2,8 +2,8 @@ package localdns
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net"
|
||||
|
||||
"v2ray.com/core/common/net"
|
||||
"v2ray.com/core/features/dns"
|
||||
)
|
||||
|
||||
@ -43,8 +43,9 @@ func (c *Client) LookupIPv4(host string) ([]net.IP, error) {
|
||||
}
|
||||
var ipv4 []net.IP
|
||||
for _, ip := range ips {
|
||||
if len(ip) == net.IPv4len {
|
||||
ipv4 = append(ipv4, ip)
|
||||
parsed := net.IPAddress(ip)
|
||||
if parsed.Family().IsIPv4() {
|
||||
ipv4 = append(ipv4, parsed.IP())
|
||||
}
|
||||
}
|
||||
return ipv4, nil
|
||||
@ -57,8 +58,9 @@ func (c *Client) LookupIPv6(host string) ([]net.IP, error) {
|
||||
}
|
||||
var ipv6 []net.IP
|
||||
for _, ip := range ips {
|
||||
if len(ip) == net.IPv6len {
|
||||
ipv6 = append(ipv6, ip)
|
||||
parsed := net.IPAddress(ip)
|
||||
if parsed.Family().IsIPv6() {
|
||||
ipv6 = append(ipv6, parsed.IP())
|
||||
}
|
||||
}
|
||||
return ipv6, nil
|
||||
|
Loading…
Reference in New Issue
Block a user