mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 14:01:15 +02:00
mcp: drop direction from marker_definition tool
A marker definition fans out to every link and auto-selects its capture node on each, so tx/rx is relative to a node that varies per link — the controller already rejects it (409). Exposing direction on the MCP definition tool let an agent ask for something that could only fail. Remove the parameter and the handler's direction handling; the docstring now points to encoding direction in the BPF (e.g. 'icmp and icmp[icmptype]==8'). Per-link link_marker keeps direction, where the capture node is fixed.
This commit is contained in:
3 files changed
+39
-41
No files matched your search
@@ -1052,7 +1052,6 @@ async def marker_definition(
|
||||
tag: Annotated[int | None, Field(description="Numeric tag for packet correlation")] = None,
|
||||
color: Annotated[str | None, Field(description="Hex color for UI highlight, e.g. '#ff5722'")] = None,
|
||||
highlight_duration: Annotated[int | None, Field(description="UI highlight duration in milliseconds")] = None,
|
||||
direction: Annotated[str | None, Field(description="Direction filter: 'tx' (capture node sending only), 'rx' (receiving only), or 'both' (no filter — on update this clears a previously set direction). Omit to leave unchanged on update.")] = None,
|
||||
) -> list[dict[str, Any]]:
|
||||
"""Manage project-level marker definitions — traffic-insight rules that apply to ALL links.
|
||||
|
||||
@@ -1061,14 +1060,20 @@ async def marker_definition(
|
||||
On delete, 'global-{name}' is removed from every link.
|
||||
|
||||
Create requires: project_id, action='create', bpf
|
||||
Update requires: project_id, action='update', def_name, and at least one of (bpf, tag, direction, color, highlight_duration)
|
||||
Update requires: project_id, action='update', def_name, and at least one of (bpf, tag, color, highlight_duration)
|
||||
Delete requires: project_id, action='delete', def_name
|
||||
List requires: project_id, action='list'
|
||||
|
||||
A definition has NO direction (tx/rx): it fans out to every link and auto-selects
|
||||
its capture node on each, so a fixed direction has no consistent meaning. Encode
|
||||
the direction you want in the BPF instead (e.g. 'icmp and icmp[icmptype]==8' for
|
||||
echo requests only). For a capture-node-relative direction on a single link, use
|
||||
the per-link `link_marker` tool.
|
||||
|
||||
Common BPF examples: 'arp', 'icmp', 'ospf', 'tcp port 22', 'udp port 53'
|
||||
"""
|
||||
params = {"project_id": project_id, "action": action}
|
||||
for opt in ("bpf", "def_name", "name", "tag", "direction", "color", "highlight_duration"):
|
||||
for opt in ("bpf", "def_name", "name", "tag", "color", "highlight_duration"):
|
||||
val = locals().get(opt)
|
||||
if val is not None:
|
||||
params[opt] = val
|
||||
|
||||
@@ -460,9 +460,9 @@ def marker_definition_handler(params: dict[str, Any], gns3_ctx: dict[str, Any])
|
||||
for opt in ("name", "tag", "color", "highlight_duration"):
|
||||
if params.get(opt) is not None:
|
||||
body[opt] = params[opt]
|
||||
# direction: "tx"/"rx" set a one-way filter; "both"/omitted = no filter.
|
||||
if params.get("direction") in ("tx", "rx"):
|
||||
body["direction"] = params["direction"]
|
||||
# No direction: a definition fans out to every link and auto-selects its
|
||||
# capture node on each, so tx/rx (which is relative to that node) has no
|
||||
# consistent meaning. Encode direction in the BPF instead.
|
||||
return conn.http_call("post", base, json_data=body).json()
|
||||
|
||||
def_name = params.get("def_name")
|
||||
@@ -476,14 +476,8 @@ def marker_definition_handler(params: dict[str, Any], gns3_ctx: dict[str, Any])
|
||||
for opt in ("bpf", "tag", "color", "highlight_duration"):
|
||||
if params.get(opt) is not None:
|
||||
body[opt] = params[opt]
|
||||
# direction tri-state: omitted=preserve, "tx"/"rx"=set, "both"=clear (→ null).
|
||||
direction = params.get("direction")
|
||||
if direction == "both":
|
||||
body["direction"] = None
|
||||
elif direction in ("tx", "rx"):
|
||||
body["direction"] = direction
|
||||
if not body:
|
||||
return {"error": "At least one update field is required (bpf, tag, direction, color, highlight_duration)"}
|
||||
return {"error": "At least one update field is required (bpf, tag, color, highlight_duration)"}
|
||||
return conn.http_call("put", url, json_data=body).json()
|
||||
|
||||
# action == "delete"
|
||||
|
||||
Reference in new issue
Block a user