From 2839416831081eeee18768ad13c2a378a8d8087e Mon Sep 17 00:00:00 2001 From: Cyberes Date: Wed, 28 Feb 2024 14:26:50 -0700 Subject: [PATCH] fix insecure, expand readme --- README.md | 5 +++-- syncer.py | 8 ++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 84de9ee..18f3583 100644 --- a/README.md +++ b/README.md @@ -26,8 +26,9 @@ able to resolve your custom domains. ```shell sudo cp pihole-opnsense-sync.service /etc/systemd/system/pihole-opnsense-sync.service ``` - The service runs as the `pihole:pihole` user. -5. Enable and start the service: + The service is configured to run as the `pihole:pihole` user. +5. Edit the service file. You might need to modify `--opnsense` and add `--insecure`. +6. Enable and start the service: ```shell sudo systemctl enable --now pihole-opnsense-sync sleep 2 diff --git a/syncer.py b/syncer.py index 5ac2571..cf16366 100755 --- a/syncer.py +++ b/syncer.py @@ -23,7 +23,7 @@ class WatchdogHandler(FileSystemEventHandler): def file_modified(args): - response = requests.get(args.opnsense + "/api/unbound/settings/searchHostOverride", auth=(args.api_key, args.api_secret), verify=args.insecure) + response = requests.get(args.opnsense + "/api/unbound/settings/searchHostOverride", auth=(args.api_key, args.api_secret), verify=not args.insecure) if response.status_code == 200: data = response.json() @@ -40,7 +40,7 @@ def file_modified(args): for item_ip, item_domain in to_remove: item_data = current_overrides_uuid[item_domain] - p = requests.post(args.opnsense + f"/api/unbound/settings/delHostOverride/{item_data['uuid']}", auth=(args.api_key, args.api_secret), verify=args.insecure) + p = requests.post(args.opnsense + f"/api/unbound/settings/delHostOverride/{item_data['uuid']}", auth=(args.api_key, args.api_secret), verify=not args.insecure) if p.status_code != 200: raise Exception(f'Failed to delete item {item_domain}: {p.status_code} - {p.text}') else: @@ -62,13 +62,13 @@ def file_modified(args): 'description': f'Synced from Pi-hole {dt_string}' } } - p = requests.post(args.opnsense + "/api/unbound/settings/addHostOverride", json=p_data, auth=(args.api_key, args.api_secret), verify=args.insecure) + p = requests.post(args.opnsense + "/api/unbound/settings/addHostOverride", json=p_data, auth=(args.api_key, args.api_secret), verify=not args.insecure) if p.status_code != 200: raise Exception(f'Failed to add item {item_domain}: {p.status_code} - {p.text}') else: logger.info(f'Added: {item_domain}') - p_reload = requests.post(args.opnsense + "/api/unbound/service/reconfigure", auth=(args.api_key, args.api_secret), verify=args.insecure) + p_reload = requests.post(args.opnsense + "/api/unbound/service/reconfigure", auth=(args.api_key, args.api_secret), verify=not args.insecure) if p_reload.status_code != 200: raise Exception(f'Failed to reload service: {p_reload.status_code} - {p_reload.text}') else: