feat: add automation scripts for NAS fixes, Authentik monitoring, and Technitium DNS management
This commit is contained in:
27
scripts/test_tech_api.py
Normal file
27
scripts/test_tech_api.py
Normal file
@@ -0,0 +1,27 @@
|
||||
import urllib.request
|
||||
import ssl
|
||||
import json
|
||||
import urllib.parse
|
||||
import sys
|
||||
|
||||
sys.stdout.reconfigure(encoding='utf-8')
|
||||
|
||||
ctx = ssl.create_default_context()
|
||||
ctx.check_hostname = False
|
||||
ctx.verify_mode = ssl.CERT_NONE
|
||||
|
||||
def get_token(host):
|
||||
url = f"https://{host}/api/user/login?user=admin&pass=snarfnetadmin&includeInfo=true"
|
||||
with urllib.request.urlopen(urllib.request.Request(url), context=ctx, timeout=8) as resp:
|
||||
return json.loads(resp.read().decode())['token']
|
||||
|
||||
token = get_token("dns1.snarfnet.net")
|
||||
print("Acquired token on dns1:", token[:8] + "...")
|
||||
|
||||
# Create primary zone snarfnet.net
|
||||
create_url = f"https://dns1.snarfnet.net/api/zones/create?token={token}&zone=snarfnet.net&type=Primary"
|
||||
try:
|
||||
with urllib.request.urlopen(urllib.request.Request(create_url), context=ctx, timeout=8) as resp:
|
||||
print("Create zone response:", json.loads(resp.read().decode()))
|
||||
except urllib.error.HTTPError as e:
|
||||
print("HTTPError:", e.code, e.read().decode())
|
||||
Reference in New Issue
Block a user