- Created unifi_targets.txt and unifi_targets_strict.txt files to define DNS records for services including authentik, caddy, and others. - Included ingress CNAMEs for modules such as audiobookshelf, gitea, grafana, and more. - Ensured both files contain comprehensive lists of DNS records to support service discovery and routing.
50 lines
1.5 KiB
Python
50 lines
1.5 KiB
Python
import requests
|
|
import json
|
|
import urllib3
|
|
|
|
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
|
|
|
UNIFI_URL = "https://udm.renner.uno"
|
|
USERNAME = "OpenTofu"
|
|
PASSWORD = "5c&DKC4AFUU3hcWN!S3n8TF&B%Rx!vM"
|
|
|
|
def login():
|
|
session = requests.Session()
|
|
session.verify = False
|
|
headers = {"Content-Type": "application/json"}
|
|
payload = {"username": USERNAME, "password": PASSWORD}
|
|
resp = session.post(f"{UNIFI_URL}/api/auth/login", json=payload, headers=headers)
|
|
if resp.status_code != 200:
|
|
print(f"Login failed: {resp.status_code}")
|
|
exit(1)
|
|
return session
|
|
|
|
def find_client(session, mac):
|
|
# Try /api/s/default/rest/user (Known clients/Users)
|
|
resp = session.get(f"{UNIFI_URL}/proxy/network/api/s/default/rest/user")
|
|
if resp.status_code == 200:
|
|
data = resp.json()
|
|
for client in data.get('data', []):
|
|
if client.get('mac') == mac:
|
|
return client
|
|
|
|
# Try /api/s/default/stat/sta (Active clients)
|
|
resp = session.get(f"{UNIFI_URL}/proxy/network/api/s/default/stat/sta")
|
|
if resp.status_code == 200:
|
|
data = resp.json()
|
|
for client in data.get('data', []):
|
|
if client.get('mac') == mac:
|
|
return client
|
|
|
|
return None
|
|
|
|
session = login()
|
|
target_mac = "bc:24:11:85:43:9c"
|
|
client = find_client(session, target_mac)
|
|
|
|
if client:
|
|
print(json.dumps(client, indent=2))
|
|
print(f"FOUND: ID={client.get('_id')}")
|
|
else:
|
|
print("NOT FOUND")
|