Added command line argument for explicite CA certificate choice
This commit is contained in:
+4
-1
@@ -10,13 +10,15 @@ import urllib.parse
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
api_url = "https://pi.hole/api"
|
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_password_file = "/etc/pihole/api_password"
|
||||||
default_keep_file = "/etc/pihole/dns_hosts_keep"
|
default_keep_file = "/etc/pihole/dns_hosts_keep"
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description="Sync static Pi-hole DHCP leases to local DNS entries.")
|
parser = argparse.ArgumentParser(description="Sync static Pi-hole DHCP leases to local DNS entries.")
|
||||||
parser.add_argument("-p", "--password-file", default=default_password_file,
|
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})")
|
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,
|
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})")
|
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",
|
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",
|
parser.add_argument("-j", "--json", action="store_true",
|
||||||
help="Print output as JSON instead of the default CSV")
|
help="Print output as JSON instead of the default CSV")
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
verify = args.ca_cert
|
||||||
|
|
||||||
if args.table and args.json:
|
if args.table and args.json:
|
||||||
parser.error("--table and --json are mutually exclusive")
|
parser.error("--table and --json are mutually exclusive")
|
||||||
|
|||||||
+4
-1
@@ -8,17 +8,20 @@ from datetime import datetime
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
api_url = "https://pi.hole/api"
|
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_password_file = "/etc/pihole/api_password"
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description="List non-static (dynamic) Pi-hole DHCP leases.")
|
parser = argparse.ArgumentParser(description="List non-static (dynamic) Pi-hole DHCP leases.")
|
||||||
parser.add_argument("-p", "--password-file", default=default_password_file,
|
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})")
|
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",
|
parser.add_argument("-t", "--table", action="store_true",
|
||||||
help="Print a human-readable aligned table (with local time expiry)")
|
help="Print a human-readable aligned table (with local time expiry)")
|
||||||
parser.add_argument("-j", "--json", action="store_true",
|
parser.add_argument("-j", "--json", action="store_true",
|
||||||
help="Print machine-readable output as JSON instead of the default CSV")
|
help="Print machine-readable output as JSON instead of the default CSV")
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
verify = args.ca_cert
|
||||||
|
|
||||||
if args.table and args.json:
|
if args.table and args.json:
|
||||||
parser.error("--table and --json are mutually exclusive")
|
parser.error("--table and --json are mutually exclusive")
|
||||||
|
|||||||
Reference in New Issue
Block a user