marker: rework pause/resume from project-wide to per-definition

The project-wide mute (POST /markers/pause|resume + _markers_paused) paused
every marker with one button. The actual need is per-rule control: pause one
definition and toggle only its inherited global-{name} copies across all links.

- Drop project-level: _markers_paused (init/asdict/load/start_all), the
  pause_all/resume_all_markers methods, and the /markers/pause|resume routes.
- Add per-definition: a persisted `paused` flag on each definition;
  pause/resume_marker_definition fan out update_marker(enabled) to every
  global-{name} copy — instant, via the existing enable_packet_filter toggle
  (no NIO rebuild, pcap/emitted preserved). New links inherit a paused
  definition already off (inherit_marker passes enabled=not paused).
- start_marker takes an enabled kwarg; update_marker's enabled-only short-circuit
  now also covers inherited copies so def pause/resume is instant.
- Routes: POST /marker-definitions/{name}/pause|resume.
- Docs + tests updated.
This commit is contained in:
YueGuobin committed 2026-08-02 22:46:33 +08:00
1 parent e97df86d96
commit 1eeee024bd
7 files changed
+113 -114

No files matched your search

+2 -1
View File
@@ -131,6 +131,7 @@ class Link:
direction=marker_def.get("direction"),
color=marker_def.get("color"),
highlight_duration=marker_def.get("highlight_duration"),
enabled=not marker_def.get("paused", False),
inherited_from=def_name,
)
@@ -341,7 +342,7 @@ class Link:
raise NotImplementedError
async def start_marker(self, name, bpf, tag=None, direction=None, capture_node_id=None):
async def start_marker(self, name, bpf, tag=None, direction=None, capture_node_id=None, enabled=True):
"""
Attach a traffic-insight marker to this link (base — UDPLink overrides).
"""