diff --git a/proton-checker.py b/proton-checker.py index 95ca56f..7197ba7 100644 --- a/proton-checker.py +++ b/proton-checker.py @@ -2,6 +2,8 @@ import requests from collections import defaultdict from collections import Counter from datetime import datetime +import os +import subprocess def get_vpn_list(): """Fetches and parses the VPN list from the ProtonVPN API. @@ -44,8 +46,15 @@ if __name__ == "__main__": vpn_list = get_vpn_list() ip_range_groups = group_by_exit_ip_range(vpn_list) +# Set output directory and create it if it doesn't exist + output_dir = "output" + os.makedirs(output_dir, exist_ok=True) + + # Define output file path + output_file = os.path.join(output_dir, "rbldnsd-proton.db") + # Write to rbldnsd-compliant file - with open("/etc/rbldnsd-proton.db", "w") as f: + with open(output_file, "w") as f: f.write(":127.0.0.4:Listed, see https://protonvpn.com\n") # Header for ip_range, (country_code, server_names) in ip_range_groups.items(): f.write(f"{ip_range} ; ProtonVPN {country_code}\n") @@ -57,4 +66,20 @@ if __name__ == "__main__": print(f"Total IP Ranges: {total_ranges}") print("IP Ranges per Country:") for country_code, count in ranges_per_country.items(): - print(f" {country_code}: {count}") \ No newline at end of file + print(f" {country_code}: {count}") + +# Git commands + try: + subprocess.run(["git", "add", output_file], check=True) + subprocess.run(["git", "commit", "-m", "Update ProtonVPN IP ranges"], check=True) + subprocess.run(["git", "push", "origin"], check=True) + print("Changes pushed to git repository.") + except subprocess.CalledProcessError as e: + print(f"Error running git commands: {e}") + +# ping health system +try: + requests.get("https://health.ext.ben.io/ping/24296528-ffbf-4219-8ef5-07aa88aef414", auth=("local", "local"), timeout=10) +except requests.RequestException as e: + # Log ping failure here... + print("Ping failed: %s" % e) \ No newline at end of file