Skip to content

Devices by name, mr pause, policy route fallback: drop (#15) - #89

Merged
Cd1s merged 1 commit into
mainfrom
feat/devices-pause
Sep 26, 2026
Merged

Cd1s merged 1 commit into
mainfrom
feat/devices-pause

Conversation

@Cd1s

@Cd1s Cd1s commented Sep 26, 2026

Copy link
Copy Markdown
Owner

What

  • Device inventory: devices: / groups: (new dev module).
    • A device is a name plus 1–8 MACs, with an optional fixed IPv4, type and owner.
    • Other sections can refer to it by name, or to a group as group:NAME: forwards, access control, policy routes, proxy bypass, the guard's always_bypass, WOL and mr pause.
    • Names are resolved at validate / render time. router.yaml is never rewritten, and the old keys still work.
    • A reference to a missing name is an error that points to where it is used.
    • Each device renders one dhcp-host line. A MAC, name or IP lives in either dhcp.hosts or devices, never both.
  • Pause without a config change
    • CLI: mr pause DEVICE|group:x|MAC 1h, mr unpause. API: dev.pause / dev.unpause (operate), dev.paused (read).
    • Every firewall load adds nft sets with timeouts, in the same transaction. They are not in the rendered file, so there is no plan and no confirm window; the kernel lifts the pause when the time runs out.
    • The reload replaces the flowtable, so offloaded flows are cut too. (The router has no conntrack tool and no nf_conntrack_netlink, so deleting single connections was not an option.)
    • Firewall reloads are serialised.
  • policy_routes[].fallback: drop: when the rule's WAN is down, its traffic is dropped instead of leaking to another WAN.
  • Web UI:
    • new page 网络 › 设备: inventory, groups, references, pause;
    • a 暂停 button on 终端设备;
    • an overview card for active pauses;
    • device pickers in access control, policy routes, proxy bypass and forwards.
  • Integration with mode bypass selected: when a selected MAC belongs to a device, that device's line carries the tag, so there is still a single dhcp-host line.

Not included: unknown_devices: isolate (private MACs would lock out the owner's own devices) and OUI-based type guessing.

Verification

  • Go tests (mr/mod_dev_test.go, mr/mode_test.go).
  • tools/ci.d/dev.sh, real nft in network namespaces:
    • a paused device's software-offloaded download stops while other devices keep going;
    • the paused device can still use the router's DNS;
    • the pause survives a firewall reload and expires on its own;
    • fallback: drop cuts the traffic when the WAN has no route and restores it when the route comes back.
  • sh tools/ci.sh: ALL CHECKS PASSED. Cost: +64 KiB binary, nothing resident.

Closes #15

https://claude.ai/code/session_01HWeUjo1dmS7gBkCYHrVjCr

- devices: / groups: (dev module): a device = name + 1–8 MACs (+ fixed IPv4, type, owner). Referenced
  by name (or group:NAME) in forwards, access control, policy routes, proxy bypass, the guard, WOL and
  mr pause; resolved at validate / render time (router.yaml is never rewritten; old keys still work).
  Each device renders one dhcp-host line; a MAC, name or IP lives in dhcp.hosts or devices, not both.
- mr pause DEVICE|group:x|MAC 1h / mr unpause / API dev.pause|unpause|paused: nft sets with
  timeouts loaded with every firewall load (not in the rendered file: no plan, no confirm window),
  the kernel lifts them; the reload cuts offloaded flows too. Firewall reloads are serialised.
- policy_routes[].fallback: drop — the rule's traffic never leaks to another WAN when its WAN is down.
- Web UI: 网络 › 设备 (inventory, groups, references, pause), 暂停 on 终端设备, an overview card for
  active pauses; device pickers in access control, policy routes, proxy bypass and forwards.

Tests; CI (tools/ci.d/dev.sh) with real nft in network namespaces: a paused device's offloaded download
stops, others keep going, DNS to the router still works, the pause survives a reload and expires;
fallback: drop cuts and restores.

Closes #15

Claude-Session: https://claude.ai/code/session_01HWeUjo1dmS7gBkCYHrVjCr
@Cd1s
Cd1s merged commit be6302d into main Sep 26, 2026
2 checks passed
@Cd1s
Cd1s deleted the feat/devices-pause branch September 26, 2026 04:00
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