]> git.nbdom.net Git - nb.git/commitdiff
etc/profile.d/functions
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Thu, 25 Jan 2018 00:16:00 +0000 (00:16 +0000)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Thu, 25 Jan 2018 00:16:00 +0000 (00:16 +0000)
etc/profile.d/functions

index 480f566ee237c95637f6a1f45841cf7dd78afa27..0c6f7d8877d82d455011824c09e0e75811f330f1 100644 (file)
@@ -772,9 +772,11 @@ file_user() {
 
 myip() {
        local url='';
-       for url in http://ipinfo.io/ip http://www.ipchicken.com http://icanhazip.com http://ident.me http://nicolas.boisselier.free.f/myip/;
+       for url in http://nbdom.net/myip http://nicolas.boisselier.free.fr/myip/ http://ipinfo.io/ip http://www.ipchicken.com http://icanhazip.com http://ident.me
        do
-               http_get "$url" | perl -ne 'print "$1\n" and exit 64 if /(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/';
+               http_get "$url" 2> /dev/null | awk 'match($0, /([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})/) {print substr($0, RSTART, RLENGTH); exit 64}'
+               #http_get "$url" | sed -n '/\([0-9]\{1,3\}\.\)\{3\}[0-9]\{1,3\}/p; q' | awk '{print $1}' | head -1
+               #http_get "$url" | perl -ne 'print "$1\n" and exit 64 if /(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/';
                [ "$?" == "64" ] && return 0;
        done;
        return 1
@@ -785,7 +787,7 @@ http_get() {
                curl -sk $*
 
        elif which wget 1>/dev/null; then
-               wget -O - --quiet --no-verbose --no-check-certificate --timeout 5 --tries 1 $*
+               wget -O - --quiet --no-verbose --no-check-certificate --timeout 10 --tries 1 $*
 
        elif which lynx 1>/dev/null; then
                lynx --source -dump $*