Last active
July 16, 2025 15:13
-
-
Save alainwolf/cb2842cf7676586414d4857fd2eecfb3 to your computer and use it in GitHub Desktop.
UptimeRobot vs Dynamic Firewall
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This script cross-references IP addresses from a text file with a CSV file | |
# and outputs the matched IPs to stdout. | |
# Its purpose was to find IPs from UptimeRobot that are in the Turris greylist. | |
import csv | |
import requests | |
# File URLs | |
uptimerobot_ips_url = "https://uptimerobot.com/inc/files/ips/IPv4andIPv6.txt" | |
turris_greylist_url = "https://view.sentinel.turris.cz/greylist-data/greylist-latest.csv" | |
# Download and load IPs from uptime-robot.txt | |
response = requests.get(uptimerobot_ips_url) | |
response.raise_for_status() | |
uptime_ips = set(line.strip() for line in response.text.splitlines() if line.strip()) | |
# Download and cross-reference with greylist-latest.csv | |
response = requests.get(turris_greylist_url) | |
response.raise_for_status() | |
# Skip comment lines starting with '#' | |
csv_lines = [line for line in response.text.splitlines() if not line.startswith("#")] | |
reader = csv.DictReader(csv_lines) | |
matched_ips = [] | |
for row in reader: | |
ip = row["Address"].strip() # Strip whitespace from the IP | |
if ip in uptime_ips: | |
matched_ips.append({"Address": ip, "Tags": row["Tags"]}) | |
# Output matched IPs to stdout | |
if matched_ips: | |
print("Address,Tags") | |
for match in matched_ips: | |
print(f"{match['Address']},{match['Tags']}") | |
else: | |
print("No matches found.") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
# shellcheck shell=dash | |
# ----------------------------------------------------------------------------- | |
# | |
# Download the latest UptimeRobot IP list and create a whitelist | |
# for Turris Sentinel using UCI commands. | |
# | |
# Edited by Alain Wolf Wed, 16. Jul 2025 16:46 | |
# ----------------------------------------------------------------------------- | |
# Define the URL for the UptimeRobot IP list | |
IP_LIST_URL="https://cdn.uptimerobot.com/api/IPv4andIPv6.txt" | |
# Define the UCI configuration | |
CONFIG="sentinel" | |
SECTION="dynfw" | |
OPTION="whitelist" | |
# Download the IP list | |
TMPFILE=$(mktemp) | |
wget -q -O "$TMPFILE" "$IP_LIST_URL" | |
# Ensure the configuration section exists | |
if ! uci get "$CONFIG"."$SECTION" 2>/dev/null >/dev/null; then | |
uci add "$CONFIG" survey | |
uci rename "$CONFIG".@survey[-1]="$SECTION" | |
uci set "$CONFIG"."$SECTION".enabled='1' | |
fi | |
# Remove existing whitelist entries | |
uci -q delete $CONFIG.$SECTION.$OPTION | |
# Add each IP to the whitelist | |
while IFS= read -r ip; do | |
[ -n "$ip" ] && uci add_list $CONFIG.$SECTION.$OPTION="$ip" | |
done < "$TMPFILE" | |
# Save and apply changes | |
uci commit $CONFIG | |
# Clean up | |
rm -f "$TMPFILE" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
UptimeRobot vs Dynamic Firewall