aboutsummaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorNardi Ivan <nardi.ivan@gmail.com>2024-08-02 12:13:51 +0200
committerIvan Nardi <12729895+IvanNardi@users.noreply.github.com>2024-09-05 16:36:50 +0200
commit5b0374c28b60a39f5720cb44ea5f711774c511af (patch)
treebb7e99bde4839996a1b5a04f309e4d502dbbea3c /utils
parent85ebda434d44f93e656ee5d3e52dc258134495d0 (diff)
Add detection of SurfShark VPN
Diffstat (limited to 'utils')
-rwxr-xr-xutils/surfshark_ip_addresses_download.sh40
-rwxr-xr-xutils/update_every_lists.sh2
2 files changed, 42 insertions, 0 deletions
diff --git a/utils/surfshark_ip_addresses_download.sh b/utils/surfshark_ip_addresses_download.sh
new file mode 100755
index 000000000..121478d20
--- /dev/null
+++ b/utils/surfshark_ip_addresses_download.sh
@@ -0,0 +1,40 @@
+#!/usr/bin/env bash
+set -e
+
+cd "$(dirname "${0}")" || exit 1
+. ./common.sh || exit 1
+
+DEST=../src/lib/inc_generated/ndpi_surfshark_match.c.inc
+TMP=/tmp/surfshark.json
+LIST_DOMAINS=/tmp/surfshark.listd
+LIST=/tmp/surfshark.list
+LIST_MERGED=/tmp/surfshark.list_m
+ORIGIN=https://api.surfshark.com/v4/server/clusters/all
+# SurfShark provides a list of DOMAINS, not of IPs!
+#TODO: should we convert these domains to ip at runtime?
+#No ipv6 support: https://support.surfshark.com/hc/en-us/articles/360011550239-Does-Surfshark-support-IPv6-Do-I-have-it-on-my-network
+
+echo "(1) Downloading file..."
+http_response=$(curl -s -o $TMP -w "%{http_code}" ${ORIGIN})
+check_http_response "${http_response}"
+is_file_empty "${TMP}"
+
+echo "(2) Processing domains..."
+jq -r '.[] | .connectionName' $TMP > $LIST_DOMAINS
+while read -r DOMAIN
+do
+ dig +short "${DOMAIN}" A >> ${LIST}
+# dig +short "${DOMAIN}" AAAA >> ${LIST6}
+done < "${LIST_DOMAINS}"
+
+echo "(3) Processing IP addresses..."
+is_file_empty "${LIST}"
+./mergeipaddrlist.py $LIST > $LIST_MERGED
+is_file_empty "${LIST_MERGED}"
+./ipaddr2list.py $LIST_MERGED NDPI_PROTOCOL_SURFSHARK > $DEST
+is_file_empty "${DEST}"
+
+rm -f ${TMP} ${LIST} ${LIST6} ${LIST_DOMAINS}
+
+echo "(4) SurfShark IPs are available in $DEST"
+exit 0
diff --git a/utils/update_every_lists.sh b/utils/update_every_lists.sh
index 4bb285fda..ad394621d 100755
--- a/utils/update_every_lists.sh
+++ b/utils/update_every_lists.sh
@@ -32,6 +32,8 @@ RETVAL=$(( RETVAL + $? ))
RETVAL=$(( RETVAL + $? ))
./nordvpn_ip_addresses_download.sh
RETVAL=$(( RETVAL + $? ))
+./surfshark_ip_addresses_download.sh
+RETVAL=$(( RETVAL + $? ))
./asn_update.sh
RETVAL=$(( RETVAL + $? ))