1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-22 01:57:12 -05:00
This commit is contained in:
Darien Raymond 2018-11-22 19:07:49 +01:00
parent 9d17221266
commit 39a092b178
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
2 changed files with 10 additions and 7 deletions

View File

@ -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 {

View File

@ -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