From be24872d73b8955603a408a15c4bab9bf43e458f Mon Sep 17 00:00:00 2001 From: nitefood Date: Wed, 14 Feb 2024 00:45:56 +0100 Subject: [PATCH] improved AWS support and bookmarklet creation: - handled ifconfig.co redirecting to captcha when queried from flagged IP ranges (fallback to ipify) - ASN server now uses WAN IP instead of lo address when building bookmarlet URL (if binding to 0.0.0.0 or ::) --- README.md | 1 + asn | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2d7212b..eea173a 100644 --- a/README.md +++ b/README.md @@ -105,6 +105,7 @@ The script uses the following services for data retrieval: * [PeeringDB](https://www.peeringdb.com/) * [CAIDA ASRank](https://asrank.caida.org/) * [ifconfig.co](https://ifconfig.co/) +* [ipify](https://www.ipify.org/) * [RIPEStat](https://stat.ripe.net/) * [RIPE IPmap](https://ipmap.ripe.net/) * [ip-api](https://ip-api.com/) diff --git a/asn b/asn index 55c5b67..afd114c 100755 --- a/asn +++ b/asn @@ -2714,7 +2714,7 @@ AsnServerListener(){ # prepare the server URL (for the JS bookmarklet) if [ "$ASN_SRV_BINDADDR" = "0.0.0.0" ] || [ "$ASN_SRV_BINDADDR" = "::" ]; then - INTERNAL_ASNSERVER_ADDRESS="127.0.0.1:$ASN_SRV_BINDPORT" + INTERNAL_ASNSERVER_ADDRESS="$local_wanip:$ASN_SRV_BINDPORT" else INTERNAL_ASNSERVER_ADDRESS="$ASN_SRV_BINDADDR:$ASN_SRV_BINDPORT" fi @@ -2844,6 +2844,8 @@ WhatIsMyIP() { [[ -n "$local_wanip" ]] && return # retrieve local WAN IP (v6 takes precedence) from ifconfig.co local_wanip=$(docurl -s "https://ifconfig.co") + # handle ifconfig.co serving a captcha-type redirect page (e.g. when coming from some AWS networks) + grep -qE '^' <<<"$local_wanip" && local_wanip=$(docurl -s "https://api64.ipify.org") # check if we default to an IPv6 internet connection if echo "$local_wanip" | grep -q ':'; then HAVE_IPV6=true