diff --git a/dhcp-dns-sync.py b/dhcp-dns-sync.py index 3a994d0..7da450a 100755 --- a/dhcp-dns-sync.py +++ b/dhcp-dns-sync.py @@ -10,13 +10,15 @@ import urllib.parse from pathlib import Path api_url = "https://pi.hole/api" -verify = "/etc/pihole/tls_ca.crt" +default_ca_cert = "/etc/pihole/tls_ca.crt" default_password_file = "/etc/pihole/api_password" default_keep_file = "/etc/pihole/dns_hosts_keep" parser = argparse.ArgumentParser(description="Sync static Pi-hole DHCP leases to local DNS entries.") parser.add_argument("-p", "--password-file", default=default_password_file, help=f"Path to file containing the Pi-hole API password (default: {default_password_file})") +parser.add_argument("-c", "--ca-cert", default=default_ca_cert, + help=f"Path to the Pi-hole TLS CA certificate for verification (default: {default_ca_cert})") parser.add_argument("-k", "--keep-file", default=default_keep_file, help=f"Path to file listing full 'ip name' DNS entries to keep regardless of DHCP state (default: {default_keep_file})") parser.add_argument("-n", "--dry-run", action="store_true", @@ -30,6 +32,7 @@ parser.add_argument("-t", "--table", action="store_true", parser.add_argument("-j", "--json", action="store_true", help="Print output as JSON instead of the default CSV") args = parser.parse_args() +verify = args.ca_cert if args.table and args.json: parser.error("--table and --json are mutually exclusive") diff --git a/dynamic-leases.py b/dynamic-leases.py index dd9e8a3..7cca758 100755 --- a/dynamic-leases.py +++ b/dynamic-leases.py @@ -8,17 +8,20 @@ from datetime import datetime from pathlib import Path api_url = "https://pi.hole/api" -verify = "/etc/pihole/tls_ca.crt" +default_ca_cert = "/etc/pihole/tls_ca.crt" default_password_file = "/etc/pihole/api_password" parser = argparse.ArgumentParser(description="List non-static (dynamic) Pi-hole DHCP leases.") parser.add_argument("-p", "--password-file", default=default_password_file, help=f"Path to file containing the Pi-hole API password (default: {default_password_file})") +parser.add_argument("-c", "--ca-cert", default=default_ca_cert, + help=f"Path to the Pi-hole TLS CA certificate for verification (default: {default_ca_cert})") parser.add_argument("-t", "--table", action="store_true", help="Print a human-readable aligned table (with local time expiry)") parser.add_argument("-j", "--json", action="store_true", help="Print machine-readable output as JSON instead of the default CSV") args = parser.parse_args() +verify = args.ca_cert if args.table and args.json: parser.error("--table and --json are mutually exclusive")