Updated `utils/whatsapp_ip_addresses_download.sh' to scrape the required IP addresses/ranges. (#1524)

* Replaced return statements in `utils/*.sh' with exit's (such scripts should never source'd)
 * Ran `utils/update_every_lists.sh'

Signed-off-by: lns <matzeton@googlemail.com>
This commit is contained in:
Toni
2022-04-22 13:27:41 +02:00
committed by GitHub
parent 42909673ce
commit 824c343602
22 changed files with 2106 additions and 735 deletions
+9 -7
View File
@@ -5,21 +5,23 @@ cd "$(dirname "${0}")"
DEST=../src/lib/inc_generated/ndpi_whatsapp_match.c.inc
TMP=/tmp/wa.zip
LIST=/tmp/wa.list
# https://developers.facebook.com/docs/whatsapp/guides/network-requirements/
ORIGIN="https://scontent.fmxp6-1.fna.fbcdn.net/v/t39.8562-6/218944277_794653217800107_785885630662402277_n.zip?_nc_cat=102&ccb=1-5&_nc_sid=ae5e01&_nc_ohc=CxWH4uR6uPsAX-Yga3M&_nc_ht=scontent.fmxp6-1.fna&oh=00_AT9gC0NiHKwmgoBdNX9jbVbxtciJ8HzeGdOLj35n3kWeUw&oe=6201B6A9"
IP_LINK_URL='https://developers.facebook.com/docs/whatsapp/guides/network-requirements/'
echo "(1) Downloading file... ${ORIGIN}"
echo "(1) Scraping Facebook WhatsApp IP Adresses and Ranges..."
ORIGIN="$(curl -s "${IP_LINK_URL}" | sed -ne 's/.*<a href="\([^"]*\)" target="_blank">List of the WhatsApp server IP addresses and ranges (.zip file)<\/a>.*/\1/gp' | sed -e 's/\&amp;/\&/g')"
echo "(2) Downloading file... ${ORIGIN}"
http_response=$(curl -s -o $TMP -w "%{http_code}" ${ORIGIN})
if [ "$http_response" != "200" ]; then
echo "Error $http_response: you probably need to update the list url!"
return 0 # WhatsApp URL broken: set this to 1 when the URL was fixed
exit 1
fi
echo "(2) Processing IP addresses..."
echo "(3) Processing IP addresses..."
zcat $TMP > $LIST
./ipaddr2list.py $LIST NDPI_PROTOCOL_WHATSAPP > $DEST
rm -f $TMP $LIST
echo "(3) WhatsApp IPs are available in $DEST"
return 0
echo "(4) WhatsApp IPs are available in $DEST"
exit 0