Skip to content

Commit

Permalink
feat(脚本): 优化查找ip
Browse files Browse the repository at this point in the history
  • Loading branch information
mack-a committed Aug 4, 2021
1 parent b27516f commit 6798bd6
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -815,15 +815,21 @@ EOF
# 检查ip
checkIP() {
echoContent skyBlue " ---> 检查ipv4中"
pingIP=$(curl -s -H 'accept:application/dns-json' 'https://cloudflare-dns.com/dns-query?name='${domain}'&type=A' | jq -r ".Answer|.[]|select(.type==1)|.data")
local pingIP=$(curl -s -H 'accept:application/dns-json' 'https://cloudflare-dns.com/dns-query?name='${domain}'&type=A' | jq -r ".Answer")
if [[ "${pingIP}" != "null" ]];then
pingIP=$(echo "${pingIP}"|jq -r ".[]|select(.type==1)|.data")
fi

if [[ -z "${pingIP}" ]]; then
if [[ "${pingIP}" == "null" ]]; then
echoContent skyBlue " ---> 检查ipv6中"
pingIP=$(curl -s -H 'accept:application/dns-json' 'https://cloudflare-dns.com/dns-query?name='${domain}'&type=AAAA' | jq -r ".Answer|.[]|select(.type==28)|.data")
pingIPv6=${pingIP}
local pingIP=$(curl -s -H 'accept:application/dns-json' 'https://cloudflare-dns.com/dns-query?name='${domain}'&type=AAAA' | jq -r ".Answer")
if [[ "${pingIP}" -ne "null" ]];then
pingIP=$(echo "${pingIP}"|jq -r ".[]|select(.type==28)|.data")
pingIPv6=${pingIP}
fi
fi

if [[ -n "${pingIP}" ]]; then
if [[ "${pingIP}" != "null" ]]; then
echo
read -r -p "当前域名的IP为 [${pingIP}],是否正确[y/n]?" domainStatus
if [[ "${domainStatus}" == "y" ]]; then
Expand Down

0 comments on commit 6798bd6

Please sign in to comment.