aboutsummaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
Diffstat (limited to 'utils')
27 files changed, 33 insertions, 57 deletions
diff --git a/utils/asn_update.sh b/utils/asn_update.sh
index 283e7f93c..f9e2a9ca7 100755
--- a/utils/asn_update.sh
+++ b/utils/asn_update.sh
@@ -1,5 +1,4 @@
#!/usr/bin/env bash
-
set -e
FAILED_ASN=0
@@ -7,13 +6,13 @@ TOTAL_ASN=0
function processing_list() {
local LIST_MERGED="/tmp/list_m"
- local LIST_MERGED6="/tmp/list_m6"
+ local LIST6_MERGED="/tmp/list6_m"
echo "(2) Processing IP addresses..."
./mergeipaddrlist.py "$1" > $LIST_MERGED
- ./mergeipaddrlist.py "$2" > $LIST_MERGED6
- ./ipaddr2list.py "$LIST_MERGED" "$3" "$LIST_MERGED6" > "$4"
- rm -f $LIST_MERGED
+ ./mergeipaddrlist.py "$2" > $LIST6_MERGED
+ ./ipaddr2list.py "$LIST_MERGED" "$3" "$LIST6_MERGED" > "$4"
+ rm -f $LIST_MERGED $LIST6_MERGED
}
function create_list() {
@@ -210,7 +209,7 @@ DEST=../src/lib/inc_generated/ndpi_asn_roblox.c.inc
create_list NDPI_PROTOCOL_ROBLOX $DEST "" "AS22697"
echo "(3) Roblox IPs are available in $DEST"
-if [ ${TOTAL_ASN} -eq 0 -o ${TOTAL_ASN} -eq ${FAILED_ASN} ]; then
+if [ ${TOTAL_ASN} -eq 0 ] || [ ${TOTAL_ASN} -eq ${FAILED_ASN} ]; then
printf '%s: %s\n' "${0}" "All download(s) failed, ./get_routes_by_asn.sh broken?"
exit 1
else
diff --git a/utils/aws_ip_addresses_download.sh b/utils/aws_ip_addresses_download.sh
index f413e8c6f..de7409759 100755
--- a/utils/aws_ip_addresses_download.sh
+++ b/utils/aws_ip_addresses_download.sh
@@ -1,5 +1,4 @@
#!/usr/bin/env bash
-
set -e
cd "$(dirname "${0}")" || exit 1
@@ -31,7 +30,7 @@ is_file_empty "${LIST6_MERGED}"
./ipaddr2list.py $LIST_MERGED NDPI_PROTOCOL_AMAZON_AWS $LIST6_MERGED > $DEST
is_file_empty "${DEST}"
-rm -f ${TMP} ${LIST} ${LIST6} ${LIST_MERGED} ${LIST_MERGED6}
+rm -f ${TMP} ${LIST} ${LIST6} ${LIST_MERGED} ${LIST6_MERGED}
echo "(3) Amazon AWS IPs are available in $DEST"
exit 0
diff --git a/utils/azure_ip_addresses_download.sh b/utils/azure_ip_addresses_download.sh
index 243e11fd3..ad9efc511 100755
--- a/utils/azure_ip_addresses_download.sh
+++ b/utils/azure_ip_addresses_download.sh
@@ -1,5 +1,4 @@
#!/usr/bin/env bash
-
set -e
cd "$(dirname "${0}")" || exit 1
@@ -17,7 +16,7 @@ LIST6_MERGED=/tmp/azure.list6_m
LINK_ORIGIN="https://www.microsoft.com/en-us/download/confirmation.aspx?id=56519"
echo "(1) Downloading file... ${LINK_ORIGIN}"
-http_response=$(curl -s -o ${LINK_TMP} -w "%{http_code}" ${LINK_ORIGIN})
+http_response=$(curl -s -o ${LINK_TMP} -w "%{http_code}" "${LINK_ORIGIN}")
check_http_response "${http_response}"
is_file_empty "${LINK_TMP}"
@@ -26,7 +25,7 @@ rm -f ${LINK_TMP}
is_str_empty "${ORIGIN}" "${LINK_ORIGIN} does not contain the url format!"
echo "(2) Downloading file... ${ORIGIN}"
-http_response=$(curl -s -o $TMP -w "%{http_code}" ${ORIGIN})
+http_response=$(curl -s -o $TMP -w "%{http_code}" "${ORIGIN}")
check_http_response "${http_response}"
is_file_empty "${TMP}"
@@ -42,7 +41,7 @@ is_file_empty "${LIST6_MERGED}"
./ipaddr2list.py $LIST_MERGED NDPI_PROTOCOL_MICROSOFT_AZURE $LIST6_MERGED > $DEST
is_file_empty "${DEST}"
-rm -f ${TMP} ${LIST} ${LIST6} ${LIST_MERGED} ${LIST_MERGED6}
+rm -f ${TMP} ${LIST} ${LIST6} ${LIST_MERGED} ${LIST6_MERGED}
echo "(4) Microsoft Azure IPs are available in $DEST"
exit 0
diff --git a/utils/bitcoinnodes.sh b/utils/bitcoinnodes.sh
index 19b30b4d9..3641618d0 100755
--- a/utils/bitcoinnodes.sh
+++ b/utils/bitcoinnodes.sh
@@ -1,10 +1,9 @@
#!/usr/bin/env bash
+set -e
#
# List all the current bittorrent nodes
#
-set -e
-
cd "$(dirname "${0}")" || exit 1
. ./common.sh || exit 1
diff --git a/utils/bitcoinnodes_v4v6.sh b/utils/bitcoinnodes_v4v6.sh
index 2ae8babd6..60dc4859d 100755
--- a/utils/bitcoinnodes_v4v6.sh
+++ b/utils/bitcoinnodes_v4v6.sh
@@ -1,32 +1,30 @@
#!/usr/bin/env bash
+set -e
#
# List all the current bittorrent nodes
#
-set -e
-
cd "$(dirname "${0}")" || exit 1
. ./common.sh || exit 1
# NOTE: JQ can be found at https://stedolan.github.io/jq/
-CMD='curl -s -H "Accept: application/json; indent=4" https://bitnodes.io/api/v1/snapshots/latest/'
+CMD=(curl -s -H "Accept: application/json; indent=4" https://bitnodes.io/api/v1/snapshots/latest/)
-RESULT_V4="$(${CMD} | jq -r '.nodes|keys[] as $k | "\($k)"' | grep -v onion | grep -v ']' | cut -d ':' -f 1)"
-RESULT_V6="$(${CMD} | jq -r '.nodes|keys[] as $k | "\($k)"' | grep -v onion | grep ']' | cut -d '[' -f 2 | cut -d ']' -f 1)"
-RESULTS="echo ${RESULT_V4} ${RESULT_V6}"
+RESULT_V4="$("${CMD[@]}" | jq -r '.nodes|keys[] as $k | "\($k)"' | grep -v onion | grep -v ']' | cut -d ':' -f 1)"
+RESULT_V6="$("${CMD[@]}" | jq -r '.nodes|keys[] as $k | "\($k)"' | grep -v onion | grep ']' | cut -d '[' -f 2 | cut -d ']' -f 1)"
OUT_FILE="../lists/99_bitcoinnodes.ip_list"
rm -f ${OUT_FILE}
-strarr=($(echo $RESULT_V4 | tr " " "\n"))
+strarr=($(echo "$RESULT_V4" | tr " " "\n"))
for i in "${strarr[@]}"; do
echo "$i/32" >> "${OUT_FILE}"
done
#########
-strarr=($(echo $RESULT_V6 | tr " " "\n"))
+strarr=($(echo "$RESULT_V6" | tr " " "\n"))
for i in "${strarr[@]}"; do
echo "$i/128" >> "${OUT_FILE}"
done
diff --git a/utils/cachefly_ip_addresses_download.sh b/utils/cachefly_ip_addresses_download.sh
index 6e27b9ff7..7a7ef68b7 100755
--- a/utils/cachefly_ip_addresses_download.sh
+++ b/utils/cachefly_ip_addresses_download.sh
@@ -1,5 +1,4 @@
#!/usr/bin/env bash
-
set -e
cd "$(dirname "${0}")" || exit 1
diff --git a/utils/check_symbols.sh b/utils/check_symbols.sh
index 5a2bf2991..ec23bfa90 100755
--- a/utils/check_symbols.sh
+++ b/utils/check_symbols.sh
@@ -1,18 +1,17 @@
-#!/usr/bin/env sh
-
+#!/usr/bin/env bash
set -e
-SCRIPT_DIR="$(realpath $(dirname ${0}))"
+SCRIPT_DIR="$(realpath "$(dirname "${0}")")"
NDPI_LIB="${1:-${SCRIPT_DIR}/../src/lib/libndpi.a}"
if [ ! -r "${NDPI_LIB}" ]; then
- printf '%s\n' "${0}: nDPI static library '$(realpath ${NDPI_LIB})' not found."
+ printf '%s\n' "${0}: nDPI static library '$(realpath "${NDPI_LIB}")' not found."
exit 1
fi
FAIL_COUNT=0
CURRENT_OBJECT=''
-for line in `nm -P -u "${NDPI_LIB}"`; do
+for line in $(nm -P -u "${NDPI_LIB}"); do
OBJECT="$(printf '%s' "${line}" | grep -E "^${NDPI_LIB}\[.*\.o\]:" | grep -oE "\[.*\.o\]" || true)"
if [ ! -z "${OBJECT}" ]; then
CURRENT_OBJECT="${OBJECT}"
@@ -39,7 +38,7 @@ for line in `nm -P -u "${NDPI_LIB}"`; do
'malloc'|'calloc'|'realloc'|'free') SKIP=1 ;;
esac
;;
- '[ndpi_utils.o]'|'[ndpi_memory.o]'|'[roaring.o]')
+ '[ndpi_utils.o]'|'[ndpi_memory.o]')
case "${FOUND_SYMBOL}" in
'malloc'|'calloc'|'free') SKIP=1 ;;
esac
@@ -52,7 +51,7 @@ for line in `nm -P -u "${NDPI_LIB}"`; do
esac
if [ ${SKIP} -eq 0 ]; then
- FAIL_COUNT="$(expr ${FAIL_COUNT} + 1)"
+ FAIL_COUNT="$((FAIL_COUNT + 1))"
printf '%s: %s\n' "${CURRENT_OBJECT}" "${FOUND_SYMBOL}"
fi
fi
diff --git a/utils/cloudflare_ip_addresses_download.sh b/utils/cloudflare_ip_addresses_download.sh
index f30dfb288..861010570 100755
--- a/utils/cloudflare_ip_addresses_download.sh
+++ b/utils/cloudflare_ip_addresses_download.sh
@@ -1,5 +1,4 @@
#!/usr/bin/env bash
-
set -e
cd "$(dirname "${0}")" || exit 1
diff --git a/utils/common.sh b/utils/common.sh
index 67087484a..85abe8720 100755
--- a/utils/common.sh
+++ b/utils/common.sh
@@ -1,6 +1,6 @@
-#!/usr/bin/env sh
+#!/usr/bin/env bash
-printf 'Running script: %s\n' "$(basename ${0})" >&2
+printf 'Running script: %s\n' "$(basename "${0}")" >&2
function check_http_response()
{
@@ -21,7 +21,7 @@ function is_file_empty()
exit 1
fi
- if [ `cat "${file}" | wc -c` -eq 0 ]; then
+ if [ "$(< "${file}" wc -c)" -eq 0 ]; then
printf '%s error: %s\n' "${0}" "file ${file} empty!" >&2
exit 1
fi
diff --git a/utils/crawlers_ip_addresses_download.sh b/utils/crawlers_ip_addresses_download.sh
index d15c6e4c1..e96307db1 100755
--- a/utils/crawlers_ip_addresses_download.sh
+++ b/utils/crawlers_ip_addresses_download.sh
@@ -1,5 +1,4 @@
#!/usr/bin/env bash
-
set -e
cd "$(dirname "${0}")" || exit 1
diff --git a/utils/ethereum_ip_addresses_download.sh b/utils/ethereum_ip_addresses_download.sh
index df7844a16..00885e3f5 100755
--- a/utils/ethereum_ip_addresses_download.sh
+++ b/utils/ethereum_ip_addresses_download.sh
@@ -1,5 +1,4 @@
#!/usr/bin/env bash
-
set -e
cd "$(dirname "${0}")" || exit 1
diff --git a/utils/gambling_sites_download.sh b/utils/gambling_sites_download.sh
index 93eb81549..9337786c1 100755
--- a/utils/gambling_sites_download.sh
+++ b/utils/gambling_sites_download.sh
@@ -1,5 +1,4 @@
#!/usr/bin/env bash
-
set -e
cd "$(dirname "${0}")" || exit 1
diff --git a/utils/get_routes6_by_asn.sh b/utils/get_routes6_by_asn.sh
index 235bebbfd..fadf05f0c 100755
--- a/utils/get_routes6_by_asn.sh
+++ b/utils/get_routes6_by_asn.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/usr/bin/env bash
if [ "$#" -ne 1 ]; then
echo "Usage: $0 AS-Number" >&2
diff --git a/utils/get_routes_by_asn.sh b/utils/get_routes_by_asn.sh
index ce90ffcd5..f5c1705b1 100755
--- a/utils/get_routes_by_asn.sh
+++ b/utils/get_routes_by_asn.sh
@@ -1,5 +1,4 @@
-#!/bin/sh
-
+#!/usr/bin/env bash
set -e
if [ "$#" -ne 1 ]; then
diff --git a/utils/google_cloud_ip_addresses_download.sh b/utils/google_cloud_ip_addresses_download.sh
index 41fce68c5..7a4662147 100755
--- a/utils/google_cloud_ip_addresses_download.sh
+++ b/utils/google_cloud_ip_addresses_download.sh
@@ -1,5 +1,4 @@
#!/usr/bin/env bash
-
set -e
cd "$(dirname "${0}")" || exit 1
diff --git a/utils/google_ip_addresses_download.sh b/utils/google_ip_addresses_download.sh
index 1c3e76948..0d9e85efa 100755
--- a/utils/google_ip_addresses_download.sh
+++ b/utils/google_ip_addresses_download.sh
@@ -1,5 +1,4 @@
#!/usr/bin/env bash
-
set -e
cd "$(dirname "${0}")" || exit 1
@@ -27,7 +26,7 @@ is_file_empty "${LIST6_MERGED}"
./ipaddr2list.py $LIST_MERGED NDPI_PROTOCOL_GOOGLE $LIST6_MERGED > $DEST
is_file_empty "${DEST}"
-rm -f $TMP $LIST $LIST6
+rm -f "$TMP" $LIST $LIST6
echo "(3) Google IPs are available in $DEST"
exit 0
diff --git a/utils/icloud_private_relay_ip_addresses_download.sh b/utils/icloud_private_relay_ip_addresses_download.sh
index 0b6862e14..346e222a5 100755
--- a/utils/icloud_private_relay_ip_addresses_download.sh
+++ b/utils/icloud_private_relay_ip_addresses_download.sh
@@ -1,5 +1,4 @@
#!/usr/bin/env bash
-
set -e
cd "$(dirname "${0}")" || exit 1
diff --git a/utils/malicious_sites_download.sh b/utils/malicious_sites_download.sh
index 44fc76fb2..599385b93 100755
--- a/utils/malicious_sites_download.sh
+++ b/utils/malicious_sites_download.sh
@@ -1,5 +1,4 @@
#!/usr/bin/env bash
-
set -e
cd "$(dirname "${0}")" || exit 1
diff --git a/utils/microsoft_ip_addresses_download.sh b/utils/microsoft_ip_addresses_download.sh
index 4365732bf..9bf3b202a 100755
--- a/utils/microsoft_ip_addresses_download.sh
+++ b/utils/microsoft_ip_addresses_download.sh
@@ -1,5 +1,4 @@
#!/usr/bin/env bash
-
set -e
cd "$(dirname "${0}")" || exit 1
@@ -19,7 +18,7 @@ ORIGIN="https://endpoints.office.com/endpoints/worldwide?clientrequestid=b10c5ed
echo "(1) Downloading file... ${ORIGIN}"
-http_response=$(curl -s -o $TMP -w "%{http_code}" ${ORIGIN})
+http_response=$(curl -s -o $TMP -w "%{http_code}" "${ORIGIN}")
check_http_response "${http_response}"
is_file_empty "${TMP}"
@@ -74,7 +73,7 @@ is_file_empty "${LIST6_MERGED}"
./ipaddr2list.py $LIST_MERGED NDPI_PROTOCOL_MICROSOFT_365 $LIST6_MERGED > $DEST_OFFICE365
is_file_empty "${DEST_OFFICE365}"
-rm -f ${TMP} ${LIST} ${LIST6} ${LIST_MERGED} ${LIST_MERGED6}
+rm -f ${TMP} ${LIST} ${LIST6} ${LIST_MERGED} ${LIST6_MERGED}
echo "(3) Microsoft IPs are available in ${DEST_OUTLOOK}, ${DEST_SKYPE_MSTEAMS}, ${DEST_ONEDRIVE}, ${DEST_OFFICE365}"
exit 0
diff --git a/utils/mullvad_ip_addresses_download.sh b/utils/mullvad_ip_addresses_download.sh
index 941f50a27..de52f09be 100755
--- a/utils/mullvad_ip_addresses_download.sh
+++ b/utils/mullvad_ip_addresses_download.sh
@@ -1,5 +1,4 @@
#!/usr/bin/env bash
-
set -e
cd "$(dirname "${0}")" || exit 1
diff --git a/utils/protonvpn_ip_addresses_download.sh b/utils/protonvpn_ip_addresses_download.sh
index af3625520..c290a7846 100755
--- a/utils/protonvpn_ip_addresses_download.sh
+++ b/utils/protonvpn_ip_addresses_download.sh
@@ -1,5 +1,4 @@
#!/usr/bin/env bash
-
set -e
cd "$(dirname "${0}")" || exit 1
diff --git a/utils/public_suffix_list_download.sh b/utils/public_suffix_list_download.sh
index 68be5bcbb..20fd39747 100755
--- a/utils/public_suffix_list_download.sh
+++ b/utils/public_suffix_list_download.sh
@@ -1,5 +1,4 @@
#!/usr/bin/env bash
-
set -e
cd "$(dirname "${0}")" || exit 1
diff --git a/utils/tor_ip_addresses_download.sh b/utils/tor_ip_addresses_download.sh
index cfdba68e2..c63f1c14e 100755
--- a/utils/tor_ip_addresses_download.sh
+++ b/utils/tor_ip_addresses_download.sh
@@ -1,5 +1,4 @@
#!/usr/bin/env bash
-
set -e
cd "$(dirname "${0}")" || exit 1
diff --git a/utils/update_every_lists.sh b/utils/update_every_lists.sh
index 1c98900f2..f01480e1c 100755
--- a/utils/update_every_lists.sh
+++ b/utils/update_every_lists.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
cd "$(dirname "${0}")" || exit 1
diff --git a/utils/verify_dist_tarball.sh b/utils/verify_dist_tarball.sh
index 0b5800769..c429ae7eb 100755
--- a/utils/verify_dist_tarball.sh
+++ b/utils/verify_dist_tarball.sh
@@ -1,4 +1,4 @@
-#!/usr/bin/env sh
+#!/usr/bin/env bash
EXCLUDE_PATTERN="(.*\.m4$|Makefile$|Makefile\.in$|utils/verify_dist_tarball\.sh|^packages/debian/.*|^packages/debian|^test-driver|^config\.guess|^config\.sub|^compile|^configure|/|depcomp|.gitattributes|.gitignore|install-sh|ltmain.sh|missing|src/include/ndpi_config\.h\.in|tests/pcap|tests/result)$"
@@ -10,7 +10,7 @@ cd "$(dirname "${0}")/.."
git ls-tree --full-tree --name-only -r HEAD | grep -vE "${EXCLUDE_PATTERN}" | sort >/tmp/ndpi-dist-verify-git.txt
TARBALL="${1}"
-if [ "x${TARBALL}" = x ]; then
+if [ -z "${TARBALL}" ]; then
if [ ! -r Makefile ]; then
./autogen.sh
fi
diff --git a/utils/whatsapp_ip_addresses_download.sh b/utils/whatsapp_ip_addresses_download.sh
index cddb21389..8346afb82 100755
--- a/utils/whatsapp_ip_addresses_download.sh
+++ b/utils/whatsapp_ip_addresses_download.sh
@@ -1,5 +1,4 @@
#!/usr/bin/env bash
-
set -e
cd "$(dirname "${0}")" || exit 1
diff --git a/utils/zoom_ip_addresses_download.sh b/utils/zoom_ip_addresses_download.sh
index b527abdad..3745de5d8 100755
--- a/utils/zoom_ip_addresses_download.sh
+++ b/utils/zoom_ip_addresses_download.sh
@@ -1,5 +1,4 @@
#!/usr/bin/env bash
-
set -e
cd "$(dirname "${0}")" || exit 1