mirror of
https://github.com/Buriburizaem0n/nezha_domains.git
synced 2026-02-04 04:30:05 +00:00
installer: use multiple geoip api to determine location (#393)
This commit is contained in:
@@ -48,6 +48,19 @@ err() {
|
||||
printf "${red}$*${plain}\n" >&2
|
||||
}
|
||||
|
||||
geo_check() {
|
||||
api_list="http://api.myip.la/en?json https://api.ip.sb/geoip https://ipapi.co/json http://ip-api.com/json/"
|
||||
ua="Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/81.0"
|
||||
set -- $api_list
|
||||
for url in $api_list; do
|
||||
text="$(curl -A $ua -m 10 -s $url)"
|
||||
if echo $text | grep -qw 'CN'; then
|
||||
isCN=true
|
||||
break
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
pre_check() {
|
||||
## os_arch
|
||||
if uname -m | grep -q 'x86_64'; then
|
||||
@@ -66,8 +79,9 @@ pre_check() {
|
||||
|
||||
## China_IP
|
||||
if [ -z "$CN" ]; then
|
||||
if curl -m 10 -s http://ip-api.com/json |grep 'country' |grep -q 'China'; then
|
||||
echo "According to the information provided by ip-api.com, the current IP may be in China"
|
||||
geo_check
|
||||
if [ ! -z "$isCN" ]; then
|
||||
echo "According to the information provided by various geoip api, the current IP may be in China"
|
||||
printf "Will the installation be done with a Chinese Mirror? [Y/n] (Custom Mirror Input 3): "
|
||||
read -r input
|
||||
case $input in
|
||||
|
||||
Reference in New Issue
Block a user