aboutsummaryrefslogtreecommitdiff
path: root/utils/tor_ip_addresses_download.sh
blob: ed5cdc4c7af19aea08173278bc77d7194f9ed547 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/sh

cd "$(dirname "${0}")"

DEST=../src/lib/ndpi_tor_match.c.inc
LIST=/tmp/tor.list
# There are at least two lists:
#  * https://torstatus.rueckgr.at/ip_list_all.php/Tor_ip_list_ALL.csv
#  * https://check.torproject.org/torbulkexitlist
# The latter seems to be more "stable" (the former changes every few seconds!)
ORIGIN="https://check.torproject.org/torbulkexitlist"


echo "(1) Downloading file..."
http_response=$(curl -s -o $LIST -w "%{http_code}" ${ORIGIN})
if [ $http_response != "200" ]; then
    echo "Error $http_response: you probably need to update the list url!"
    return
fi

echo "(2) Processing IP addresses..."
./ipaddr2list.py $LIST NDPI_PROTOCOL_TOR > $DEST
rm -f $LIST

echo "(3) TOR IPs are available in $DEST"