Skip to content

Fix CM1000 multi-login recovery: release the old session, then log in again - #6

Merged
mphuff merged 1 commit into
masterfrom
claude/netgear-multilogin-relogin-fix
Aug 5, 2026
Merged

Fix CM1000 multi-login recovery: release the old session, then log in again#6
mphuff merged 1 commit into
masterfrom
claude/netgear-multilogin-relogin-fix

Conversation

@mphuff

@mphuff mphuff commented Jul 30, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes the CM1000 failing to recover when the modem is already holding an admin session (the "you are currently logged in from another device" interstitial). The prior handling detected the interstitial but never completed login, so the scraper looped on it every interval and never got in.

Root cause

Clicking "Yes" on that interstitial is not a one-click takeover. POST /goform/MultiLogin only releases the existing admin session and bounces back to the login page — the modem then admits the next login. The previous code did the "Yes" POST and treated the resulting login page as a failure, so recovery never completed. In syslog this showed up as:

INFO   Netgear reports an existing admin session; taking it over ("Yes")
ERROR  Netgear login failed (received the login form again). ...
INFO   Unable to obtain valid login session, sleeping for: 30s

…repeating every interval.

Fix

login() now mirrors what a browser does, on a single shared requests.Session so cookies persist and update automatically:

  1. _attempt_login() — GET the login page for a fresh webToken, POST credentials.
  2. If the interstitial comes back, _confirm_multi_login() POSTs "Yes" to release the existing session.
  3. _attempt_login() again on the same session to actually get in.

Additional robustness: the "Yes" payload is now built from the interstitial's real hidden inputs via _hidden_form_fields() (Act / RetailSessionId / webToken exactly as served), instead of the guessed empty strings the first version sent — so the modem sees its own session identifiers.

The false-positive guard remains: login() only returns a session once the response is confirmed to be neither the login form nor the interstitial, so a failed recovery can never hand back a dead session (which is what caused the original multi-hour stall after an outage).

Test plan

  • bash tests/run_tests.sh — all 11 tests pass
  • Added test_hidden_form_fields_multi_login covering the Act / RetailSessionId / unquoted-webToken extraction from the interstitial HTML
  • Verify against a live CM1000v2 while a session is held: log should show releasing it ("Yes") and re-logging in, a second Obtaining login session…, then Retreiving stats… with no "received the login form again"

🤖 Generated with Claude Code


Generated by Claude Code

The "you are currently logged in from another device" interstitial is not a
one-click takeover. Clicking "Yes" (POST /goform/MultiLogin) only RELEASES
the existing admin session and bounces back to the login page -- the modem
then admits the NEXT login. The previous fix did the "Yes" POST and treated
the resulting login page as failure, so recovery never completed (observed
in syslog: "taking it over" immediately followed by "received the login form
again", looping every interval).

Rework login() to mirror the browser flow on a single shared Session (so
cookies persist/update automatically):

  1. _attempt_login(): GET login page for a fresh webToken, POST credentials
  2. if the interstitial comes back, _confirm_multi_login() POSTs "Yes" to
     release the old session
  3. _attempt_login() again on the same Session to actually get in

Also build the "Yes" payload from the interstitial's real hidden inputs via
_hidden_form_fields() (Act / RetailSessionId / webToken as served) instead of
guessed empty strings, so the modem sees its own session identifiers.

Tests: add _hidden_form_fields coverage for the interstitial HTML.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018bKShZ5y7RFZzqfbkn6WZq
@mphuff
mphuff merged commit aac412d into master Aug 5, 2026
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.

2 participants