🚸 优化NAT64机器取IP场景

This commit is contained in:
naiba
2021-07-13 10:59:13 +08:00
parent 32cb05e8cd
commit fea7858297
2 changed files with 11 additions and 6 deletions

View File

@@ -5,6 +5,7 @@ import (
"fmt"
"io/ioutil"
"net/http"
"strings"
"time"
"github.com/naiba/nezha/pkg/utils"
@@ -64,6 +65,14 @@ func fetchGeoIP(servers []string, isV6 bool) geoIP {
if err != nil {
continue
}
// 没取到 v6 IP
if isV6 && !strings.Contains(ip.IP, ":") {
continue
}
// 没取到 v4 IP
if !isV6 && !strings.Contains(ip.IP, ".") {
continue
}
if ip.IP == "" && ip.Query != "" {
ip.IP = ip.Query
}