Improved helper scripts. (#1986)
* added additional (more restrictive) checks Signed-off-by: lns <matzeton@googlemail.com>
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
#!/bin/sh
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
cd "$(dirname "${0}")" || exit 1
|
||||
. ./common.sh || exit 1
|
||||
|
||||
DEST=../src/lib/inc_generated/ndpi_whatsapp_match.c.inc
|
||||
TMP=/tmp/wa.zip
|
||||
@@ -12,18 +13,19 @@ IP_LINK_URL='https://developers.facebook.com/docs/whatsapp/guides/network-requir
|
||||
|
||||
echo "(1) Scraping Facebook WhatsApp IP Adresses and Ranges..."
|
||||
ORIGIN="$(curl -s "${IP_LINK_URL}" | sed -ne 's/.*<a href="\([^"]*\)" target="_blank">WhatsApp server IP addresses and ranges (.zip file)<\/a>.*/\1/gp' | sed -e 's/\&/\&/g')"
|
||||
is_str_empty "${ORIGIN}" "IP webpage list does not contain any addresses. A REGEX update may be required."
|
||||
|
||||
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!"
|
||||
exit 1
|
||||
fi
|
||||
http_response=$(curl -s -o "${TMP}" -w "%{http_code}" "${ORIGIN}")
|
||||
check_http_response "${http_response}"
|
||||
is_file_empty "${TMP}"
|
||||
|
||||
echo "(3) Processing IP addresses..."
|
||||
unzip -p /tmp/wa.zip "WhatsApp IPs (IPv4 Only) 2022-07-26 - 2022-07-30.txt" > $LIST
|
||||
./ipaddr2list.py $LIST NDPI_PROTOCOL_WHATSAPP > $DEST
|
||||
rm -f $TMP $LIST
|
||||
unzip -p /tmp/wa.zip "WhatsApp IPs (IPv4 Only) 2022-07-26 - 2022-07-30.txt" > "${LIST}"
|
||||
is_file_empty "${LIST}"
|
||||
./ipaddr2list.py "${LIST}" NDPI_PROTOCOL_WHATSAPP > "${DEST}"
|
||||
rm -f "${TMP}" "${LIST}"
|
||||
is_file_empty "${DEST}"
|
||||
|
||||
echo "(4) WhatsApp IPs are available in $DEST"
|
||||
exit 0
|
||||
|
||||
Reference in New Issue
Block a user