Update ipregion.sh
This commit is contained in:
+7
-22
@@ -924,47 +924,32 @@ get_registered_country() {
|
||||
|
||||
get_server_country() {
|
||||
local ip_version="$1"
|
||||
local response country_code country_name
|
||||
local response country_code
|
||||
|
||||
# Используем Cloudflare как основной источник (быстрый и надежный)
|
||||
response=$(make_request GET "https://speed.cloudflare.com/meta" --ip-version "$ip_version")
|
||||
# 1. ipapi.co — самый стабильный и не ебет мозг
|
||||
response=$(make_request GET "https://ipapi.co/json" --ip-version "$ip_version")
|
||||
country_code=$(process_json "$response" ".country_code")
|
||||
|
||||
if [[ -n "$response" && "$response" != *"error"* ]]; then
|
||||
country_code=$(process_json "$response" ".country")
|
||||
if [[ -n "$country_code" && "$country_code" != "null" ]]; then
|
||||
echo "$country_code"
|
||||
return
|
||||
fi
|
||||
fi
|
||||
|
||||
# Если Cloudflare не сработал, пробуем MaxMind
|
||||
# 2. MaxMind — fallback
|
||||
response=$(make_request GET "https://geoip.maxmind.com/geoip/v2.1/city/me" \
|
||||
--header "Referer: https://www.maxmind.com" \
|
||||
--ip-version "$ip_version")
|
||||
|
||||
if [[ -n "$response" && "$response" != *"error"* ]]; then
|
||||
country_code=$(process_json "$response" ".country.iso_code")
|
||||
|
||||
if [[ -n "$country_code" && "$country_code" != "null" ]]; then
|
||||
echo "$country_code"
|
||||
return
|
||||
fi
|
||||
fi
|
||||
|
||||
# Если и MaxMind не сработал, пробуем IPAPI.co
|
||||
response=$(make_request GET "https://ipapi.co/json" --ip-version "$ip_version")
|
||||
|
||||
if [[ -n "$response" && "$response" != *"error"* ]]; then
|
||||
country_code=$(process_json "$response" ".country_code")
|
||||
if [[ -n "$country_code" && "$country_code" != "null" ]]; then
|
||||
echo "$country_code"
|
||||
return
|
||||
fi
|
||||
fi
|
||||
|
||||
# Если ничего не сработало
|
||||
echo "Unknown"
|
||||
}
|
||||
|
||||
|
||||
get_iata_location() {
|
||||
local iata_code="$1"
|
||||
local url="https://www.air-port-codes.com/api/v1/single"
|
||||
|
||||
Reference in New Issue
Block a user