From b8ca53054d0d5bdb178299b10ab1ff002524a2c9 Mon Sep 17 00:00:00 2001 From: 233boy <31657650+233boy@users.noreply.github.com> Date: Thu, 10 Nov 2022 09:59:57 +0800 Subject: [PATCH] prefer ipv4, fix #995 #996 --- install.sh | 3 ++- v2ray.sh | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/install.sh b/install.sh index 4b6ce1a..35e6db6 100644 --- a/install.sh +++ b/install.sh @@ -886,7 +886,8 @@ get_ip() { # [[ -z $ip ]] && ip=$(curl -s https://api.myip.com | grep -oE "([0-9]{1,3}\.){3}[0-9]{1,3}") # [[ -z $ip ]] && ip=$(curl -s icanhazip.com) # [[ -z $ip ]] && ip=$(curl -s myip.ipip.net | grep -oE "([0-9]{1,3}\.){3}[0-9]{1,3}") - export "$(wget -qO- https://dash.cloudflare.com/cdn-cgi/trace | grep ip=)" >/dev/null 2>&1 + export "$(wget -4 -qO- https://dash.cloudflare.com/cdn-cgi/trace | grep ip=)" >/dev/null 2>&1 + [[ -z $ip ]] && export "$(wget -6 -qO- https://dash.cloudflare.com/cdn-cgi/trace | grep ip=)" >/dev/null 2>&1 [[ -z $ip ]] && echo -e "\n$red 获取IP失败, 这垃圾小鸡扔了吧!$none\n" && exit } diff --git a/v2ray.sh b/v2ray.sh index 41ba2e4..6912fff 100644 --- a/v2ray.sh +++ b/v2ray.sh @@ -10,7 +10,7 @@ none='\e[0m' # Root [[ $(id -u) != 0 ]] && echo -e " 哎呀……请使用 ${red}root ${none}用户运行 ${yellow}~(^_^) ${none}" && exit 1 -_version="v3.66" +_version="v3.67" cmd="apt-get" @@ -2542,7 +2542,8 @@ get_ip() { # [[ -z $ip ]] && ip=$(curl -s https://api.myip.com | grep -oE "([0-9]{1,3}\.){3}[0-9]{1,3}") # [[ -z $ip ]] && ip=$(curl -s icanhazip.com) # [[ -z $ip ]] && ip=$(curl -s myip.ipip.net | grep -oE "([0-9]{1,3}\.){3}[0-9]{1,3}") - export "$(wget -qO- https://dash.cloudflare.com/cdn-cgi/trace | grep ip=)" >/dev/null 2>&1 + export "$(wget -4 -qO- https://dash.cloudflare.com/cdn-cgi/trace | grep ip=)" >/dev/null 2>&1 + [[ -z $ip ]] && export "$(wget -6 -qO- https://dash.cloudflare.com/cdn-cgi/trace | grep ip=)" >/dev/null 2>&1 [[ -z $ip ]] && echo -e "\n$red 获取IP失败, 这垃圾小鸡扔了吧!$none\n" && exit }