Skip to content

feat: Add GL.iNet router support with supplementary API data#56

Open
diggerburg wants to merge 3 commits into
cogwheel0:mainfrom
diggerburg:feature/glinet-support
Open

feat: Add GL.iNet router support with supplementary API data#56
diggerburg wants to merge 3 commits into
cogwheel0:mainfrom
diggerburg:feature/glinet-support

Conversation

@diggerburg

@diggerburg diggerburg commented Mar 30, 2026

Copy link
Copy Markdown

Summary

GL.iNet routers run a custom firmware layer on top of OpenWrt that provides additional data not available through standard ubus/LuCI RPCs. This PR auto-detects GL.iNet routers and fetches supplementary data from their /rpc JSON-RPC API alongside the existing LuCI data path.

All changes are backward-compatible — GL.iNet-specific code only activates when the router model contains "GL-" or "GL.iNet". Non-GL.iNet routers are completely unaffected.

What's new

Dashboard:

  • CPU temperature display (GL.iNet routers report SoC temperature)
  • Fan status (speed/active for models with fans)
  • CPU load shown as percentage on GL.iNet (core count is known), load average on other routers
  • WiFi cards show band labels (2.4 GHz / 5 GHz / 6 GHz)

Clients:

  • Accurate online/offline status from GL.iNet API (standard ubus DHCP leases don't distinguish)
  • WiFi band per client (2.4 GHz / 5 GHz / 6 GHz) instead of generic "Wi-Fi" / "Unknown"
  • Device class enrichment (phone, laptop, etc.)
  • Better device names from GL.iNet's client database
  • Online clients sorted before offline

Interfaces:

  • Real WiFi channels on Qualcomm IPQ platforms (where iwinfo returns N/A through ubus)
  • WiFi band labels in subtitle (e.g., "AP • 5 GHz • Ch. 44")
  • Tailscale interface shows actual IP address (Tailscale manages IPs outside netifd)

Bug fix:

  • CPU load no longer shows 100% on multi-core routers. The previous formula (load[0] / 65536) * 100 treated load average as a percentage, but load average of 2.0 on a 4-core system is ~50% utilization, not 200% clamped to 100%.

Screenshots

Dashboard Clients Interfaces
Dashboard Clients Interfaces

Technical details

  • GlInetApiService — lightweight service for GL.iNet /rpc auth + data fetching
  • Sha256Crypt — Unix SHA-256 crypt implementation (GL.iNet firmware ≥4.x uses $5$ password hashing)
  • GL.iNet session is cached and reused across poll cycles (cleared on logout/router switch)
  • HttpClientManager is injected (shared certificate acceptance with main LuCI client)
  • formatWifiBand() utility extracted to avoid duplication

Testing

  • 8 unit tests for SHA-256 crypt (verified against passlib reference vectors including empty password, unicode, special chars, custom rounds)
  • 6 unit tests for GlInetApiService (auth state, session cleanup, graceful null returns)
  • All 27 existing tests continue to pass
  • 41 total tests, 0 analyzer warnings
  • Tested on real hardware: GL.iNet GL-BE9300 (Flint 3), firmware 4.8.4, via LAN and Tailscale

Checklist

  • Code follows Dart style guide (dart format applied)
  • flutter analyze passes (0 errors, 0 warnings)
  • flutter test passes (41/41)
  • Backward compatible with non-GL.iNet OpenWrt routers
  • No security vulnerabilities (password hashed locally, never logged)
  • Documentation in code comments for GL.iNet auth protocol

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant