From 44d7df50e39cf758621ba915db4c61a3ca307ddc Mon Sep 17 00:00:00 2001 From: Teddysun Date: Tue, 24 Mar 2015 17:04:12 +0800 Subject: [PATCH] Update get public IP address method --- shadowsocks-go.sh | 4 ++-- shadowsocks-libev-debian.sh | 4 ++-- shadowsocks-libev.sh | 4 ++-- shadowsocks.sh | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/shadowsocks-go.sh b/shadowsocks-go.sh index c7b3724..1f782d7 100644 --- a/shadowsocks-go.sh +++ b/shadowsocks-go.sh @@ -110,8 +110,8 @@ function pre_install(){ fi # Get IP address echo "Getting Public IP address, Please wait a moment..." - IP=$(curl -s checkip.dyndns.com | cut -d' ' -f 6 | cut -d'<' -f 1) - if [ $? -ne 0 -o -z $IP ]; then + IP=$(wget -qO- ipv4.icanhazip.com) + if [[ "$IP" = "" ]]; then IP=$(curl -s -4 ipinfo.io | grep "ip" | awk -F\" '{print $4}') fi echo -e "Your main public IP is\t\033[32m$IP\033[0m" diff --git a/shadowsocks-libev-debian.sh b/shadowsocks-libev-debian.sh index b147f04..0e66686 100644 --- a/shadowsocks-libev-debian.sh +++ b/shadowsocks-libev-debian.sh @@ -73,8 +73,8 @@ function pre_install(){ apt-get install -y wget unzip curl build-essential autoconf libtool libssl-dev # Get IP address echo "Getting Public IP address, Please wait a moment..." - IP=$(curl -s checkip.dyndns.com | cut -d' ' -f 6 | cut -d'<' -f 1) - if [ $? -ne 0 -o -z $IP ]; then + IP=$(wget -qO- ipv4.icanhazip.com) + if [[ "$IP" = "" ]]; then IP=$(curl -s -4 ipinfo.io | grep "ip" | awk -F\" '{print $4}') fi echo -e "Your main public IP is\t\033[32m$IP\033[0m" diff --git a/shadowsocks-libev.sh b/shadowsocks-libev.sh index b0ba92a..87b180c 100644 --- a/shadowsocks-libev.sh +++ b/shadowsocks-libev.sh @@ -87,8 +87,8 @@ function pre_install(){ yum install -y automake make curl curl-devel zlib-devel openssl-devel perl perl-devel cpio expat-devel gettext-devel # Get IP address echo "Getting Public IP address, Please wait a moment..." - IP=`curl -s checkip.dyndns.com | cut -d' ' -f 6 | cut -d'<' -f 1` - if [ $? -ne 0 -o -z $IP ]; then + IP=$(wget -qO- ipv4.icanhazip.com) + if [[ "$IP" = "" ]]; then IP=`curl -s -4 ipinfo.io | grep "ip" | awk -F\" '{print $4}'` fi echo -e "Your main public IP is\t\033[32m$IP\033[0m" diff --git a/shadowsocks.sh b/shadowsocks.sh index dbfe9cc..24d48c0 100644 --- a/shadowsocks.sh +++ b/shadowsocks.sh @@ -107,8 +107,8 @@ function pre_install(){ fi # Get IP address echo "Getting Public IP address, Please wait a moment..." - IP=$(curl -s checkip.dyndns.com | cut -d' ' -f 6 | cut -d'<' -f 1) - if [ $? -ne 0 -o -z $IP ]; then + IP=$(wget -qO- ipv4.icanhazip.com) + if [[ "$IP" = "" ]]; then IP=$(curl -s -4 ipinfo.io | grep "ip" | awk -F\" '{print $4}') fi echo -e "Your main public IP is\t\033[32m$IP\033[0m"