unifi-dns
unifi-dns copied to clipboard
Add Support for cloudkeys running Unifi OS?
Cloudkeys (inc Gen 2 that I have) were recenly updated to Unifi OS. The script does not appear to work with these? https://community.ui.com/questions/CloudKey-Gen2-updated-8443-not-working-anymore-reset-still-same-issue/c384eca4-d754-4cec-9518-161ca2552fd6
- the default
UNIFI_BASEURL
includes port 8443 whereas the new OS no longer has that open; all services are consolidated on port 443 - (Leaving a trailing
/
on the URL confuses the path handling sending it to a 404 page, it'd be nice to handle that case) - Fixing the URL to point to 443 sends the JSON decoder into a spin:
/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py:1013: InsecureRequestWarning: Unverified HTTPS request is being made to host 'cloudkey'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings,
warnings.warn(,
/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py:1013: InsecureRequestWarning: Unverified HTTPS request is being made to host 'cloudkey'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings,
warnings.warn(,
Traceback (most recent call last):,
File "/app/./get_unifi_reservations.py", line 80, in <module>,
for c in get_clients():,
File "/app/./get_unifi_reservations.py", line 45, in get_clients,
clients = get_configured_clients(s),
File "/app/./get_unifi_reservations.py", line 24, in get_configured_clients,
return r.json()["data"],
File "/usr/local/lib/python3.9/site-packages/requests/models.py", line 900, in json,
return complexjson.loads(self.text, **kwargs),
File "/usr/local/lib/python3.9/json/__init__.py", line 346, in loads,
return _default_decoder.decode(s),
File "/usr/local/lib/python3.9/json/decoder.py", line 337, in decode,
obj, end = self.raw_decode(s, idx=_w(s, 0).end()),
File "/usr/local/lib/python3.9/json/decoder.py", line 355, in raw_decode,
raise JSONDecodeError("Expecting value", s, err.value) from None,
json.decoder.JSONDecodeError: Expecting value: line 2 column 1 (char 1),
LMK if I can collect some more logs to debug further
As a little more info, after login the tool is requesting https://cloudkey/api/s/default/list/user
but this appears to be a terse html page containing JS that affects a redirect to the main landing page (https://cloudkey/
for me)
https://cloudkey/api/s/default/list/user
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1"><link href="/2.css" rel="stylesheet"></head>
<body>
<div id="root"></div>
<script type="text/javascript" src="/vendor.0306759b.chunk.js"></script><script type="text/javascript" src="/main.d8e6c715.js"></script></body>
</html>
There's a thread here confirming Unifi OS removed the API, I can't see any solution posted. For the purpose of this tool, maybe there's another path to fetching the required info? (ssh?)
Sorry for the delayed reply, it seems I'm not getting my github notifications.. Yeah, not sure what could be done about the API being removed from cloudkeys. If the client list / dhcp reservations are available through ssh then sure - should be possible to use that. But since that wouldn't work on the dockerized version I can't do much about it - I don't have a cloudkey. If you want to mess around with it I'm happy to receive PRs for it.