fix: decrypt DAL reads, read the uplink and facts from the gateway's answers #31

Merged
christianmanivong merged 3 commits from fix/dal-decrypt-facts-wan into main 2026-11-12 18:11:49 +00:00
3 Commits
Author SHA1 Message Date
Christian Manivong b6668eddbd test(facts): check get_facts against the gateway's recorded answers (#24)
driver / standard (pull_request) Successful in 18s
driver / lint (pull_request) Successful in 16s
driver / types (pull_request) Successful in 1m5s
driver / test (3.13) (pull_request) Successful in 1m10s
driver / test (3.12) (pull_request) Successful in 1m12s
driver / lowest (pull_request) Successful in 29s
driver / build (pull_request) Successful in 31s
driver / security (pull_request) Successful in 1m5s
CI / driver (pull_request) Successful in 2m35s
driver / publish (pull_request) Skipped
get_facts read SerialNumber, HostName, SystemUpTime and MacAddress
from getBasicInformation, which a VMG4005-B50A (V5.17(ABQA.3.1)C0)
answers with model, firmware and language settings only. The code
was fixed by #26 (host name and domain from the System page) and #28
(serial number and uptime from cardpage_status); the tests still fed
it an invented getBasicInformation (MOCK_BASIC_INFO) that carried
those fields, with an invented serial number and firmware.

MOCK_BASIC_INFO is now the recorded answer, and a new test reads the
facts from the recorded, sealed status page and the System page: it
fails against the driver before #26 with the symptoms of this issue
(serial "", uptime 0, host name the connection address). The README
names the sources get_facts reads.

Closes #24
2026-11-12 19:06:53 +01:00
Christian Manivong 3213dfaaaa fix(wan): read the uplink from the gateway's status page (#29)
get_wan_status built its answer from WanIp, WanAccessType,
SystemUpTime, MaxUpstream and MaxDownstream in getBasicInformation.
A VMG4005-B50A sends none of them there, so every gateway's uplink
read as down, with no address and no sync rate; get_nat_translations
built inside_global from the same WanIp and reported ":<port>".

Both now read the DAL's cardpage_status. A bridge has no WAN address
of its own, so it is connected when its DSL line is in sync (a
DslChannelInfo entry with Status "Up"); a router is connected when a
WAN interface that is not IP_Bridged is up with an address. The sync
rates are those of the channels in sync, added up for bonded lines;
a channel out of sync keeps its last rates, which are not reported.
A translation without a WAN address goes to 0.0.0.0, and without
enabled port forwards the status page is not read at all.

The tests read the recorded, anonymised status page of a
VMG4005-B50A bridge whose line was not in sync; the in-sync and
router states are derived from it.

Closes #29
2026-11-12 19:05:48 +01:00
Christian Manivong a47f9c3970 fix(dal): decrypt the DAL's answer before reading it (#25)
A GET of the DAL answers sealed ({"content", "iv"}), like a PUT does.
_read_dal_or_page parsed the envelope as it came, so hosts, the ARP
table, port forwards and the Wi-Fi getters found nothing on every
gateway, and since nothing raised the HTML fallback never ran either.

Every DAL GET now goes through one helper that decrypts the answer,
checks for ZCFG_SUCCESS and returns its Object list; the status page
and the System page share the decryption. Hosts are read from
lanhosts and port forwards from nat, the names the gateway's web
interface uses: LAN_HOSTS and NAT_PORTMAP are answered like any
unknown name, with an empty Object. The new parsers live in
napalm_zyxel/parsers.py, under strict mypy.

Tests seal recorded, anonymised answers of a VMG4005-B50A
(V5.17(ABQA.3.1)C0) with a real ZyxelCrypto, so the driver decrypts
them. The Wi-Fi DAL names stay unverified: that gateway has no Wi-Fi.

Closes #25
2026-11-12 19:03:40 +01:00