feat: custom ip api (#100)
* feat: custom ip api feat: add switch for nat and query Co-authored-by: ChrisKim <[email protected]> * remove dash.cloudflare --------- Co-authored-by: ChrisKim <[email protected]> Co-authored-by: naiba <[email protected]>
This commit is contained in:
+13
-3
@@ -15,9 +15,11 @@ import (
|
||||
var (
|
||||
cfList = []string{
|
||||
"https://blog.cloudflare.com/cdn-cgi/trace",
|
||||
"https://dash.cloudflare.com/cdn-cgi/trace",
|
||||
"https://hostinger.com/cdn-cgi/trace",
|
||||
"https://ahrefs.com/cdn-cgi/trace",
|
||||
"https://developers.cloudflare.com/cdn-cgi/trace",
|
||||
}
|
||||
CustomEndpoints []string
|
||||
GeoQueryIP, CachedCountryCode string
|
||||
GeoQueryIPChanged bool = true
|
||||
httpClientV4 = util.NewSingleStackHTTPClient(time.Second*20, time.Second*5, time.Second*10, false)
|
||||
@@ -32,11 +34,19 @@ func FetchIP(useIPv6CountryCode bool) *pb.GeoIP {
|
||||
var ipv4, ipv6 string
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
ipv4 = fetchIP(cfList, false)
|
||||
if len(CustomEndpoints) > 0 {
|
||||
ipv4 = fetchIP(CustomEndpoints, false)
|
||||
} else {
|
||||
ipv4 = fetchIP(cfList, false)
|
||||
}
|
||||
}()
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
ipv6 = fetchIP(cfList, true)
|
||||
if len(CustomEndpoints) > 0 {
|
||||
ipv6 = fetchIP(CustomEndpoints, true)
|
||||
} else {
|
||||
ipv6 = fetchIP(cfList, true)
|
||||
}
|
||||
}()
|
||||
wg.Wait()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user