Repository navigation
feat(udm-wan-monitor): define WAN ports manually and choose the cable WAN - #16
Draft
lennard0711 wants to merge 3 commits into
Draft
lennard0711 wants to merge 3 commits into
lennard0711 wants to merge 3 commits into
Conversation
…UniFi WAN-Monitor, fix polling on current DOCSight Verified against a UCG Ultra (UDRULT, UniFi OS 5.1.33), including a real failover (WAN 1 unplugged and reconnected). - Derive WAN port names from the gateway's wan1/wan2 ifname instead of hardcoding the UDM Pro's eth9/eth8 (UCG Ultra: eth4/eth0), so it follows whichever ports are assigned as WAN, including reassigned LAN ports. Only wan1 and wan2 are considered; a WAN that is not configured produces no row. Dashboard cards show the real ifname. - Select the gateway by type (udm/ugw/usg/ucg) and presence of wan1; never fall back to devices[0], which could be a switch or AP and would report a bogus offline WAN. Fail with "No gateway device found" or "No WAN interface (wan1/wan2) found on gateway" instead. - Fix CollectorResult.ok()/failure() no longer existing in current DOCSight (every poll was recorded as a failure). Helpers use them only if present. - Reuse the collector's session for dashboard requests and only fall back to the legacy /api/login on 404/405. A login per request tripped UniFi OS' login rate limit (429), which was then masked as a 401. - Rename the module to "UniFi WAN-Monitor" (display name only; module id, directory, routes and event type are unchanged) and mention UCG in the texts. - Version 3.2.0.
- IP: show the WAN interface's own address, as UniFi Network does. Behind another router (double NAT) that is a private address, so the previous geo-detected public address looked wrong next to the UniFi dashboard. The public address stays available as ip_public and is shown in an extra "Public IP" row only when it differs from the interface IP. - IPv6: skip link-local (fe80::/10) addresses. UniFi lists them first, so an uplink without IPv6 showed a link-local address as if it had one. - Add label_ip_public translations (en, de, fr, es).
… WAN
Manual WAN ports
When the gateway reports no wan1/wan2 (or another port should be monitored,
e.g. an SFP+ uplink), WAN ports can now be added by interface name.
- Settings: replace the four fixed "extra port" fields with a list and an
"Add port" button (dialog for interface + alias, remove button per row, up
to 8 ports). The list is stored as JSON in the new key udm_wan_extra_ports.
The dialog lives outside the settings form, so its fields are not saved as
stray config keys.
- Existing setups keep working: while udm_wan_extra_ports has never been
saved, the legacy udm_wan_extra_port{1,2}_* fields are read and shown in
the list; after the first save the list takes over.
- The module no longer fails with "No WAN interface" when ports were defined
manually; they are shown in the port table (link, speed, traffic). A WAN
without interface is shown as unknown instead of offline on the dashboard.
- Entries are validated (interface name pattern, no duplicates, alias max 40
chars, max 8 ports).
Cable WAN
New setting udm_wan_primary (not set / WAN 1 / WAN 2) for the WAN that
carries the cable connection DOCSight monitors.
- Dashboard: the selected WAN gets a "DOCSight" badge and is shown first.
- Events: with a cable WAN set, outages of the other WAN (link down, offline,
not alive) are reported as warning instead of critical; the cable WAN keeps
critical. Not set = unchanged behaviour.
Version 3.3.0.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Builds on the UCG support PR (#14, 3.2.0) and the display PR (3.2.1) and bumps the module to 3.3.0. Please merge those first; until then this PR also shows their commits.
Hi @Oggy512, this replaces the four fixed "extra port" fields with a list you can add to, lets users define WAN ports by hand when the gateway reports none, and adds a setting for which WAN carries the cable connection DOCSight monitors.
Summary
Port assignment is flexible on UniFi gateways (on my UCG Ultra a LAN port is WAN 2). If automatic detection finds no
wan1/wan2, the user can now define the WAN port(s) themselves instead of being stuck. With two WANs, users can also mark which one is the cable connection.Changes
udm_wan_extra_ports. The dialog uses DOCSight's own modal classes and sits outside the settings form so its inputs are not saved as stray config keys. Entries are validated (interface name pattern, no duplicates, alias ≤ 40 chars).udm_wan_extra_portshas never been saved, the legacyudm_wan_extra_port{1,2}_*fields are read and shown in the list. After the first save the list takes over.warninginstead ofcritical, since the monitored connection is still up; the cable WAN keepscritical. Not set (default) = unchanged behaviour. Failover events are unchanged.Note: UniFi only reports alive/online status for
wan1/wan2, so manually defined ports are display-only (as the old extra ports were).Testing
python3 -m unittest discover -s testsandscripts/validate_registry.pypass.