From c8d9d2fb0668db92972bfbe71cf39fa30b6b4db7 Mon Sep 17 00:00:00 2001 From: tsosunchia <59512455+tsosunchia@users.noreply.github.com> Date: Tue, 8 Sep 2026 14:48:38 +0800 Subject: [PATCH] =?UTF-8?q?docs(cli):=20=E8=A1=A5=E9=BD=90=20MTR=20?= =?UTF-8?q?=E4=B8=8E=E8=AF=8A=E6=96=AD=E7=89=B9=E6=80=A7=E7=9A=84=E5=A5=91?= =?UTF-8?q?=E7=BA=A6=E5=92=8C=E5=B9=B3=E5=8F=B0=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AGENTS.md | 27 +++++++++-- README.md | 12 +++-- README_zh_CN.md | 12 +++-- docs/mtr-json.md | 25 +++++++++- docs/mtr-session.md | 46 ++++++++++++++++++- .../nexttrace/references/capability-matrix.md | 4 ++ skills/nexttrace/references/cli-fallback.md | 38 +++++++++++++++ skills/nexttrace/references/platform-notes.md | 10 ++++ skills/nexttrace/references/validation.md | 20 ++++++++ trace/internal/icmp_windows.go | 2 + 10 files changed, 183 insertions(+), 13 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 3f00f52..1599273 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -108,12 +108,33 @@ - `-w/--wide`:宽报告模式,隐式等价 `--mtr --report --wide`。 - `--raw`:与 MTR 组合时进入 **MTR raw 流式模式**(`runMTRRaw`),不再与 MTR 冲突。 - 有效 MTR 开关:`effectiveMTR = mtr || report || wide`。 -- MTR 三路分支(`chooseMTRRunMode`): +- MTR 文本/RAW 三路分支(`chooseMTRRunMode`;JSON 提前单独分发): 1. `effectiveMTRRaw` → `runMTRRaw`(流式行输出,适合管道/脚本) 2. `effectiveReport` → `runMTRReport`(非交互报告表) 3. 默认 → `runMTRTUI`(全屏 TUI) -- MTR 冲突参数(会直接报错退出):`--table` `--classic` `--json` `--output` `--route-path` `--from` `--fast-trace` `--file` `--deploy`。 - - **注意**:`--raw` 不再是冲突参数。 +- MTR 冲突参数(会直接报错退出):`--table` `--classic` `--output` `--route-path` `--from` `--fast-trace` `--file` `--deploy`。 + - **注意**:`--raw`、`--json` 均可选择 MTR 输出,但两者互斥。 + +### JSON、录制、回放与自定义列 + +- 三个 flavor 均支持 MTR JSON;`--mtr --json` 为 NDJSON,`-r/-w --json` 为最终单文档,`ntr --json` 默认流式。完整/tiny 单独 `--json` 仍为传统 traceroute。 +- JSON stream 的非正 `-q` 表示无限;JSON report 默认 10,显式非正值报错。FULL metadata 不保证 Geo/PTR 一定存在,遵守 provider/DNS 设置。 +- TCP/UDP 的 `--source-port -1` 在文本、JSON、录制中均为逐包随机;`0` 自动选择,正数固定端口。 +- `probe` 先于其 `path_end`;录制失败丢弃 causal probe 时,JSON 不得发布该 pending path。max-hops 可在最后 probe 后单独 flush。 +- `--mtr-record FILE` 独占创建新文件,保留完整 UTF-8 JSON 行;写入失败停止探测。首个会话错误及阶段不被后续录制 start/finish 错误覆盖。 +- `--mtr-replay FILE` 为纯离线独立入口,拒绝 target/探测参数/stdin;TTY 默认停在末尾,非 TTY/report 输出最终表,JSON 使用独立 `mtr_replay` 文档。 +- 回放 `j/J` 定位、Space 播放、`p` 暂停、`r` 回到开头;残缺文件恢复有效前缀但非零退出。显示副本过滤 Unicode Cc/Cf,文件与 JSON 原值保留。 +- `--mtr-columns` 只控制 MTR/回放文本列,不改变 RAW/JSON;`o/O` 会话内编辑,`d/D` 历史视图、`g/G` 切换三种图表。默认统计列不变,新增可选 Received/Rcv。 +- 契约与验收入口:[MTR JSON](docs/mtr-json.md)、[录制/回放](docs/mtr-session.md)、[CLI 说明](skills/nexttrace/references/cli-fallback.md)。 + +### Doctor、fwmark 与 TOS + +- `--doctor` 三个 flavor 可用,只做纯文本本地初始化检查,不发送探测;DNS/DoT 可以联网。Windows 使用 NO_INSTALL,不安装驱动。成功不等于可达、TOS 生效或实际出口已验证。 +- Doctor 明确拒绝 `--fwmark` 与随机源端口 `-1`;不要为此扩展 BackendOptions 来暗示该组合受支持。 +- `--fwmark` 仅 Linux 本地 traceroute/MTR,支持十进制/十六进制 uint32,显式零也设置并检查权限;独立模式、批量、远程及 deploy/MCP 不支持。 +- 标记与非零 TOS 参与 Linux 会话选源,保留显式 source/device 约束,不标记 DNS/Geo/API 请求;初始化失败停止探测,不变成 MTR 丢包。 +- Linux IPv4 UDP 使用 raw connect 选源且不发送报文;只能确认源地址,Doctor 不据此推断出口接口/网关。netlink DONE 无匹配路由立即返回错误。 +- Windows amd64 非零 ICMP TOS 使用 WinDivert 发送;默认/零仍为原生 socket。详见中英文 README 的平台限制与参数说明。 ### MTR 中 `-q/-i/-y` 的新语义 diff --git a/README.md b/README.md index 80d7305..07a17a1 100644 --- a/README.md +++ b/README.md @@ -194,6 +194,10 @@ Starting from this release, NextTrace is published in **three flavors** under th | MTR report (`-r`) | ✅ | ✅ | ✅ | | MTR wide (`-w`) | ✅ | ✅ | ✅ | | MTR raw (`--raw`) | ✅ | ✅ | ✅ | +| MTR JSON / NDJSON | ✅ | ✅ | ✅ | +| MTR custom columns (`--mtr-columns`) | ✅ | ✅ | ✅ | +| MTR recording / replay (`--mtr-record` / `--mtr-replay`) | ✅ | ✅ | ✅ | +| Linux policy routing (`--fwmark`, local probes only) | ✅ | ✅ | ✅ | | Globalping (`--from`) | ✅ | — | — | | WebUI (`--deploy`) / MCP (`--deploy --mcp`) | ✅ | — | — | | Fast Trace (`-F`) | ✅ | ✅ | — | @@ -329,7 +333,7 @@ ntr --doctor --dev eth0 example.com `--doctor` generates a plain-text report and exits without tracing. It separates requested settings, DNS/source selection, system route predictions, and actual local backend initialization. It does not send probe packets, read captured traffic, query GeoIP/API services, or verify target reachability. DNS/DoT queries can use the network. -All three builds support `--doctor`. Options are limited to `--ipv4`/`--ipv6`, `--tcp`/`--udp`, `--port`, `--source`, `--source-port`, `--dev`, `--tos`, `--dot-server`, `--timeout`, `--language`, `--no-color`, and Windows `--icmp-mode`, plus their listed short aliases. Use `--doctor --help` for details. The target must be a domain or IP literal; URLs and IPv6 zone suffixes are not accepted. Doctor is incompatible with other execution modes, JSON/RAW/file output, and unrelated probe options. +All three builds support `--doctor`. Options are limited to `--ipv4`/`--ipv6`, `--tcp`/`--udp`, `--port`, `--source`, `--source-port`, `--dev`, `--tos`, `--dot-server`, `--timeout`, `--language`, `--no-color`, and Windows `--icmp-mode`, plus their listed short aliases. Use `--doctor --help` for details. The target must be a domain or IP literal; URLs and IPv6 zone suffixes are not accepted. Doctor is incompatible with other execution modes, JSON/RAW/file output, and unrelated probe options. It rejects `--fwmark`, so it cannot verify marked routing or `SO_MARK` privileges. Doctor accepts source ports `0..65535`, not the probe mode's random value `-1`. The default is ICMP, Chinese text, and 5000 ms per network check. Multiple DNS candidates are listed; the first matching the requested family is selected without prompting. Target DoT failures do not fall back to system DNS. A failed check does not prevent independent checks from completing. The report goes to stdout; usage and output-write errors go to stderr. Reports include target/source/interface addresses, but no token or proxy credentials. @@ -466,7 +470,7 @@ nexttrace --udp 1.0.0.1 nexttrace --udp --port 5353 1.0.0.1 # For TCP/UDP Trace, you can specify the source port; by default, a fixed random port is used -# (If you need to use a different random source port for each packet, please set the ENV variable NEXTTRACE_RANDOMPORT, or set the source port to -1) +# (If you need to use a different random source port for each packet, please set the ENV variable NEXTTRACE_RANDOMPORT, or set the source port to -1; this also applies to MTR text, JSON and recording) nexttrace --tcp --source-port 14514 www.bing.com ``` @@ -721,7 +725,7 @@ When running in a terminal (TTY), MTR mode uses an **interactive full-screen TUI - **`p`** — pause probing - **`SPACE`** — resume probing - **`r`** — reset statistics (counters are cleared, display mode is preserved) -- **`y`** — cycle host display mode: ASN → City → Owner → Full +- **`y`** — cycle host display mode: IP/PTR → ASN → City → Owner → Full - **`n`** — toggle host name display: - default: PTR (or IP fallback) ↔ IP only - with `--show-ips`: PTR (IP) ↔ IP only @@ -875,6 +879,8 @@ All NextTrace IP geolocation `API DEMO` can refer to [here](https://github.com/n ### Environment Variables +With `NEXTTRACE_DEBUG`, environment-read logs for known tokens, IPDB credentials and proxy URLs show only the variable name and presence, never their values. Other diagnostics can still contain target/source addresses and interface names. + NextTrace currently reads the following environment variables. For `NEXTTRACE_*` boolean switches, only `1` and `0` are recognized; other values fall back to the built-in default. For consistency, restart NextTrace after changing them. #### Core Runtime / Network diff --git a/README_zh_CN.md b/README_zh_CN.md index 0964349..a785e0a 100644 --- a/README_zh_CN.md +++ b/README_zh_CN.md @@ -195,6 +195,10 @@ Document Language: [English](README.md) | 简体中文 | MTR 报告(`-r`) | ✅ | ✅ | ✅ | | MTR 宽报告(`-w`) | ✅ | ✅ | ✅ | | MTR 原始输出(`--raw`) | ✅ | ✅ | ✅ | +| MTR JSON / NDJSON | ✅ | ✅ | ✅ | +| MTR 自定义列(`--mtr-columns`) | ✅ | ✅ | ✅ | +| MTR 录制 / 回放(`--mtr-record` / `--mtr-replay`) | ✅ | ✅ | ✅ | +| Linux 策略路由(`--fwmark`,仅本地探测) | ✅ | ✅ | ✅ | | Globalping(`--from`) | ✅ | — | — | | WebUI(`--deploy`)/ MCP(`--deploy --mcp`) | ✅ | — | — | | 快速跟踪(`-F`) | ✅ | ✅ | — | @@ -214,7 +218,7 @@ ntr --doctor --dev eth0 example.com `--doctor` 输出纯文本诊断报告后退出,分别列出请求配置、目标解析与源地址选择、系统路由预测及实际后端初始化结果。自检不发送探测包、不读取捕获流量、不访问 GeoIP/API 服务,也不验证目标可达性;DNS/DoT 解析可能访问网络。 -三个版本均支持。可用参数限于 `--ipv4`/`--ipv6`、`--tcp`/`--udp`、`--port`、`--source`、`--source-port`、`--dev`、`--tos`、`--dot-server`、`--timeout`、`--language`、`--no-color`、Windows 的 `--icmp-mode` 及对应短参数,详见 `--doctor --help`。目标仅接受域名或 IP,不接受 URL 和带区域后缀的 IPv6 地址。其他运行模式、JSON/RAW/文件输出及无关探测参数不能与自检组合。 +三个版本均支持。可用参数限于 `--ipv4`/`--ipv6`、`--tcp`/`--udp`、`--port`、`--source`、`--source-port`、`--dev`、`--tos`、`--dot-server`、`--timeout`、`--language`、`--no-color`、Windows 的 `--icmp-mode` 及对应短参数,详见 `--doctor --help`。目标仅接受域名或 IP,不接受 URL 和带区域后缀的 IPv6 地址。其他运行模式、JSON/RAW/文件输出及无关探测参数不能与自检组合。`--fwmark` 在自检中不受支持,不能用 Doctor 验证带标记的选路或 `SO_MARK` 权限;Doctor 的 `--source-port` 仅接受 `0..65535`,不接受探测模式的随机值 `-1`。 默认使用 ICMP、中文文本,每项网络检查超时为 5000ms。多个解析候选全部列出,自动选择首个符合地址族的地址,不进行交互选择。目标 DoT 失败不回退系统 DNS。单项失败后继续独立检查;报告写入 stdout,参数与报告写入错误写入 stderr。报告包含目标、源地址和接口信息,不包含 token 或代理凭据。 @@ -464,7 +468,7 @@ nexttrace --udp 1.0.0.1 # 可以自行指定目标端口[此处为5353],默认33494端口 nexttrace --udp --port 5353 1.0.0.1 -# TCP/UDP Trace 可以自行指定源端口,默认使用随机一个固定的端口(如需每次发包随机使用不同的源端口,请设置`ENV` `NEXTTRACE_RANDOMPORT`) +# TCP/UDP Trace 可以自行指定源端口,默认使用随机一个固定的端口;`--source-port -1` 或环境变量 `NEXTTRACE_RANDOMPORT` 启用逐包随机源端口,适用于传统 traceroute 及 MTR 文本、JSON、录制 nexttrace --tcp --source-port 14514 www.bing.com ``` @@ -712,7 +716,7 @@ ntr --mtr-columns received 1.1.1.1 - **`p`** — 暂停探测 - **空格** — 恢复探测 - **`r`** — 重置统计(计数器清零,显示模式保持不变) -- **`y`** — 循环切换主机显示模式:ASN → City → Owner → Full +- **`y`** — 循环切换主机显示模式:IP/PTR → ASN → City → Owner → Full - **`n`** — 切换主机名显示方式: - 默认:PTR(无 PTR 时回退 IP)↔ 仅 IP - 启用 `--show-ips`:PTR (IP) ↔ 仅 IP @@ -850,6 +854,8 @@ export GLOBALPING_TOKEN=your_token_here ### 环境变量总览 +启用 `NEXTTRACE_DEBUG` 时,已知 token、IPDB 凭据及代理 URL 的环境变量读取日志只显示变量名和存在状态,不输出其值。其他诊断仍可能包含目标、源地址和接口信息。 + NextTrace 当前会读取下列环境变量。对于 `NEXTTRACE_*` 布尔开关,只识别 `1` 和 `0`,其他值会回退到内置默认值。为了避免混淆,修改后建议重启 NextTrace。 #### 核心运行 / 网络 diff --git a/docs/mtr-json.md b/docs/mtr-json.md index 93bb833..679dd2d 100644 --- a/docs/mtr-json.md +++ b/docs/mtr-json.md @@ -44,7 +44,10 @@ output, with no retry of the final event/report. Each RAW callback maps to one `probe` in the same order. `iteration` keeps its RAW meaning and is not a unique event identifier. A probe precedes the path -change it triggers; final max-hops conclusions precede `end`. There are no separate Geo/PTR +change it triggers; final max-hops conclusions precede `end`. When recording +failure prevents a RAW probe callback, its pending destination/unreachable or +reopening change is discarded from stdout and the final stream path state. A +max-hops conclusion can still be emitted after the last callback. There are no separate Geo/PTR update events, no retained event history, and no final stream statistics. Example finite stream with metadata queries disabled (version/times illustrative): @@ -96,7 +99,7 @@ do not synthesize timeout events for in-flight probes. RTT units are millisecond | `max_per_hop`, `hop_interval_ms`, `timeout_ms` | Normalized count (0 unlimited), interval and timeout | | `begin_hop`, `max_hops`, `parallel_requests` | TTL range and concurrency | | `source_address`, optional `source_device` | Selected source address and applicable device binding | -| `source_port`, `port` | TCP/UDP only; source 0 means automatic selection | +| `source_port`, `port` | TCP/UDP only; source `0` selects one automatic port, `-1` selects a random port per probe, `1..65535` selects a fixed port; destination `1..65535` | | `packet_size`, `random_packet_size` | Total IP+protocol+payload size; negative size means randomized up to its absolute value | | `tos`, optional `icmp_mode` | Traffic class; ICMP listener setting where supported | | `data_provider`, `language`, optional `dot_server` | Effective metadata provider, language and DNS override | @@ -126,6 +129,10 @@ Session errors preserve partial statistics and have `error.stage` and `stage: "initialize"`; other runner failures use `stage: "probe"`. Signals use `signal: "SIGINT"` or `"SIGTERM"`. Internal cancellation retains its error cause and is not reported as user interruption. +Recording failures use `record` when no earlier session error exists. A later +recording start, sync or close failure does not replace the original error or +its stage. A recording failure may leave only a recoverable file prefix; a +writable stdout still follows the JSON error lifecycle. Syntax and conflicting-mode errors occur before a session: stdout is empty, stderr carries the diagnostic, and exit code is 2. Help/version retain their existing output behavior. All session diagnostics go to stderr. @@ -133,3 +140,17 @@ existing output behavior. All session diagnostics go to stderr. ### Linux socket mark For supported Linux traceroute/MTR CLI sessions, an explicit `--fwmark` is recorded in MTR `effective_parameters.fwmark` as an optional uint32 JSON number. Decimal and hexadecimal CLI spellings produce the same value. Explicit zero is included; omission leaves the field absent. Schema version remains 1. This records the requested socket setting, not proof of the observed egress route. Mark/source initialization errors use the existing `initialize` error stage and nonzero exit status; no human-readable lines are inserted into JSON or NDJSON. + +## Combined examples + +```sh +# Random TCP source ports, finite NDJSON and an independent replay file +nexttrace --mtr --json --tcp --source-port -1 -q 10 --mtr-record tcp-session.jsonl example.com +# Linux: marked wide JSON report with DSCP 46 / ECN 0 +nexttrace -w --json --fwmark 0x100 --tos 184 -q 10 example.com +``` + +The TCP/UDP source-port value is preserved in effective parameters; it is not a +list of the randomly selected ports. `--mtr-columns` is rejected with JSON, +including offline JSON replay. CLI JSON, session recordings, offline replay +JSON and MCP structured output are distinct contracts. diff --git a/docs/mtr-session.md b/docs/mtr-session.md index c4faa41..01e43b3 100644 --- a/docs/mtr-session.md +++ b/docs/mtr-session.md @@ -22,7 +22,10 @@ Opening the recording precedes network initialization and probing. Each accepted event is written as a complete UTF-8 JSON line. A failed encode or write cancels probing. The file is synchronized and closed at the end, and -sync/close errors are reported as failures. No events are silently dropped. +sync/close errors are reported as failures. The first session error and its +stage take precedence over later recording start or finish errors. When file +writes already failed, no complete error end record is guaranteed. No events +are silently dropped. There is no rotation, compression, append mode, or periodic durable checkpoint. Crash recovery is limited to complete records that remain readable from disk. @@ -107,7 +110,26 @@ nexttrace --mtr-replay session.jsonl -r --json `--mtr-replay --help` and `--mtr-replay --version` need no file. For a file named `--help` or `--version`, use `--mtr-replay=--help` or a path such as `./--help`. -Replay accepts presentation options, not a target or probe configuration. It +Replay accepts presentation options, not a target or probe configuration. + +| Option | Behavior | +| --- | --- | +| `-r`, `--report` | Print the final compact text report | +| `-w`, `--wide` | Print the final text report without host truncation | +| `-j`, `--json` | Print the offline JSON document, taking precedence over report/wide | +| `--mtr-columns` | Select text columns; incompatible with JSON | +| `-y`, `--ipinfo` | Initial TUI host mode `0..4` | +| `--show-ips` | Display PTR and IP together | +| `-g`, `--language` | Display `cn` or `en` using recorded metadata | +| `-C`, `--no-color` | Disable TUI colors; text reports already have no ANSI | + +Omitted host mode, PTR/IP display, columns and language inherit the recording's +initial settings; MPLS display also starts from the recorded setting. Live column +edits are session-local and are not recorded as replay control events. Explicit +`-r` chooses compact output; without `-r/-w`, non-TTY output inherits the +recorded wide setting. Both source and responder host names are truncated in +compact output. No target, `--raw`, probe options, `--mtr-record`, stdin (`-`), +pipe or non-regular input file is accepted. It does not initialize probing, resolve addresses, query metadata, or discover a source interface. Recorded missing metadata stays missing. It can run without raw-socket privileges and without network connectivity. @@ -135,6 +157,26 @@ Non-TTY or explicit `-r/-w` produces one final report. `--json` produces a separate offline document with session information, statistics, path state, playback position and recording completeness, rather than emitting live NDJSON. +### Offline JSON fields + +The output is one object plus a newline, with `schema_version: 1` and +`type: "mtr_replay"`. It contains: + +| Field | Meaning | +| --- | --- | +| `session` | Original session header and initial display/effective parameters | +| `complete` | Whether a valid end record was read | +| `cursor_ns`, `duration_ns` | Final valid playback position and duration, in nanoseconds | +| `generation`, `recorded_paused` | Final reducer generation and recorded probe-pause state | +| `path_end` | Reconstructed conclusion, or `null` | +| `stats` | Final MTR statistics; always an array, including `[]` | +| `end` | Original end payload, omitted when absent | + +Replay text/TUI and diagnostics replace Unicode control (`Cc`) and format +(`Cf`, including bidi overrides and isolates) characters with spaces. Only +display copies are sanitized; recorded data and offline JSON retain original +values. JSON consumers must apply their own display escaping. + ## Incomplete and invalid files A missing end record or an unfinished final JSON line recovers only the complete diff --git a/skills/nexttrace/references/capability-matrix.md b/skills/nexttrace/references/capability-matrix.md index eac8e66..82bb3fb 100644 --- a/skills/nexttrace/references/capability-matrix.md +++ b/skills/nexttrace/references/capability-matrix.md @@ -38,3 +38,7 @@ Current important gaps: - No Globalping location search/list MCP tool. - MCP transport is HTTP deploy mode only, not stdio. +- Doctor, Linux `--fwmark`, CLI MTR JSON/NDJSON, recording/replay and interactive + column editing have no equivalent MCP input/tool in this release. Use the + [CLI workflow](cli-fallback.md) for an explicitly requested capability; MCP + report/raw structured content is not a CLI replay file. diff --git a/skills/nexttrace/references/cli-fallback.md b/skills/nexttrace/references/cli-fallback.md index ac8c904..b44415c 100644 --- a/skills/nexttrace/references/cli-fallback.md +++ b/skills/nexttrace/references/cli-fallback.md @@ -28,6 +28,44 @@ nexttrace --mtr --raw -q 5 example.com When `-q` is omitted, `--mtr --raw` runs continuously, while `--report/--wide` (including with `--raw`) defaults to 10 probes per hop. Set an explicit `-q` for bounded automation. MTR raw stdout remains a fixed 12-column stream. Semantic unreachable diagnostics are written to stderr so stdout parsers remain compatible. In unbounded MTR, an unreachable edge is provisional and later transit evidence can reopen the path; use the final `path_end` from bounded structured output as the authoritative boundary. +### JSON, recording and replay + +```sh +nexttrace --mtr --json -q 10 example.com +nexttrace -r --json -q 10 example.com +nexttrace --mtr --tcp --source-port -1 --mtr-record session.jsonl -q 10 example.com +nexttrace --mtr-replay session.jsonl --json +nexttrace -r --mtr-columns loss,received,avg example.com +``` + +All three builds support these CLI capabilities; full/tiny require explicit MTR +for live runs, while `ntr --json` defaults to streaming MTR. JSON streams and +reports have different count/error contracts. Do not use live NDJSON as a replay +file: only `--mtr-record` creates that format. Replay accepts presentation flags +only and never probes or queries metadata; it can run without network access or +probe privileges. Incomplete files return nonzero with the valid prefix marked +incomplete. Text columns do not change RAW/JSON schemas and cannot accompany +those output modes. See [JSON](../../../docs/mtr-json.md) and +[recording/replay](../../../docs/mtr-session.md) for schemas and lifecycle rules. + +### Environment check and Linux marks + +```sh +nexttrace --doctor --tcp --port 443 --language en example.com +nexttrace -r --json --fwmark 0x100 -q 10 example.com +``` + +Doctor is plain text and performs local setup checks only; DNS/DoT may access +the network. It does not send probes or verify delivery. Exit codes are 0 for +required checks passed, 1 for failure, 2 for invalid arguments, 3 for unconfirmed +required checks, and 130/143 for handled signals. On Windows, WinDivert checks +use NO_INSTALL. Doctor rejects `--fwmark` and random source port `-1`. + +`--fwmark` is Linux-only local traceroute/MTR CLI input, not an MCP parameter. +Do not silently drop it or send an unmarked MCP request. It supports decimal or +hex uint32 values, including explicit zero; source/device constraints remain in +force. Mark setup errors stop probing. It does not mark DNS/Geo/API traffic. + ## MTU `--mtu` is available in the `nexttrace` and `nexttrace-tiny` flavors. It is not supported by `ntr`. diff --git a/skills/nexttrace/references/platform-notes.md b/skills/nexttrace/references/platform-notes.md index 2a580fe..65531c5 100644 --- a/skills/nexttrace/references/platform-notes.md +++ b/skills/nexttrace/references/platform-notes.md @@ -23,6 +23,16 @@ Do not pass `tos` to: If TOS fails because of platform privileges or socket support, report that limitation. Do not remove `tos` or switch tools unless the user asks for a fallback. +## Linux socket marks + +`--fwmark` accepts `0..4294967295` in decimal or hexadecimal for local CLI +traceroute/MTR only. Omission and explicit zero differ: zero still sets SO_MARK +and requires permission. Matching system policy rules must already exist. +Linux requires CAP_NET_ADMIN, or CAP_NET_RAW on Linux 5.17+. Automatic source +selection uses the marked route; explicit source/device constraints are kept. +Doctor, MTU, DNS, speed, deploy/MCP, Globalping, Fast Trace and file targets +reject the option. See the [CLI workflow](cli-fallback.md). + ## Packet Size `packet_size` is local traceroute/MTR input. It means total bytes including IP and active probe protocol headers. diff --git a/skills/nexttrace/references/validation.md b/skills/nexttrace/references/validation.md index 86870cd..83fc22d 100644 --- a/skills/nexttrace/references/validation.md +++ b/skills/nexttrace/references/validation.md @@ -53,3 +53,23 @@ go build ./... go test ./... node --test server/web/assets/*.test.cjs ``` + + +## CLI feature regression coverage + +| Feature | Local checks | Native CI evidence | +| --- | --- | --- | +| MTR JSON ordering, error stages and ports | `go test ./cmd` | Test full/tiny/ntr; Runtime Regression CI checks finite streams and reports | +| Recording, reducer validation and recovery | `go test ./internal/mtrsession ./trace ./cmd` | Test workflow; recorded sessions and offline replay on PTY/Windows ConPTY | +| Replay sanitation, seek and text columns | `go test ./cmd ./printer` | `scripts/test_mtr_session_pty.py` and `scripts/test_mtr_columns_pty.py` | +| Doctor route/backend checks | `go test ./internal/doctor ./trace/internal ./cmd` | Test workflow loopback route and privileged backend smoke; NO_INSTALL Windows checks | +| Linux fwmark and source constraints | `go test ./internal/routeprobe ./trace ./trace/internal ./cmd` | Linux fwmark workflow: native marks, permission failures, dual-stack dual-egress captures | +| TOS, zero restoration and engine replacement | `go test ./trace ./trace/internal` | TOS packet acceptance: Linux/macOS/Windows amd64 full-byte dual-stack captures | +| Linux legacy socketcall pointer lifetime | Cross-compile and vet `internal/routeprobe` for 386/s390x | Linux fwmark workflow executes route tests on amd64 and 386; s390x compile only | + +Privilege-gated tests skip in ordinary `go test` runs. Cross-compilation, +simulated callbacks and successful socket initialization do not prove packet +contents or remote reachability. Inspect the matching commit's workflow logs and +artifacts for native acceptance; do not report a skipped test as passed coverage. +Unix MTR JSON regression failures retain the full Python traceback in +`.json.assert`, with a short failure detail in the summary. diff --git a/trace/internal/icmp_windows.go b/trace/internal/icmp_windows.go index 810ac60..d326d33 100644 --- a/trace/internal/icmp_windows.go +++ b/trace/internal/icmp_windows.go @@ -287,6 +287,8 @@ func (s *ICMPSpec) ensureICMPSendHandle(ipv6 bool) error { return s.ensureICMPSendHandleWithFlags(ipv6, 0) } +// ensureICMPSendHandleWithFlags applies extraFlags only when opening a handle. +// Callers requiring those flags (doctor NO_INSTALL) must use a fresh spec. func (s *ICMPSpec) ensureICMPSendHandleWithFlags(ipv6 bool, extraFlags uint64) error { if s.sendHandle != 0 { return nil