From e46b51a8cf4a298c30c902b2e7a4bb63c262b6bf Mon Sep 17 00:00:00 2001 From: 233boy <31657650+233boy@users.noreply.github.com> Date: Thu, 3 Nov 2022 20:37:28 +0800 Subject: [PATCH] support ipv6 --- install.sh | 29 +++++++++++++++-------------- v2ray.sh | 29 +++++++++++++++-------------- 2 files changed, 30 insertions(+), 28 deletions(-) diff --git a/install.sh b/install.sh index f695d2e..4b6ce1a 100644 --- a/install.sh +++ b/install.sh @@ -742,18 +742,18 @@ domain_check() { # $cmd install dnsutils -y # fi # test_domain=$(dig $domain +short) - # test_domain=$(ping $domain -c 1 -4 | grep -oE -m1 "([0-9]{1,3}\.){3}[0-9]{1,3}") + test_domain=$(ping $domain -c 1 -W 2 | head -1) # test_domain=$(wget -qO- --header='accept: application/dns-json' "https://cloudflare-dns.com/dns-query?name=$domain&type=A" | grep -oE "([0-9]{1,3}\.){3}[0-9]{1,3}" | head -1) - test_domain=$(curl -sH 'accept: application/dns-json' "https://cloudflare-dns.com/dns-query?name=$domain&type=A" | grep -oE "([0-9]{1,3}\.){3}[0-9]{1,3}" | head -1) - if [[ $test_domain != $ip ]]; then + # test_domain=$(curl -sH 'accept: application/dns-json' "https://cloudflare-dns.com/dns-query?name=$domain&type=A" | grep -oE "([0-9]{1,3}\.){3}[0-9]{1,3}" | head -1) + if [[ ! $(echo $test_domain | grep $ip) ]]; then echo echo -e "$red 检测域名解析错误....$none" echo echo -e " 你的域名: $yellow$domain$none 未解析到: $cyan$ip$none" echo - echo -e " 你的域名当前解析到: $cyan$test_domain$none" + echo -e " PING 测试结果: $cyan$test_domain$none" echo - echo "备注...如果你的域名是使用 Cloudflare 解析的话..在 Status 那里点一下那图标..让它变灰" + echo "备注...如果你的域名是使用 Cloudflare 解析的话..在 DNS 那, 将 (Proxy status / 代理状态), 设置成 (DNS only / 仅限 DNS)" echo exit 1 fi @@ -878,15 +878,16 @@ backup_config() { } get_ip() { - ip=$(curl -s https://ipinfo.io/ip) - [[ -z $ip ]] && ip=$(curl -s https://api.ip.sb/ip) - [[ -z $ip ]] && ip=$(curl -s https://api.ipify.org) - [[ -z $ip ]] && ip=$(curl -s https://ip.seeip.org) - [[ -z $ip ]] && ip=$(curl -s https://ifconfig.co/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}") - [[ -z $ip ]] && echo -e "\n$red 这垃圾小鸡扔了吧!$none\n" && exit + # ip=$(curl -s https://ipinfo.io/ip) + # [[ -z $ip ]] && ip=$(curl -s https://api.ip.sb/ip) + # [[ -z $ip ]] && ip=$(curl -s https://api.ipify.org) + # [[ -z $ip ]] && ip=$(curl -s https://ip.seeip.org) + # [[ -z $ip ]] && ip=$(curl -s https://ifconfig.co/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 + [[ -z $ip ]] && echo -e "\n$red 获取IP失败, 这垃圾小鸡扔了吧!$none\n" && exit } error() { diff --git a/v2ray.sh b/v2ray.sh index bb83eca..ecf20af 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="old-v0.1" +_version="old-v0.11" v2ray_latest_ver=v4.45.2 cmd="apt-get" @@ -1765,18 +1765,18 @@ change_proxy_site_config() { } domain_check() { # test_domain=$(dig $new_domain +short) - test_domain=$(ping $new_domain -c 1 -4 -W 2 | grep -oE -m1 "([0-9]{1,3}\.){3}[0-9]{1,3}") + test_domain=$(ping $new_domain -c 1 -W 2 | head -1) # test_domain=$(wget -qO- --header='accept: application/dns-json' "https://cloudflare-dns.com/dns-query?name=$new_domain&type=A" | grep -oE "([0-9]{1,3}\.){3}[0-9]{1,3}" | head -1) # test_domain=$(curl -sH 'accept: application/dns-json' "https://cloudflare-dns.com/dns-query?name=$new_domain&type=A" | grep -oE "([0-9]{1,3}\.){3}[0-9]{1,3}" | head -1) - if [[ $test_domain != $ip ]]; then + if [[ ! $(echo $test_domain | grep $ip) ]]; then echo echo -e "$red 检测域名解析错误....$none" echo echo -e " 你的域名: $yellow$new_domain$none 未解析到: $cyan$ip$none" echo - echo -e " 你的域名当前解析到: $cyan$test_domain$none" + echo -e " PING 测试结果: $cyan$test_domain$none" echo - echo "备注...如果你的域名是使用 Cloudflare 解析的话..在 Status 那里点一下那图标..让它变灰" + echo "备注...如果你的域名是使用 Cloudflare 解析的话..在 DNS 那, 将 (Proxy status / 代理状态), 设置成 (DNS only / 仅限 DNS)" echo exit 1 fi @@ -2540,15 +2540,16 @@ backup_config() { } get_ip() { - ip=$(curl -s https://ipinfo.io/ip) - [[ -z $ip ]] && ip=$(curl -s https://api.ip.sb/ip) - [[ -z $ip ]] && ip=$(curl -s https://api.ipify.org) - [[ -z $ip ]] && ip=$(curl -s https://ip.seeip.org) - [[ -z $ip ]] && ip=$(curl -s https://ifconfig.co/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}") - [[ -z $ip ]] && echo -e "\n$red 这垃圾小鸡扔了吧!$none\n" && exit + # ip=$(curl -s https://ipinfo.io/ip) + # [[ -z $ip ]] && ip=$(curl -s https://api.ip.sb/ip) + # [[ -z $ip ]] && ip=$(curl -s https://api.ipify.org) + # [[ -z $ip ]] && ip=$(curl -s https://ip.seeip.org) + # [[ -z $ip ]] && ip=$(curl -s https://ifconfig.co/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 + [[ -z $ip ]] && echo -e "\n$red 获取IP失败, 这垃圾小鸡扔了吧!$none\n" && exit } error() {