mirror of
https://github.com/nxtrace/NTrace-core.git
synced 2026-12-03 01:34:44 +00:00
feat(cli): 添加显式传统模式并开放 tiny MTR
This commit is contained in:
1 parent
92e0d4be07
commit
ef143a73d6
18 files changed
+633
-172
No files matched your search
@@ -38,6 +38,12 @@
|
||||
|
||||
### 常规 traceroute 路径
|
||||
|
||||
- `-k/--traceroute`:完整版和 tiny 显式选择传统模式;配合 `--raw` 保留传统 RAW。与显式 MTR/report/wide 及独立 DNS/MTU/speed/nali/deploy 模式冲突。
|
||||
- 完整版和 tiny 当前仍默认传统 traceroute,已公告最早于 2027 年切换默认模式与单独 RAW 到 MTR;具体版本另行公告,不按日期自动切换。
|
||||
- tiny 已开放可选 MTR TUI/report/wide/RAW;ntr 仍是 MTR 专用版,不注册 `--traceroute`。
|
||||
- `enableTraceroute` 控制传统参数能力,`defaultMTR` 只控制未明确选择模式时的默认值;不可再用默认模式决定传统参数是否注册。
|
||||
- `cmd/trace_mode.go` 集中解析模式;未来默认 MTR 时,传统专用格式和 Fast Trace/文件目标/Globalping 保持传统路径,独立模式中的共享格式参数由各自入口解释。
|
||||
|
||||
- `--table`:现在是"最终汇总表"模式(一次探测完成后输出汇总表),不再是旧的异步 table 刷新模式。
|
||||
- `--route-path`:仍由 `reporter.New(...).Print()` 负责(与 MTR report 无关)。
|
||||
|
||||
|
||||
@@ -26,6 +26,10 @@
|
||||
</a>
|
||||
</p>
|
||||
|
||||
## Default-mode migration: no earlier than 2027
|
||||
|
||||
> **Downstream developers:** NextTrace will switch the default operating and display mode of `nexttrace` and `nexttrace-tiny` to MTR **no earlier than 2027**. Using `--raw` alone will switch to MTR RAW at the same time. Traditional traceroute and its RAW output will remain available through `-k/--traceroute`. Programs relying on today's behavior should adopt `--traceroute` or `--traceroute --raw` now. **This release does not change the default; the switching release will be announced separately.** `ntr` remains MTR-only.
|
||||
|
||||
## IAAS Sponsor
|
||||
|
||||
<div style="text-align: center;">
|
||||
@@ -185,10 +189,10 @@ Starting from this release, NextTrace is published in **three flavors** under th
|
||||
| DNS client (`-l` / `--dns`) | ✅ | — | — |
|
||||
| CDN Speed (`--speed`) | ✅ | — | — |
|
||||
| IP annotation (`--nali`) | ✅ | — | — |
|
||||
| MTR TUI | ✅ | — | ✅ (default) |
|
||||
| MTR report (`-r`) | ✅ | — | ✅ |
|
||||
| MTR wide (`-w`) | ✅ | — | ✅ |
|
||||
| MTR raw (`--raw`) | ✅ | — | ✅ |
|
||||
| MTR TUI | ✅ | ✅ | ✅ (default) |
|
||||
| MTR report (`-r`) | ✅ | ✅ | ✅ |
|
||||
| MTR wide (`-w`) | ✅ | ✅ | ✅ |
|
||||
| MTR raw (`--raw`) | ✅ | ✅ | ✅ |
|
||||
| Globalping (`--from`) | ✅ | — | — |
|
||||
| WebUI (`--deploy`) / MCP (`--deploy --mcp`) | ✅ | — | — |
|
||||
| Fast Trace (`-F`) | ✅ | ✅ | — |
|
||||
@@ -200,7 +204,7 @@ Starting from this release, NextTrace is published in **three flavors** under th
|
||||
### Feature Matrix
|
||||
|
||||
- **`nexttrace`** — Full-featured build. Includes traceroute, the standalone DNS client and MTU modes, CDN speed test, IP annotation, MTR, Globalping, Fast Trace, WebUI, and deploy MCP.
|
||||
- **`nexttrace-tiny`** — Lightweight build. Keeps normal traceroute, standalone MTU, and Fast Trace. No DNS client / CDN speed test / IP annotation / MTR / Globalping / WebUI / MCP. Suitable for embedded or minimal environments.
|
||||
- **`nexttrace-tiny`** — Lightweight build. Keeps normal traceroute, standalone MTU, and Fast Trace. Includes optional MTR TUI, reports, and RAW. No DNS client / CDN speed test / IP annotation / Globalping / WebUI / MCP. Suitable for embedded or minimal environments.
|
||||
- **`ntr`** — MTR-focused build. Runs MTR TUI by default. No normal traceroute mode, standalone DNS client or `--mtu`, CDN speed test, IP annotation, Globalping, Fast Trace, WebUI, or MCP.
|
||||
|
||||
### Manual Build
|
||||
@@ -217,7 +221,7 @@ export GOEXPERIMENT=nojsonv2
|
||||
# Full (all features)
|
||||
go build -trimpath -o dist/nexttrace -ldflags "-w -s" .
|
||||
|
||||
# Tiny (no DNS client, no MTR, no Globalping, no WebUI)
|
||||
# Tiny (optional MTR; no DNS client, no Globalping, no WebUI)
|
||||
go build -tags flavor_tiny -trimpath -o dist/nexttrace-tiny -ldflags "-w -s" .
|
||||
|
||||
# NTR (MTR-only)
|
||||
@@ -276,7 +280,7 @@ nexttrace http://example.com:8080/index.html?q=1
|
||||
nexttrace --table 1.0.0.1
|
||||
|
||||
# Machine-readable output: stdout is a single JSON document
|
||||
nexttrace --raw 1.0.0.1
|
||||
nexttrace --traceroute --raw 1.0.0.1
|
||||
nexttrace --json 1.0.0.1
|
||||
|
||||
# Realtime trace output to a custom file
|
||||
@@ -311,6 +315,45 @@ Normal traceroute reports why it stopped: destination reached, a terminal unreac
|
||||
|
||||
When multiple normal-trace output modes are selected, precedence is `--json` > `--table` > `--classic` > `--raw` > `--output` > realtime output. If a higher-priority mode overrides an explicit `--output` or `--output-default`, NextTrace reports that choice on stderr and does not create the ignored log file.
|
||||
|
||||
#### Downstream migration and explicit traditional mode
|
||||
|
||||
`-k/--traceroute` selects traditional traceroute in full and tiny builds; it is not an alias for the `--classic` layout. It supports existing traditional output formats, Fast Trace, file targets, and Globalping. Combining it with `--mtr/-t`, `--report/-r`, `--wide/-w`, or standalone DNS, MTU, speed, IP annotation, or deploy mode is an error.
|
||||
|
||||
```bash
|
||||
nexttrace --traceroute example.com
|
||||
nexttrace -k example.com
|
||||
nexttrace --traceroute --raw example.com
|
||||
nexttrace --mtr --raw -q 10 example.com
|
||||
```
|
||||
|
||||
| Invocation | Today | After the default switch |
|
||||
|---|---|---|
|
||||
| Target only | Traditional traceroute | MTR |
|
||||
| `--raw` | Traditional RAW | MTR RAW |
|
||||
| `--traceroute` | Traditional traceroute | Traditional traceroute |
|
||||
| `--traceroute --raw` | Traditional RAW | Traditional RAW |
|
||||
| `--json/--table/--classic/--output/--output-default/--route-path` | Traditional mode | Selects traditional mode automatically |
|
||||
|
||||
Standalone entry points, Fast Trace, file targets, and Globalping keep their workflows; `--json` in a standalone mode still belongs to that mode. Explicit MTR continues to reject traditional-only output formats.
|
||||
|
||||
MTR TUI/RAW runs continuously when `-q` is omitted; reports default to 10 probes per hop. Automation should set an explicit `-q`. In MTR, `-i` is the per-hop interval (default 1000ms) and `-z` is ignored. In traditional traceroute, `-q` defaults to 3 samples per hop, `-i` is the TTL-group interval (default 300ms), and `-z` is the packet interval (default 50ms).
|
||||
|
||||
Do not distinguish the RAW modes by successful rows alone: traditional RAW uses 12 columns for success and preserves historical 8-column timeout rows; MTR RAW uses fixed 12-column data rows in a continuous event stream. Parsers must also honor each mode's existing information headers and stderr behavior. `NEXTTRACE_UNINTERRUPTED` retains its traditional loop behavior with `--traceroute --raw`.
|
||||
|
||||
Bash wrappers supporting older releases can detect the capability before invoking a trace:
|
||||
|
||||
```bash
|
||||
trace_mode=()
|
||||
nexttrace_help=$(nexttrace --help)
|
||||
if [[ "$nexttrace_help" == *"--traceroute"* ]]; then
|
||||
trace_mode=(--traceroute)
|
||||
fi
|
||||
nexttrace "${trace_mode[@]}" --raw example.com
|
||||
```
|
||||
|
||||
Omit the new flag on older releases. Do not retry a failed trace without the flag: that could run the measurement twice.
|
||||
|
||||
|
||||
PS: The route visualization module is an independent component, You can find its source code at [nxtrace/traceMap](https://github.com/nxtrace/traceMap).
|
||||
The routing visualization function requires the geographical coordinates of each hop. It is currently available with NextTrace API, IPInfo, and IP-API.com.
|
||||
|
||||
@@ -656,7 +699,7 @@ In MTR mode (`--mtr`, `-r`, `-w`, including `--raw`), `-i/--ttl-time` sets the *
|
||||
|
||||
> Note: `--show-ips` only takes effect in MTR mode (`--mtr`, `-r`, `-w`); otherwise it is ignored.
|
||||
>
|
||||
> Note: `--mtr` cannot be used together with `--table`, `--classic`, `--json`, `--output`, `--output-default`, `--route-path`, `--from`, `--fast-trace`, `--file`, or `--deploy`.
|
||||
> Note: `--mtr` cannot be used together with `--traceroute`, `--table`, `--classic`, `--json`, `--output`, `--output-default`, `--route-path`, `--from`, `--fast-trace`, `--file`, or `--deploy`.
|
||||
|
||||
#### `NextTrace` supports users to select their own IP API (currently supports: `NextTrace-API`, `IP.SB`, `IPInfo`, `IPInsight`, `IPAPI.com`, `IPInfoLocal`, `IPDB.One`, `CHUNZHEN`, `DN42`)
|
||||
|
||||
@@ -806,51 +849,46 @@ These q-compatible variables apply only to the standalone DNS client mode.
|
||||
|
||||
### For full usage list, please refer to the usage menu
|
||||
|
||||
The following is full-build help on macOS; Windows also provides `--init` and `--icmp-mode`.
|
||||
|
||||
```shell
|
||||
Usage: nexttrace [-h|--help] [--init] [-4|--ipv4] [-6|--ipv6] [-T|--tcp]
|
||||
[-U|--udp] [-l|--dns] [--speed] [--nali] [-F|--fast-trace]
|
||||
[-p|--port <integer>] [--icmp-mode <integer>] [-q|--queries <integer>]
|
||||
[--max-attempts <integer>] [--parallel-requests <integer>]
|
||||
[-m|--max-hops <integer>] [-d|--data-provider
|
||||
usage: nexttrace [-h|--help] [-4|--ipv4] [-6|--ipv6] [-T|--tcp] [-U|--udp]
|
||||
[--mtu] [-F|--fast-trace] [-p|--port <integer>] [-q|--queries
|
||||
<integer>] [--max-attempts <integer>] [--parallel-requests
|
||||
<integer>] [-m|--max-hops <integer>] [-d|--data-provider
|
||||
(IP.SB|ip.sb|IPInfo|ipinfo|IPInsight|ipinsight|IPAPI.com|ip-api.com|IPInfoLocal|ipinfolocal|chunzhen|NextTrace-API|ipdb.one|disable-geoip|DN42|dn42)]
|
||||
[--pow-provider (api.nxtrace.org|sakura)] [-n|--no-rdns]
|
||||
[-a|--always-rdns] [-P|--route-path] [--dn42] [-o|--output
|
||||
"<value>"] [-O|--output-default] [--table] [--raw]
|
||||
[-j|--json] [-c|--classic] [-f|--first <integer>] [-M|--map]
|
||||
[-e|--disable-mpls] [-V|--version] [-x|--setup-api-v4-token]
|
||||
[-a|--always-rdns] [-k|--traceroute] [-P|--route-path]
|
||||
[-o|--output "<value>"] [-O|--output-default] [--table]
|
||||
[-j|--json] [-c|--classic] [--dn42] [--raw] [-f|--first
|
||||
<integer>] [-M|--map] [-e|--disable-mpls] [-V|--version]
|
||||
[-x|--setup-api-v4-token] [-l|--dns] [--speed] [--nali]
|
||||
[-s|--source "<value>"] [--source-port <integer>] [-D|--dev
|
||||
"<value>"] [--listen "<value>"] [--deploy-token "<value>"]
|
||||
[--mcp] [--deploy] [-z|--send-time <integer>]
|
||||
[-i|--ttl-time <integer>] [--timeout <integer>]
|
||||
[--psize <integer>] [--dot-server
|
||||
[--mcp] [--deploy] [-z|--send-time <integer>] [-i|--ttl-time
|
||||
<integer>] [--timeout <integer>] [--psize <integer>] [-Q|--tos
|
||||
<integer>] [--dot-server
|
||||
(dnssb|aliyun|dnspod|google|cloudflare)] [-g|--language
|
||||
(en|cn)] [-C|--no-color] [--from "<value>"] [-t|--mtr]
|
||||
[-r|--report] [-w|--wide] [--show-ips] [-y|--ipinfo <integer>]
|
||||
[--file "<value>"] [TARGET "<value>"]
|
||||
|
||||
An open source visual route tracking CLI tool
|
||||
|
||||
Arguments:
|
||||
|
||||
-h --help Print help information
|
||||
--init Windows ONLY: Extract WinDivert runtime to
|
||||
executable directory
|
||||
-l --dns Run DNS client mode. See `nexttrace --dns
|
||||
--help` for details
|
||||
--speed Run CDN speed test mode. See `nexttrace
|
||||
--speed --help` for details
|
||||
--nali Annotate IP literals in text using
|
||||
NextTrace GeoIP data
|
||||
-4 --ipv4 Use IPv4 only
|
||||
-6 --ipv6 Use IPv6 only
|
||||
-T --tcp Use TCP SYN for tracerouting (default
|
||||
dest-port is 80)
|
||||
-U --udp Use UDP SYN for tracerouting (default
|
||||
dest-port is 33494)
|
||||
--mtu Run standalone UDP path-MTU discovery mode
|
||||
with streaming output and GeoIP/RDNS
|
||||
-F --fast-trace One-Key Fast Trace to China ISPs
|
||||
-p --port Set the destination port to use. With
|
||||
default of 80 for "tcp", 33494 for "udp"
|
||||
--icmp-mode Windows ONLY: Choose the method to listen
|
||||
for ICMP packets (1=Socket, 2=WinDivert;
|
||||
0=Auto)
|
||||
-q --queries Latency samples per hop. Increase to 5-10
|
||||
on unstable paths for a steadier view.
|
||||
Default: 3
|
||||
@@ -877,28 +915,38 @@ Arguments:
|
||||
domain names
|
||||
-a --always-rdns Always resolve IP addresses to their
|
||||
domain names
|
||||
-k --traceroute Use traditional traceroute mode; with
|
||||
--raw, preserve traditional raw output
|
||||
-P --route-path Print traceroute hop path by ASN and
|
||||
location
|
||||
--dn42 DN42 Mode
|
||||
-o --output Write trace result to FILE
|
||||
(RealtimePrinter only)
|
||||
-O --output-default Write trace result to the default log file
|
||||
-o --output Write realtime trace output and final stop
|
||||
reason to FILE
|
||||
-O --output-default Write realtime trace output and final stop
|
||||
reason to the default log file
|
||||
(/tmp/trace.log)
|
||||
--table Output trace results as a final summary
|
||||
table (traceroute report mode)
|
||||
--raw Machine-friendly output. With MTR
|
||||
(--mtr/-r/-w), enables streaming raw event
|
||||
mode
|
||||
-j --json Output trace results as JSON
|
||||
-c --classic Classic Output trace results like
|
||||
BestTrace
|
||||
--dn42 DN42 Mode
|
||||
--raw Machine-friendly output; use --traceroute
|
||||
--raw to preserve traditional raw output.
|
||||
With MTR (--mtr/-r/-w), enables streaming
|
||||
raw event mode
|
||||
-f --first Start from the first_ttl hop (instead of
|
||||
1). Default: 1
|
||||
-M --map Disable Print Trace Map
|
||||
-e --disable-mpls Disable MPLS
|
||||
-V --version Print version info and exit
|
||||
-x --setup-api-v4-token Store a session-only NextTrace API v4
|
||||
token in a temporary file and exit
|
||||
token in a temporary file
|
||||
-l --dns Run DNS client mode. See `nexttrace --dns
|
||||
--help` for details
|
||||
--speed Run CDN speed test mode. See `nexttrace
|
||||
--speed --help` for details
|
||||
--nali Annotate IP literals in text using
|
||||
NextTrace GeoIP data
|
||||
-s --source Use source address src_addr for outgoing
|
||||
packets
|
||||
--source-port Use source port src_port for outgoing
|
||||
@@ -912,8 +960,7 @@ Arguments:
|
||||
127.0.0.1:30080)
|
||||
--deploy-token Set bearer token for --deploy
|
||||
WebUI/API/WebSocket/MCP access
|
||||
--mcp Enable MCP endpoint under --deploy at
|
||||
/mcp
|
||||
--mcp Enable MCP endpoint under --deploy at /mcp
|
||||
--deploy Start the Gin powered web console
|
||||
-z --send-time Advanced: per-packet gap [ms] inside the
|
||||
same TTL group. Lower is faster; raise to
|
||||
@@ -929,10 +976,10 @@ Arguments:
|
||||
paths. Default: 1000
|
||||
--psize Probe packet size in bytes, inclusive IP
|
||||
and active probe headers. Default is the
|
||||
minimum legal size for the chosen
|
||||
protocol and IP family; raise for MTU or
|
||||
minimum legal size for the chosen protocol
|
||||
and IP family; raise for MTU or
|
||||
large-packet testing. Negative values
|
||||
randomize each probe up to abs(value).
|
||||
randomize each probe up to abs(value)
|
||||
-Q --tos Set the IP type-of-service / traffic class
|
||||
value [0-255]. Default: 0
|
||||
--dot-server Use DoT Server for DNS Parse [dnssb,
|
||||
|
||||
+91
-44
@@ -26,6 +26,10 @@
|
||||
</a>
|
||||
</p>
|
||||
|
||||
## 默认模式迁移公告:最早于 2027 年
|
||||
|
||||
> **下游开发者请注意:** NextTrace 将最早于 2027 年将 `nexttrace` 和 `nexttrace-tiny` 的默认运行与显示模式切换为 MTR,单独使用 `--raw` 时也将切换为 MTR RAW。传统 traceroute 及其 RAW 输出将继续通过 `-k/--traceroute` 提供。依赖当前行为的程序应提前使用 `--traceroute` 或 `--traceroute --raw`。**本次版本尚未切换默认模式,具体切换版本将另行公告。** `ntr` 继续作为 MTR 专用版。
|
||||
|
||||
## IAAS Sponsor
|
||||
|
||||
<div style="text-align: center;">
|
||||
@@ -186,10 +190,10 @@ Document Language: [English](README.md) | 简体中文
|
||||
| DNS 客户端(`-l` / `--dns`) | ✅ | — | — |
|
||||
| CDN 测速(`--speed`) | ✅ | — | — |
|
||||
| IP 文本标注(`--nali`) | ✅ | — | — |
|
||||
| MTR TUI | ✅ | — | ✅(默认) |
|
||||
| MTR 报告(`-r`) | ✅ | — | ✅ |
|
||||
| MTR 宽报告(`-w`) | ✅ | — | ✅ |
|
||||
| MTR 原始输出(`--raw`) | ✅ | — | ✅ |
|
||||
| MTR TUI | ✅ | ✅ | ✅(默认) |
|
||||
| MTR 报告(`-r`) | ✅ | ✅ | ✅ |
|
||||
| MTR 宽报告(`-w`) | ✅ | ✅ | ✅ |
|
||||
| MTR 原始输出(`--raw`) | ✅ | ✅ | ✅ |
|
||||
| Globalping(`--from`) | ✅ | — | — |
|
||||
| WebUI(`--deploy`)/ MCP(`--deploy --mcp`) | ✅ | — | — |
|
||||
| 快速跟踪(`-F`) | ✅ | ✅ | — |
|
||||
@@ -201,7 +205,7 @@ Document Language: [English](README.md) | 简体中文
|
||||
### 功能对比
|
||||
|
||||
- **`nexttrace`** — 完整版。包含 traceroute、独立 DNS 客户端与 MTU 模式、CDN 测速、IP 文本标注、MTR、Globalping、Fast Trace、WebUI(`--deploy`)与 MCP(`--deploy --mcp`)。
|
||||
- **`nexttrace-tiny`** — 精简版。保留常规 traceroute、独立 MTU 和 Fast Trace;不含 DNS 客户端 / CDN 测速 / IP 文本标注 / MTR / Globalping / WebUI / MCP。适合嵌入式或极简环境。
|
||||
- **`nexttrace-tiny`** — 精简版。保留常规 traceroute、独立 MTU 和 Fast Trace;包含可选 MTR TUI、报告和 RAW;不含 DNS 客户端 / CDN 测速 / IP 文本标注 / Globalping / WebUI / MCP。适合嵌入式或极简环境。
|
||||
- **`ntr`** — MTR 专用版。默认启动 MTR TUI。不含常规 traceroute、独立 DNS 客户端或 `--mtu`、CDN 测速、IP 文本标注、Globalping、Fast Trace、WebUI 或 MCP。
|
||||
|
||||
### 手动编译
|
||||
@@ -217,7 +221,7 @@ export GOEXPERIMENT=nojsonv2
|
||||
# 完整版(所有功能)
|
||||
go build -trimpath -o dist/nexttrace -ldflags "-w -s" .
|
||||
|
||||
# 精简版(无 DNS 客户端、无 MTR、无 Globalping、无 WebUI)
|
||||
# 精简版(含可选 MTR,无 DNS 客户端、无 Globalping、无 WebUI)
|
||||
go build -tags flavor_tiny -trimpath -o dist/nexttrace-tiny -ldflags "-w -s" .
|
||||
|
||||
# MTR 专用版
|
||||
@@ -276,7 +280,7 @@ nexttrace http://example.com:8080/index.html?q=1
|
||||
nexttrace --table 1.0.0.1
|
||||
|
||||
# 机器可读输出:stdout 只包含一个 JSON 文档
|
||||
nexttrace --raw 1.0.0.1
|
||||
nexttrace --traceroute --raw 1.0.0.1
|
||||
nexttrace --json 1.0.0.1
|
||||
|
||||
# 将实时 traceroute 输出写入自定义文件
|
||||
@@ -308,6 +312,45 @@ export NEXTTRACE_DISABLEMPLS=1
|
||||
|
||||
普通 traceroute 同时指定多个输出模式时,优先级为 `--json` > `--table` > `--classic` > `--raw` > `--output` > 实时输出。高优先级模式覆盖显式 `--output` 或 `--output-default` 时,NextTrace 会在 stderr 说明该选择,且不会创建被忽略的日志文件。
|
||||
|
||||
#### 下游迁移与显式传统模式
|
||||
|
||||
`-k/--traceroute` 在完整版和 tiny 中选择传统 traceroute;它不是 `--classic` 排版的别名。可与现有传统输出格式、Fast Trace、文件目标和 Globalping 组合。与 `--mtr/-t`、`--report/-r`、`--wide/-w` 或独立 DNS、MTU、测速、IP 标注、deploy 模式同用会报错。
|
||||
|
||||
```bash
|
||||
nexttrace --traceroute example.com
|
||||
nexttrace -k example.com
|
||||
nexttrace --traceroute --raw example.com
|
||||
nexttrace --mtr --raw -q 10 example.com
|
||||
```
|
||||
|
||||
| 调用 | 当前 | 默认切换后 |
|
||||
|---|---|---|
|
||||
| 仅目标地址 | 传统 traceroute | MTR |
|
||||
| `--raw` | 传统 RAW | MTR RAW |
|
||||
| `--traceroute` | 传统 traceroute | 传统 traceroute |
|
||||
| `--traceroute --raw` | 传统 RAW | 传统 RAW |
|
||||
| `--json/--table/--classic/--output/--output-default/--route-path` | 传统模式 | 自动选择传统模式 |
|
||||
|
||||
独立功能入口以及 Fast Trace、文件目标和 Globalping 保持各自工作流;独立模式中的 `--json` 仍属于该模式。显式 MTR 与传统专用格式的冲突规则不变。
|
||||
|
||||
MTR TUI/RAW 在未指定 `-q` 时持续运行,report 默认每跳 10 次;自动化调用应设置明确的 `-q`。MTR 中 `-i` 是每跳探测间隔(默认 1000ms),`-z` 被忽略;传统 traceroute 中 `-q` 默认每跳 3 次,`-i` 是 TTL 组间隔(默认 300ms),`-z` 是包间隔(默认 50ms)。
|
||||
|
||||
两种 RAW 不能只按成功行的列数区分:传统 RAW 成功行 12 列、超时行保留历史 8 列;MTR RAW 的数据行固定 12 列,并持续逐事件输出。解析器还需遵守各模式现有的信息头和 stderr 规则。`NEXTTRACE_UNINTERRUPTED` 配合 `--traceroute --raw` 时继续保留传统循环行为。
|
||||
|
||||
需兼容旧版本的 Bash 包装脚本可在调用前检测能力:
|
||||
|
||||
```bash
|
||||
trace_mode=()
|
||||
nexttrace_help=$(nexttrace --help)
|
||||
if [[ "$nexttrace_help" == *"--traceroute"* ]]; then
|
||||
trace_mode=(--traceroute)
|
||||
fi
|
||||
nexttrace "${trace_mode[@]}" --raw example.com
|
||||
```
|
||||
|
||||
旧版本不添加新参数;不要在探测失败后去掉参数自动重试,以免重复发起探测。
|
||||
|
||||
|
||||
PS: 路由可视化的绘制模块为独立模块,具体代码可在 [nxtrace/traceMap](https://github.com/nxtrace/traceMap) 查看
|
||||
路由可视化功能需要每个 Hop 的地理位置坐标,目前支持搭配 NextTrace API、IPInfo 和 IP-API.com 使用。
|
||||
|
||||
@@ -647,7 +690,7 @@ raw stdout 契约仍严格保持 12 列。无限运行的 MTR 中,unreachable
|
||||
|
||||
> 注意:`--show-ips` 仅在 MTR 模式(`--mtr`、`-r`、`-w`)生效,其他模式会忽略。
|
||||
>
|
||||
> 注意:`--mtr` 不可与 `--table`、`--classic`、`--json`、`--output`、`--output-default`、`--route-path`、`--from`、`--fast-trace`、`--file`、`--deploy` 同时使用。
|
||||
> 注意:`--mtr` 不可与 `--traceroute`、`--table`、`--classic`、`--json`、`--output`、`--output-default`、`--route-path`、`--from`、`--fast-trace`、`--file`、`--deploy` 同时使用。
|
||||
|
||||
#### `NextTrace`支持用户自主选择 IP 数据库(目前支持:`NextTrace-API`, `IP.SB`, `IPInfo`, `IPInsight`, `IPAPI.com`, `IPInfoLocal`, `IPDB.One`, `CHUNZHEN`, `DN42`)
|
||||
|
||||
@@ -781,51 +824,46 @@ NextTrace 当前会读取下列环境变量。对于 `NEXTTRACE_*` 布尔开关
|
||||
|
||||
### 全部用法详见 Usage 菜单
|
||||
|
||||
以下为 macOS 完整版的帮助输出;Windows 还提供 `--init` 和 `--icmp-mode`。
|
||||
|
||||
```shell
|
||||
Usage: nexttrace [-h|--help] [--init] [-4|--ipv4] [-6|--ipv6] [-T|--tcp]
|
||||
[-U|--udp] [-l|--dns] [--speed] [--nali] [-F|--fast-trace]
|
||||
[-p|--port <integer>] [--icmp-mode <integer>] [-q|--queries <integer>]
|
||||
[--max-attempts <integer>] [--parallel-requests <integer>]
|
||||
[-m|--max-hops <integer>] [-d|--data-provider
|
||||
usage: nexttrace [-h|--help] [-4|--ipv4] [-6|--ipv6] [-T|--tcp] [-U|--udp]
|
||||
[--mtu] [-F|--fast-trace] [-p|--port <integer>] [-q|--queries
|
||||
<integer>] [--max-attempts <integer>] [--parallel-requests
|
||||
<integer>] [-m|--max-hops <integer>] [-d|--data-provider
|
||||
(IP.SB|ip.sb|IPInfo|ipinfo|IPInsight|ipinsight|IPAPI.com|ip-api.com|IPInfoLocal|ipinfolocal|chunzhen|NextTrace-API|ipdb.one|disable-geoip|DN42|dn42)]
|
||||
[--pow-provider (api.nxtrace.org|sakura)] [-n|--no-rdns]
|
||||
[-a|--always-rdns] [-P|--route-path] [--dn42] [-o|--output
|
||||
"<value>"] [-O|--output-default] [--table] [--raw]
|
||||
[-j|--json] [-c|--classic] [-f|--first <integer>] [-M|--map]
|
||||
[-e|--disable-mpls] [-V|--version] [-x|--setup-api-v4-token]
|
||||
[-a|--always-rdns] [-k|--traceroute] [-P|--route-path]
|
||||
[-o|--output "<value>"] [-O|--output-default] [--table]
|
||||
[-j|--json] [-c|--classic] [--dn42] [--raw] [-f|--first
|
||||
<integer>] [-M|--map] [-e|--disable-mpls] [-V|--version]
|
||||
[-x|--setup-api-v4-token] [-l|--dns] [--speed] [--nali]
|
||||
[-s|--source "<value>"] [--source-port <integer>] [-D|--dev
|
||||
"<value>"] [--listen "<value>"] [--deploy-token "<value>"]
|
||||
[--mcp] [--deploy] [-z|--send-time <integer>]
|
||||
[-i|--ttl-time <integer>] [--timeout <integer>]
|
||||
[--psize <integer>] [--dot-server
|
||||
[--mcp] [--deploy] [-z|--send-time <integer>] [-i|--ttl-time
|
||||
<integer>] [--timeout <integer>] [--psize <integer>] [-Q|--tos
|
||||
<integer>] [--dot-server
|
||||
(dnssb|aliyun|dnspod|google|cloudflare)] [-g|--language
|
||||
(en|cn)] [-C|--no-color] [--from "<value>"] [-t|--mtr]
|
||||
[-r|--report] [-w|--wide] [--show-ips] [-y|--ipinfo <integer>]
|
||||
[--file "<value>"] [TARGET "<value>"]
|
||||
|
||||
An open source visual route tracking CLI tool
|
||||
|
||||
Arguments:
|
||||
|
||||
-h --help Print help information
|
||||
--init Windows ONLY: Extract WinDivert runtime to
|
||||
executable directory
|
||||
-l --dns Run DNS client mode. See `nexttrace --dns
|
||||
--help` for details
|
||||
--speed Run CDN speed test mode. See `nexttrace
|
||||
--speed --help` for details
|
||||
--nali Annotate IP literals in text using
|
||||
NextTrace GeoIP data
|
||||
-4 --ipv4 Use IPv4 only
|
||||
-6 --ipv6 Use IPv6 only
|
||||
-T --tcp Use TCP SYN for tracerouting (default
|
||||
dest-port is 80)
|
||||
-U --udp Use UDP SYN for tracerouting (default
|
||||
dest-port is 33494)
|
||||
--mtu Run standalone UDP path-MTU discovery mode
|
||||
with streaming output and GeoIP/RDNS
|
||||
-F --fast-trace One-Key Fast Trace to China ISPs
|
||||
-p --port Set the destination port to use. With
|
||||
default of 80 for "tcp", 33494 for "udp"
|
||||
--icmp-mode Windows ONLY: Choose the method to listen
|
||||
for ICMP packets (1=Socket, 2=WinDivert;
|
||||
0=Auto)
|
||||
-q --queries Latency samples per hop. Increase to 5-10
|
||||
on unstable paths for a steadier view.
|
||||
Default: 3
|
||||
@@ -852,28 +890,38 @@ Arguments:
|
||||
domain names
|
||||
-a --always-rdns Always resolve IP addresses to their
|
||||
domain names
|
||||
-k --traceroute Use traditional traceroute mode; with
|
||||
--raw, preserve traditional raw output
|
||||
-P --route-path Print traceroute hop path by ASN and
|
||||
location
|
||||
--dn42 DN42 Mode
|
||||
-o --output Write trace result to FILE
|
||||
(RealtimePrinter only)
|
||||
-O --output-default Write trace result to the default log file
|
||||
-o --output Write realtime trace output and final stop
|
||||
reason to FILE
|
||||
-O --output-default Write realtime trace output and final stop
|
||||
reason to the default log file
|
||||
(/tmp/trace.log)
|
||||
--table Output trace results as a final summary
|
||||
table (traceroute report mode)
|
||||
--raw Machine-friendly output. With MTR
|
||||
(--mtr/-r/-w), enables streaming raw event
|
||||
mode
|
||||
-j --json Output trace results as JSON
|
||||
-c --classic Classic Output trace results like
|
||||
BestTrace
|
||||
--dn42 DN42 Mode
|
||||
--raw Machine-friendly output; use --traceroute
|
||||
--raw to preserve traditional raw output.
|
||||
With MTR (--mtr/-r/-w), enables streaming
|
||||
raw event mode
|
||||
-f --first Start from the first_ttl hop (instead of
|
||||
1). Default: 1
|
||||
-M --map Disable Print Trace Map
|
||||
-e --disable-mpls Disable MPLS
|
||||
-V --version Print version info and exit
|
||||
-x --setup-api-v4-token Store a session-only NextTrace API v4
|
||||
token in a temporary file and exit
|
||||
token in a temporary file
|
||||
-l --dns Run DNS client mode. See `nexttrace --dns
|
||||
--help` for details
|
||||
--speed Run CDN speed test mode. See `nexttrace
|
||||
--speed --help` for details
|
||||
--nali Annotate IP literals in text using
|
||||
NextTrace GeoIP data
|
||||
-s --source Use source address src_addr for outgoing
|
||||
packets
|
||||
--source-port Use source port src_port for outgoing
|
||||
@@ -887,8 +935,7 @@ Arguments:
|
||||
127.0.0.1:30080)
|
||||
--deploy-token Set bearer token for --deploy
|
||||
WebUI/API/WebSocket/MCP access
|
||||
--mcp Enable MCP endpoint under --deploy at
|
||||
/mcp
|
||||
--mcp Enable MCP endpoint under --deploy at /mcp
|
||||
--deploy Start the Gin powered web console
|
||||
-z --send-time Advanced: per-packet gap [ms] inside the
|
||||
same TTL group. Lower is faster; raise to
|
||||
@@ -904,10 +951,10 @@ Arguments:
|
||||
paths. Default: 1000
|
||||
--psize Probe packet size in bytes, inclusive IP
|
||||
and active probe headers. Default is the
|
||||
minimum legal size for the chosen
|
||||
protocol and IP family; raise for MTU or
|
||||
minimum legal size for the chosen protocol
|
||||
and IP family; raise for MTU or
|
||||
large-packet testing. Negative values
|
||||
randomize each probe up to abs(value).
|
||||
randomize each probe up to abs(value)
|
||||
-Q --tos Set the IP type-of-service / traffic class
|
||||
value [0-255]. Default: 0
|
||||
--dot-server Use DoT Server for DNS Parse [dnssb,
|
||||
|
||||
+43
-16
@@ -368,7 +368,7 @@ func registerInitFlag(parser *argparse.Parser) *bool {
|
||||
}
|
||||
|
||||
func registerFastTraceFlag(parser *argparse.Parser) *bool {
|
||||
if !defaultMTR {
|
||||
if enableTraceroute {
|
||||
return parser.Flag("F", "fast-trace", &argparse.Options{Help: "One-Key Fast Trace to China ISPs"})
|
||||
}
|
||||
return ptrBool(false)
|
||||
@@ -396,7 +396,7 @@ func registerDataProviderFlag(parser *argparse.Parser) *string {
|
||||
}
|
||||
|
||||
func buildQueriesHelp() string {
|
||||
if defaultMTR {
|
||||
if !enableTraceroute {
|
||||
return "MTR only: max probes per hop. 0 = unlimited in TUI/raw; --report defaults to 10 when omitted. Start with 10-20 on unstable paths"
|
||||
}
|
||||
return "Latency samples per hop. Increase to 5-10 on unstable paths for a steadier view"
|
||||
@@ -431,7 +431,11 @@ func buildTOSHelp() string {
|
||||
}
|
||||
|
||||
func registerTracerouteOutputFlags(parser *argparse.Parser) tracerouteOutputFlags {
|
||||
if !defaultMTR {
|
||||
return registerTracerouteOutputFlagsWithAvailability(parser, enableTraceroute)
|
||||
}
|
||||
|
||||
func registerTracerouteOutputFlagsWithAvailability(parser *argparse.Parser, enabled bool) tracerouteOutputFlags {
|
||||
if enabled {
|
||||
return tracerouteOutputFlags{
|
||||
routePath: parser.Flag("P", "route-path", &argparse.Options{Help: "Print traceroute hop path by ASN and location"}),
|
||||
outputPath: parser.String("o", "output", &argparse.Options{Help: "Write realtime trace output and final stop reason to FILE"}),
|
||||
@@ -473,19 +477,19 @@ func registerWebUIFlagsWithAvailability(parser *argparse.Parser, enabled bool) w
|
||||
}
|
||||
|
||||
func registerPacketIntervalFlag(parser *argparse.Parser) *int {
|
||||
if !defaultMTR {
|
||||
if enableTraceroute {
|
||||
return parser.Int("z", "send-time", &argparse.Options{Default: defaultPacketIntervalMs, Help: buildPacketIntervalHelp()})
|
||||
}
|
||||
return ptrInt(defaultPacketIntervalMs)
|
||||
}
|
||||
|
||||
func buildRawHelp() string {
|
||||
rawHelp := "Machine-friendly output"
|
||||
if !enableTraceroute {
|
||||
return "MTR streaming raw event output"
|
||||
}
|
||||
rawHelp := "Machine-friendly output; use --traceroute --raw to preserve traditional raw output"
|
||||
if enableMTR {
|
||||
mtrFlags := "--mtr/-r/-w"
|
||||
if defaultMTR {
|
||||
mtrFlags = "-r/-w"
|
||||
}
|
||||
rawHelp += ". With MTR (" + mtrFlags + "), enables streaming raw event mode"
|
||||
}
|
||||
return rawHelp
|
||||
@@ -495,7 +499,7 @@ func buildTTLIntervalHelp() string {
|
||||
if !enableMTR {
|
||||
return "Advanced: TTL-group interval [ms] in normal traceroute. 100-300ms is usually safe; lower is faster but may trigger rate limits"
|
||||
}
|
||||
if defaultMTR {
|
||||
if !enableTraceroute {
|
||||
return "Advanced: per-hop probe interval [ms] in MTR mode. 500-1000ms is a good starting point; omitted defaults to 1000ms"
|
||||
}
|
||||
return "Advanced: TTL-group interval [ms] in normal traceroute. In MTR mode (--mtr/-r/-w, including --raw), this becomes per-hop probe interval. 500-1000ms is a good MTR starting range"
|
||||
@@ -521,7 +525,7 @@ func applyTTLIntervalDefault(ttlInterval *int, ttlTimeExplicit, effectiveMTR boo
|
||||
}
|
||||
|
||||
func registerDisableMaptraceFlag(parser *argparse.Parser) *bool {
|
||||
if !defaultMTR {
|
||||
if enableTraceroute {
|
||||
return parser.Flag("M", "map", &argparse.Options{Help: "Disable Print Trace Map"})
|
||||
}
|
||||
return ptrBool(true)
|
||||
@@ -540,8 +544,8 @@ func registerGlobalpingFlagWithAvailability(parser *argparse.Parser, enabled boo
|
||||
|
||||
func registerMTRFlags(parser *argparse.Parser) mtrCLIFlags {
|
||||
if enableMTR {
|
||||
mtrMode := ptrBool(true)
|
||||
if !defaultMTR {
|
||||
mtrMode := ptrBool(false)
|
||||
if enableTraceroute {
|
||||
mtrMode = parser.Flag("t", "mtr", &argparse.Options{Help: "Enable MTR (My Traceroute) continuous probing mode"})
|
||||
}
|
||||
return mtrCLIFlags{
|
||||
@@ -562,7 +566,7 @@ func registerMTRFlags(parser *argparse.Parser) mtrCLIFlags {
|
||||
}
|
||||
|
||||
func registerFileFlag(parser *argparse.Parser) *string {
|
||||
if !defaultMTR {
|
||||
if enableTraceroute {
|
||||
return parser.String("", "file", &argparse.Options{Help: "Read IP Address or domain name from file"})
|
||||
}
|
||||
return ptrStr("")
|
||||
@@ -1378,6 +1382,7 @@ func Execute() {
|
||||
Help: "Choose PoW Provider for NextTrace API v3 [api.nxtrace.org, sakura] For China mainland users, please use sakura"})
|
||||
norDNS := parser.Flag("n", "no-rdns", &argparse.Options{Help: "Do not resolve IP addresses to their domain names"})
|
||||
alwaysrDNS := parser.Flag("a", "always-rdns", &argparse.Options{Help: "Always resolve IP addresses to their domain names"})
|
||||
tracerouteMode := registerTracerouteFlag(parser)
|
||||
outputFlags := registerTracerouteOutputFlags(parser)
|
||||
routePath := outputFlags.routePath
|
||||
outputPath := outputFlags.outputPath
|
||||
@@ -1421,7 +1426,7 @@ func Execute() {
|
||||
// ── Globalping flag (full only) ──
|
||||
from := registerGlobalpingFlag(parser)
|
||||
|
||||
// ── MTR flags (full & ntr only) ──
|
||||
// ── MTR flags (all flavors) ──
|
||||
mtrFlags := registerMTRFlags(parser)
|
||||
mtrMode := mtrFlags.mtrMode
|
||||
reportMode := mtrFlags.reportMode
|
||||
@@ -1429,7 +1434,7 @@ func Execute() {
|
||||
showIPs := mtrFlags.showIPs
|
||||
ipInfoMode := mtrFlags.ipInfoMode
|
||||
|
||||
// ── File: hidden in ntr (conflicts with default MTR mode) ──
|
||||
// ── File: hidden in MTR-only ntr ──
|
||||
file := registerFileFlag(parser)
|
||||
str := parser.StringPositional(&argparse.Options{Help: "Trace target: IPv4 address (e.g. 8.8.8.8), IPv6 address (e.g. 2001:db8::1), domain name (e.g. example.com), or URL (e.g. https://example.com)"})
|
||||
|
||||
@@ -1458,7 +1463,29 @@ func Execute() {
|
||||
defer stop()
|
||||
util.SrcDev = ""
|
||||
|
||||
mtrModes := deriveEffectiveMTRModes(*mtrMode, *reportMode, *wideMode, *rawPrint)
|
||||
standalone := ""
|
||||
switch {
|
||||
case *mtuMode:
|
||||
standalone = "--mtu"
|
||||
case *naliMode:
|
||||
standalone = "--nali"
|
||||
case *deploy:
|
||||
standalone = "--deploy"
|
||||
}
|
||||
mtrModes, modeErr := resolveTraceModes(traceModeOptions{
|
||||
traceroute: *tracerouteMode,
|
||||
mtr: *mtrMode,
|
||||
report: *reportMode,
|
||||
wide: *wideMode,
|
||||
raw: *rawPrint,
|
||||
traditional: *jsonPrint || *tablePrint || *classicPrint || *outputPath != "" ||
|
||||
*outputDefault || *routePath || *fastTraceFlag || *file != "" || (enableGlobalping && *from != ""),
|
||||
standalone: standalone,
|
||||
}, defaultMTR)
|
||||
if modeErr != nil {
|
||||
fmt.Fprintln(os.Stderr, modeErr)
|
||||
os.Exit(1)
|
||||
}
|
||||
if *naliMode {
|
||||
applyColorMode(*noColor)
|
||||
if maybePrintVersion(*ver) {
|
||||
|
||||
+3
-3
@@ -1078,7 +1078,7 @@ func TestAdvancedHelpTextMentionsTuningGuidance(t *testing.T) {
|
||||
"intercontinental",
|
||||
"raise for MTU or",
|
||||
}
|
||||
if !defaultMTR {
|
||||
if enableTraceroute {
|
||||
wants = append(wants, "rate-limited links")
|
||||
}
|
||||
for _, want := range wants {
|
||||
@@ -1303,7 +1303,7 @@ func TestResolvePacketSizeArg_DefaultsToProtocolMinimum(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRegisterTracerouteOutputFlagsParsesOutputPath(t *testing.T) {
|
||||
if defaultMTR {
|
||||
if !enableTraceroute {
|
||||
t.Skip("normal traceroute output flags are unavailable in the ntr flavor")
|
||||
}
|
||||
parser := argparse.NewParser("nexttrace", "")
|
||||
@@ -1325,7 +1325,7 @@ func TestRegisterTracerouteOutputFlagsParsesOutputPath(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRegisterTracerouteOutputFlagsParsesOutputDefault(t *testing.T) {
|
||||
if defaultMTR {
|
||||
if !enableTraceroute {
|
||||
t.Skip("normal traceroute output flags are unavailable in the ntr flavor")
|
||||
}
|
||||
parser := argparse.NewParser("nexttrace", "")
|
||||
|
||||
@@ -33,6 +33,10 @@ func maybeRunDNSModeWithAvailability(
|
||||
_, _ = fmt.Fprintf(stderr, "-l/--dns is not available in %s; please use the full nexttrace build\n", appBinName)
|
||||
return true, 1
|
||||
}
|
||||
if containsTracerouteFlag(rawArgs) {
|
||||
_, _ = fmt.Fprintln(stderr, "--traceroute cannot be combined with --dns")
|
||||
return true, 1
|
||||
}
|
||||
return true, runner(rawArgs[1:], stdout, stderr)
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ const (
|
||||
appBinName = "nexttrace"
|
||||
enableWebUI = true
|
||||
enableGlobalping = true
|
||||
enableTraceroute = true
|
||||
enableMTR = true
|
||||
enableMTU = true
|
||||
enableSpeed = true
|
||||
|
||||
@@ -6,6 +6,7 @@ const (
|
||||
appBinName = "ntr"
|
||||
enableWebUI = false
|
||||
enableGlobalping = false
|
||||
enableTraceroute = false
|
||||
enableMTR = true
|
||||
enableMTU = false
|
||||
enableSpeed = false
|
||||
|
||||
+2
-1
@@ -6,7 +6,8 @@ const (
|
||||
appBinName = "nexttrace-tiny"
|
||||
enableWebUI = false
|
||||
enableGlobalping = false
|
||||
enableMTR = false
|
||||
enableTraceroute = true
|
||||
enableMTR = true
|
||||
enableMTU = true
|
||||
enableSpeed = false
|
||||
enableNali = false
|
||||
|
||||
@@ -50,6 +50,10 @@ func maybeRunSpeedModeWithAvailability(enabled bool, rawArgs []string, stdout, s
|
||||
_, _ = fmt.Fprintf(stderr, "--speed is not available in %s; please use the full nexttrace build\n", appBinName)
|
||||
return true, 1
|
||||
}
|
||||
if containsTracerouteFlag(rawArgs) {
|
||||
_, _ = fmt.Fprintln(stderr, "--traceroute cannot be combined with --speed")
|
||||
return true, 1
|
||||
}
|
||||
return true, runSpeedMode(rawArgs, stdout, stderr)
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/akamensky/argparse"
|
||||
)
|
||||
|
||||
func registerTracerouteFlag(parser *argparse.Parser) *bool {
|
||||
return registerTracerouteFlagWithAvailability(parser, enableTraceroute)
|
||||
}
|
||||
|
||||
func registerTracerouteFlagWithAvailability(parser *argparse.Parser, enabled bool) *bool {
|
||||
if enabled {
|
||||
return parser.Flag("k", "traceroute", &argparse.Options{Help: "Use traditional traceroute mode; with --raw, preserve traditional raw output"})
|
||||
}
|
||||
return ptrBool(false)
|
||||
}
|
||||
|
||||
type traceModeOptions struct {
|
||||
traceroute bool
|
||||
mtr bool
|
||||
report bool
|
||||
wide bool
|
||||
raw bool
|
||||
traditional bool
|
||||
standalone string
|
||||
}
|
||||
|
||||
// Explicit modes take precedence over the default, never over conflicting flags.
|
||||
// traditional covers traceroute output formats and its batch/remote workflows.
|
||||
func resolveTraceModes(opts traceModeOptions, useMTRByDefault bool) (effectiveMTRModes, error) {
|
||||
if opts.traceroute {
|
||||
for _, flag := range []struct {
|
||||
name string
|
||||
set bool
|
||||
}{
|
||||
{"--mtr", opts.mtr},
|
||||
{"--report", opts.report},
|
||||
{"--wide", opts.wide},
|
||||
{opts.standalone, opts.standalone != ""},
|
||||
} {
|
||||
if flag.set {
|
||||
return effectiveMTRModes{}, fmt.Errorf("--traceroute cannot be combined with %s", flag.name)
|
||||
}
|
||||
}
|
||||
}
|
||||
mtr := opts.mtr || (useMTRByDefault && !opts.traceroute && !opts.traditional && opts.standalone == "")
|
||||
return deriveEffectiveMTRModes(mtr, opts.report, opts.wide, opts.raw), nil
|
||||
}
|
||||
|
||||
// DNS and speed dispatch before the main parser. Do not consume anything after --.
|
||||
func containsTracerouteFlag(args []string) bool {
|
||||
for _, arg := range args {
|
||||
if arg == "--" {
|
||||
return false
|
||||
}
|
||||
if arg == "-k" || arg == "--traceroute" {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
@@ -0,0 +1,164 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/akamensky/argparse"
|
||||
)
|
||||
|
||||
func TestResolveTraceModes(t *testing.T) {
|
||||
type modeCase struct {
|
||||
name string
|
||||
opts traceModeOptions
|
||||
want effectiveMTRModes
|
||||
conflict string
|
||||
}
|
||||
for _, useDefault := range []bool{false, true} {
|
||||
tests := []modeCase{
|
||||
{name: "default", want: effectiveMTRModes{mtr: useDefault}},
|
||||
{name: "raw follows default", opts: traceModeOptions{raw: true}, want: effectiveMTRModes{mtr: useDefault, raw: useDefault}},
|
||||
{name: "traditional", opts: traceModeOptions{traceroute: true}},
|
||||
{name: "traditional raw", opts: traceModeOptions{traceroute: true, raw: true}},
|
||||
{name: "traditional format", opts: traceModeOptions{traditional: true}},
|
||||
{name: "traditional format and raw", opts: traceModeOptions{traditional: true, raw: true}},
|
||||
{name: "explicit mtr", opts: traceModeOptions{mtr: true}, want: effectiveMTRModes{mtr: true}},
|
||||
{name: "report", opts: traceModeOptions{report: true}, want: effectiveMTRModes{mtr: true, report: true}},
|
||||
{name: "wide", opts: traceModeOptions{wide: true}, want: effectiveMTRModes{mtr: true, report: true, wide: true}},
|
||||
{name: "mtr raw", opts: traceModeOptions{mtr: true, raw: true}, want: effectiveMTRModes{mtr: true, raw: true}},
|
||||
{name: "report raw", opts: traceModeOptions{report: true, raw: true}, want: effectiveMTRModes{mtr: true, report: true, raw: true}},
|
||||
{name: "mtr conflict", opts: traceModeOptions{traceroute: true, mtr: true}, conflict: "--mtr"},
|
||||
{name: "report conflict", opts: traceModeOptions{traceroute: true, report: true}, conflict: "--report"},
|
||||
{name: "wide conflict", opts: traceModeOptions{traceroute: true, wide: true}, conflict: "--wide"},
|
||||
// Keep explicit MTR selected so the existing output conflict validator rejects it.
|
||||
{name: "explicit mtr with format", opts: traceModeOptions{mtr: true, traditional: true}, want: effectiveMTRModes{mtr: true}},
|
||||
}
|
||||
for _, mode := range []string{"--mtu", "--nali", "--deploy"} {
|
||||
tests = append(tests, modeCase{
|
||||
name: mode, opts: traceModeOptions{standalone: mode, traditional: true},
|
||||
}, modeCase{
|
||||
name: mode + " conflict", opts: traceModeOptions{standalone: mode, traceroute: true}, conflict: mode,
|
||||
})
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name+map[bool]string{false: "/trace-default", true: "/mtr-default"}[useDefault], func(t *testing.T) {
|
||||
got, err := resolveTraceModes(tt.opts, useDefault)
|
||||
if tt.conflict != "" {
|
||||
if err == nil || !strings.Contains(err.Error(), tt.conflict) {
|
||||
t.Fatalf("error = %v, want conflict %s", err, tt.conflict)
|
||||
}
|
||||
return
|
||||
}
|
||||
if err != nil || got != tt.want {
|
||||
t.Fatalf("got %#v, %v; want %#v", got, err, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestTracerouteFlagAliasesAndConflicts(t *testing.T) {
|
||||
for _, flag := range []string{"-k", "--traceroute"} {
|
||||
for _, other := range []string{"", "-t", "--mtr", "-r", "--report", "-w", "--wide"} {
|
||||
for _, reversed := range []bool{false, true} {
|
||||
parser := argparse.NewParser("nexttrace", "")
|
||||
traditional := registerTracerouteFlagWithAvailability(parser, true)
|
||||
mtr := parser.Flag("t", "mtr", nil)
|
||||
report := parser.Flag("r", "report", nil)
|
||||
wide := parser.Flag("w", "wide", nil)
|
||||
args := []string{flag}
|
||||
if other != "" {
|
||||
args = append(args, other)
|
||||
}
|
||||
if reversed && len(args) == 2 {
|
||||
args[0], args[1] = args[1], args[0]
|
||||
}
|
||||
if err := parser.Parse(append([]string{"nexttrace"}, args...)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, useDefault := range []bool{false, true} {
|
||||
got, err := resolveTraceModes(traceModeOptions{traceroute: *traditional, mtr: *mtr, report: *report, wide: *wide}, useDefault)
|
||||
if (err != nil) != (other != "") {
|
||||
t.Fatalf("args %v: error %v", args, err)
|
||||
}
|
||||
if other == "" && got.mtr {
|
||||
t.Fatalf("args %v selected MTR", args)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestModeFlagsMatchFlavorCapabilities(t *testing.T) {
|
||||
parser := argparse.NewParser(appBinName, "")
|
||||
traditional := registerTracerouteFlag(parser)
|
||||
registerTracerouteOutputFlags(parser)
|
||||
mtr := registerMTRFlags(parser)
|
||||
registerPacketIntervalFlag(parser)
|
||||
registerFileFlag(parser)
|
||||
usage := parser.Usage(nil)
|
||||
for _, flag := range []string{"--traceroute", "--json", "--classic", "--output", "--send-time", "--file"} {
|
||||
if strings.Contains(usage, flag) != enableTraceroute {
|
||||
t.Errorf("%s availability incorrect in %s", flag, appBinName)
|
||||
}
|
||||
}
|
||||
for _, flag := range []string{"--report", "--wide", "--show-ips", "--ipinfo"} {
|
||||
if !strings.Contains(usage, flag) {
|
||||
t.Errorf("missing %s in %s", flag, appBinName)
|
||||
}
|
||||
}
|
||||
got, err := resolveTraceModes(traceModeOptions{traceroute: *traditional, mtr: *mtr.mtrMode}, defaultMTR)
|
||||
if err != nil || got.mtr != (appBinName == "ntr") {
|
||||
t.Fatalf("default mode = %#v, %v", got, err)
|
||||
}
|
||||
if err := parser.Parse([]string{appBinName, "--mtr"}); (err == nil) != enableTraceroute {
|
||||
t.Fatalf("--mtr parse in %s: %v", appBinName, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestTraditionalOutputFlagsSurviveMTRDefault(t *testing.T) {
|
||||
for _, flag := range []string{"--json", "--table", "--classic", "--output-default", "--route-path", "--output"} {
|
||||
parser := argparse.NewParser("nexttrace", "")
|
||||
registerTracerouteFlagWithAvailability(parser, true)
|
||||
flags := registerTracerouteOutputFlagsWithAvailability(parser, true)
|
||||
args := []string{"nexttrace", flag}
|
||||
if flag == "--output" {
|
||||
args = append(args, "trace.log")
|
||||
}
|
||||
if err := parser.Parse(args); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
selected := *flags.jsonPrint || *flags.tablePrint || *flags.classicPrint || *flags.outputDefault || *flags.routePath || *flags.outputPath != ""
|
||||
modes, err := resolveTraceModes(traceModeOptions{traditional: selected}, true)
|
||||
if err != nil || modes.mtr {
|
||||
t.Fatalf("%s: %#v, %v", flag, modes, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestEarlyModesRejectTracerouteBeforeExecution(t *testing.T) {
|
||||
for _, flag := range []string{"-k", "--traceroute"} {
|
||||
var out, errOut bytes.Buffer
|
||||
handled, code := maybeRunDNSModeWithAvailability(true, []string{"--dns", flag, "example.com"}, &out, &errOut, func([]string, io.Writer, io.Writer) int {
|
||||
t.Fatal("DNS runner called")
|
||||
return 0
|
||||
})
|
||||
if !handled || code != 1 || out.Len() != 0 || !strings.Contains(errOut.String(), "cannot be combined") {
|
||||
t.Fatalf("DNS: %v/%d stdout %q stderr %q", handled, code, out.String(), errOut.String())
|
||||
}
|
||||
for _, args := range [][]string{{"--speed", flag}, {flag, "--speed"}} {
|
||||
out.Reset()
|
||||
errOut.Reset()
|
||||
handled, code = maybeRunSpeedModeWithAvailability(true, args, &out, &errOut)
|
||||
if !handled || code != 1 || out.Len() != 0 || !strings.Contains(errOut.String(), "cannot be combined") {
|
||||
t.Fatalf("speed: %v/%d stdout %q stderr %q", handled, code, out.String(), errOut.String())
|
||||
}
|
||||
}
|
||||
}
|
||||
if containsTracerouteFlag([]string{"--", "--traceroute"}) {
|
||||
t.Fatal("interpreted positional argument as flag")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
# MTR 默认模式迁移准备:验证记录
|
||||
|
||||
日期:2026-09-06。对照基线:`92e0d4be070c35f74d19f97cbe3d24e5d0c266bf`。
|
||||
本次实现仍将完整版和 tiny 的 `defaultMTR` 设为 `false`;ntr 保持 `true`。
|
||||
|
||||
## tiny 体积
|
||||
|
||||
同一台 macOS arm64 主机交叉编译 Linux 版本并原生编译 Darwin 版本。使用 Go 1.27.1、`GOEXPERIMENT=nojsonv2`、`-tags flavor_tiny -trimpath -ldflags '-s -w'`;Linux 设置 `CGO_ENABLED=0`。Darwin 设置 `CGO_ENABLED=1`,C 编译与链接使用 `-mmacosx-version-min=13.0`,Go linker 追加 `-macos=13.0`。未注入发布版本或构建时间。Linux amd64/arm64 使用 UPX 5.2.1 `-9`,mipsle 和 Darwin 不压缩。
|
||||
|
||||
| 平台 | 基线字节 | 本次实现字节 | 差值 |
|
||||
|---|---:|---:|---:|
|
||||
| Linux amd64 | 11,870,368 | 11,870,368 | 0 |
|
||||
| Linux arm64 | 11,010,208 | 11,010,208 | 0 |
|
||||
| Linux mipsle | 12,648,639 | 12,648,639 | 0 |
|
||||
| Darwin arm64 | 11,082,994 | 11,082,994 | 0 |
|
||||
|
||||
| UPX 产物 | 基线字节 | 本次实现字节 | 差值 |
|
||||
|---|---:|---:|---:|
|
||||
| Linux amd64 | 4,733,908 | 4,553,476 | -180,432 |
|
||||
| Linux arm64 | 4,129,916 | 4,132,500 | +2,584 |
|
||||
|
||||
规划阶段仅将基线 tiny 的 `enableMTR` 改为 `true`,未压缩体积也均未变化,UPX amd64/arm64 分别增加 624/1,012 字节。本次实现还包含显式传统模式和模式解析准备,因此应使用上表作为本次整体变更的比较。
|
||||
|
||||
基线 tiny 二进制已包含 MTR TUI 和调度器符号,原先仅未开放 CLI 参数入口。压缩结果受代码布局、构建信息等影响,不能作为长期体积承诺或运行性能收益;二进制字节数也不等于内存占用。
|
||||
|
||||
## 构建与自动测试
|
||||
|
||||
以下检查通过,Go 测试中的本机 HTTP/TLS 服务在允许绑定回环端口的环境下运行:
|
||||
|
||||
```sh
|
||||
go build ./...
|
||||
go test ./...
|
||||
GOEXPERIMENT=nojsonv2 go test ./...
|
||||
go test -tags flavor_tiny ./cmd ./server
|
||||
go test -tags flavor_ntr ./cmd ./server
|
||||
bash -n scripts/regression/unix.sh
|
||||
```
|
||||
|
||||
新增测试覆盖短长参数、参数顺序、显式模式冲突、三种 flavor 参数能力、未来默认 MTR 的传统输出推断,以及 DNS/测速在执行前拒绝传统模式参数。传统 RAW 固定样本验证成功行 12 列、超时行 8 列,保留现有停止原因输出测试。
|
||||
|
||||
## macOS 运行验证
|
||||
|
||||
- 完整版和 tiny 均以 `127.0.0.1`、禁用 GeoIP/RDNS、有限次数和跳数验证。归一化 RTT 后,当前默认文本与 `-k`、`--traceroute` 一致;单独 RAW 与 `--traceroute --raw` 一致。
|
||||
- 两个 flavor 的有限 MTR report/RAW 正常退出;MTR RAW 数据行保持 12 列。
|
||||
- 短长传统模式参数与 MTR/report/wide、MTU 冲突时,退出码为 1、stdout 为空、stderr 给出冲突;完整版另覆盖 DNS、测速、IP 标注和 deploy。
|
||||
- 两个 flavor 的真实 PTY 测试验证备用屏幕进入、按 `q` 退出、光标及终端属性恢复。比较终端属性时仅排除 Darwin 内核管理的 `PENDIN` 状态位。
|
||||
- 使用 Go `-overlay` 仅在临时构建中将完整版和 tiny 的 `defaultMTR` 设为 `true`,验证默认输出和单独 RAW 进入 MTR;显式传统模式、JSON/table/classic、两种文件输出、route-path 和文件目标保持传统路径。MTU 的 `--json --tcp` 进入 MTU 自身的协议冲突检查。ntr 的报告模式和参数能力保持不变。
|
||||
|
||||
Linux/Windows 运行回归用例已加入现有 CI 脚本;本机没有执行这些平台的运行验收。没有执行公网全套回归、生产部署或默认模式发布切换。
|
||||
@@ -0,0 +1,30 @@
|
||||
package printer
|
||||
|
||||
import (
|
||||
"net"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/nxtrace/NTrace-core/ipgeo"
|
||||
"github.com/nxtrace/NTrace-core/trace"
|
||||
)
|
||||
|
||||
func TestTraditionalRawKeepsHistoricalRows(t *testing.T) {
|
||||
res := &trace.Result{
|
||||
Hops: [][]trace.Hop{{
|
||||
{TTL: 1, Address: &net.IPAddr{IP: net.ParseIP("192.0.2.1")}, Hostname: "router.example", RTT: 1250 * time.Microsecond, Geo: &ipgeo.IPGeoData{Asnumber: "64500", Country: "Testland"}},
|
||||
{TTL: 1},
|
||||
}},
|
||||
StopReason: &trace.StopReason{Hop: 1, Reason: trace.StopReasonDestination},
|
||||
}
|
||||
got := captureStdout(t, func() { EasyPrinter(res, 0) })
|
||||
want := "1|192.0.2.1|router.example|1.25|64500|Testland|||||0.0000|0.0000\n1|*||||||\n"
|
||||
if got != want {
|
||||
t.Fatalf("raw output = %q, want %q", got, want)
|
||||
}
|
||||
lines := strings.Split(strings.TrimSuffix(got, "\n"), "\n")
|
||||
if len(strings.Split(lines[0], "|")) != 12 || len(strings.Split(lines[1], "|")) != 8 {
|
||||
t.Fatalf("historical column counts changed: %q", got)
|
||||
}
|
||||
}
|
||||
@@ -53,7 +53,8 @@ powershell -ExecutionPolicy Bypass -File .\scripts\regression\windows.ps1 -Artif
|
||||
|
||||
- 构建当前仓库的 `nexttrace`、`nexttrace-tiny`、`ntr`
|
||||
- 先跑 `go test ./...`
|
||||
- 再跑完整回归
|
||||
- 再跑完整回归,包括 `-k/--traceroute`、默认模式保持不变,以及 tiny 的有限 MTR report/RAW
|
||||
- 传统输出用例显式使用 `--traceroute`,默认行为另有独立用例
|
||||
- 输出:
|
||||
- `summary.tsv`
|
||||
- `artifacts/`
|
||||
|
||||
+33
-26
@@ -501,54 +501,61 @@ if (( ! IPV6_AVAILABLE )); then
|
||||
echo "ipv6_skip_reason=${IPV6_SKIP_REASON}"
|
||||
fi
|
||||
|
||||
run_cmd icmp4_basic 'ICMP IPv4 basic trace' "\"${BIN}\" --no-color -q 1 -m 3 --timeout 1000 1.1.1.1"
|
||||
run_cmd tcp4_basic 'TCP IPv4 basic trace' "\"${BIN}\" --no-color -T -q 1 -m 3 --timeout 1000 1.1.1.1"
|
||||
run_cmd udp4_basic 'UDP IPv4 basic trace' "\"${BIN}\" --no-color -U -q 1 -m 3 --timeout 1000 1.1.1.1"
|
||||
run_cmd_check default_trace 'Default remains traditional traceroute' "\"${BIN}\" --no-color --data-provider disable-geoip -M -n -q 1 -m 1 --timeout 1000 1.1.1.1" 'hops max, .*ICMP mode' 'HOST:'
|
||||
run_cmd_check default_raw 'Bare RAW remains traditional' "\"${BIN}\" --no-color --raw --data-provider disable-geoip -M -n -q 1 -m 1 --timeout 1000 1.1.1.1" 'hops max, .*ICMP mode' 'HOST:'
|
||||
run_cmd_check traceroute_short 'Short traditional mode flag' "\"${BIN}\" -k --no-color --data-provider disable-geoip -M -n -q 1 -m 1 --timeout 1000 1.1.1.1" 'hops max, .*ICMP mode' 'HOST:'
|
||||
run_cmd_check traceroute_mtr_conflict 'Explicit modes conflict before probing' "\"${BIN}\" -k --mtr 1.1.1.1" 'cannot be combined' 'hops max|HOST:' '1'
|
||||
run_cmd icmp4_basic 'ICMP IPv4 basic trace' "\"${BIN}\" --traceroute --no-color -q 1 -m 3 --timeout 1000 1.1.1.1"
|
||||
run_cmd tcp4_basic 'TCP IPv4 basic trace' "\"${BIN}\" --traceroute --no-color -T -q 1 -m 3 --timeout 1000 1.1.1.1"
|
||||
run_cmd udp4_basic 'UDP IPv4 basic trace' "\"${BIN}\" --traceroute --no-color -U -q 1 -m 3 --timeout 1000 1.1.1.1"
|
||||
if (( IPV6_AVAILABLE )); then
|
||||
run_cmd icmp6_basic 'ICMP IPv6 basic trace' "\"${BIN}\" --no-color -6 -q 1 -m 3 --timeout 1000 2606:4700:4700::1111"
|
||||
run_cmd tcp6_basic 'TCP IPv6 basic trace' "\"${BIN}\" --no-color -6 -T -q 1 -m 3 --timeout 1000 2606:4700:4700::1111"
|
||||
run_cmd udp6_basic 'UDP IPv6 basic trace' "\"${BIN}\" --no-color -6 -U -q 1 -m 3 --timeout 1000 2606:4700:4700::1111"
|
||||
run_cmd icmp6_basic 'ICMP IPv6 basic trace' "\"${BIN}\" --traceroute --no-color -6 -q 1 -m 3 --timeout 1000 2606:4700:4700::1111"
|
||||
run_cmd tcp6_basic 'TCP IPv6 basic trace' "\"${BIN}\" --traceroute --no-color -6 -T -q 1 -m 3 --timeout 1000 2606:4700:4700::1111"
|
||||
run_cmd udp6_basic 'UDP IPv6 basic trace' "\"${BIN}\" --traceroute --no-color -6 -U -q 1 -m 3 --timeout 1000 2606:4700:4700::1111"
|
||||
else
|
||||
record_ipv6_skip icmp6_basic 'ICMP IPv6 basic trace'
|
||||
record_ipv6_skip tcp6_basic 'TCP IPv6 basic trace'
|
||||
record_ipv6_skip udp6_basic 'UDP IPv6 basic trace'
|
||||
fi
|
||||
run_cmd raw_output 'Raw hop rows' "\"${BIN}\" --no-color --raw -q 1 -m 2 --timeout 1000 1.1.1.1"
|
||||
run_cmd classic_output 'Classic printer' "\"${BIN}\" --no-color --classic -q 1 -m 2 --timeout 1000 1.1.1.1"
|
||||
run_cmd route_path 'Route-path summary' "\"${BIN}\" --no-color --route-path -q 1 -m 2 --timeout 1000 1.1.1.1"
|
||||
run_cmd provider_lang 'IP.SB + sakura + en' "\"${BIN}\" --no-color -q 1 -m 2 --timeout 1000 --data-provider IP.SB --pow-provider sakura --language en 1.1.1.1"
|
||||
run_cmd dot_resolver 'DoT resolver via aliyun' "\"${BIN}\" --no-color --dot-server aliyun -q 1 -m 1 --timeout 1000 ipv4.pek-4134.endpoint.nxtrace.org"
|
||||
run_cmd disable_geoip 'disable-geoip path' "\"${BIN}\" --no-color --data-provider disable-geoip -M -q 1 -m 2 --timeout 1000 1.1.1.1"
|
||||
run_cmd dn42_mode 'DN42 mode switch' "\"${BIN}\" --no-color --dn42 -q 1 -m 2 --timeout 1000 1.1.1.1"
|
||||
check_json_pure json_trace 'Traceroute JSON stdout purity' "\"${BIN}\" --no-color --json -q 1 -m 3 --timeout 1000 1.1.1.1"
|
||||
run_cmd raw_output 'Raw hop rows' "\"${BIN}\" --traceroute --no-color --raw -q 1 -m 2 --timeout 1000 1.1.1.1"
|
||||
run_cmd classic_output 'Classic printer' "\"${BIN}\" --traceroute --no-color --classic -q 1 -m 2 --timeout 1000 1.1.1.1"
|
||||
run_cmd route_path 'Route-path summary' "\"${BIN}\" --traceroute --no-color --route-path -q 1 -m 2 --timeout 1000 1.1.1.1"
|
||||
run_cmd provider_lang 'IP.SB + sakura + en' "\"${BIN}\" --traceroute --no-color -q 1 -m 2 --timeout 1000 --data-provider IP.SB --pow-provider sakura --language en 1.1.1.1"
|
||||
run_cmd dot_resolver 'DoT resolver via aliyun' "\"${BIN}\" --traceroute --no-color --dot-server aliyun -q 1 -m 1 --timeout 1000 ipv4.pek-4134.endpoint.nxtrace.org"
|
||||
run_cmd disable_geoip 'disable-geoip path' "\"${BIN}\" --traceroute --no-color --data-provider disable-geoip -M -q 1 -m 2 --timeout 1000 1.1.1.1"
|
||||
run_cmd dn42_mode 'DN42 mode switch' "\"${BIN}\" --traceroute --no-color --dn42 -q 1 -m 2 --timeout 1000 1.1.1.1"
|
||||
check_json_pure json_trace 'Traceroute JSON stdout purity' "\"${BIN}\" --traceroute --no-color --json -q 1 -m 3 --timeout 1000 1.1.1.1"
|
||||
check_json_pure json_mtu 'MTU JSON stdout purity' "\"${BIN}\" --no-color --mtu --json --timeout 1000 -q 1 -m 3 1.1.1.1"
|
||||
check_json_pure json_globalping 'Globalping JSON stdout purity' "\"${BIN}\" --no-color --json --from Germany -q 1 -m 3 --timeout 1000 1.1.1.1"
|
||||
check_no_clear_ansi table_non_tty 'Table output without clear-screen ANSI in non-TTY' "\"${BIN}\" --no-color --table -q 1 -m 2 --timeout 1000 1.1.1.1"
|
||||
check_output_file output_custom 'Custom output file path' "\"${BIN}\" --no-color -q 1 -m 2 --timeout 1000 -o \"${ART_ROOT}/custom.log\" 1.1.1.1" "${ART_ROOT}/custom.log"
|
||||
check_output_file output_default 'Default output file path' "TMPDIR=\"${DEFAULT_TMP_DIR}\" \"${BIN}\" --no-color -q 1 -m 2 --timeout 1000 -O 1.1.1.1" "${DEFAULT_LOG_PATH}"
|
||||
check_json_pure json_globalping 'Globalping JSON stdout purity' "\"${BIN}\" --traceroute --no-color --json --from Germany -q 1 -m 3 --timeout 1000 1.1.1.1"
|
||||
check_no_clear_ansi table_non_tty 'Table output without clear-screen ANSI in non-TTY' "\"${BIN}\" --traceroute --no-color --table -q 1 -m 2 --timeout 1000 1.1.1.1"
|
||||
check_output_file output_custom 'Custom output file path' "\"${BIN}\" --traceroute --no-color -q 1 -m 2 --timeout 1000 -o \"${ART_ROOT}/custom.log\" 1.1.1.1" "${ART_ROOT}/custom.log"
|
||||
check_output_file output_default 'Default output file path' "TMPDIR=\"${DEFAULT_TMP_DIR}\" \"${BIN}\" --traceroute --no-color -q 1 -m 2 --timeout 1000 -O 1.1.1.1" "${DEFAULT_LOG_PATH}"
|
||||
run_cmd mtu_text 'MTU text mode' "\"${BIN}\" --no-color --mtu --timeout 1000 -q 1 -m 3 1.1.1.1"
|
||||
check_mtu_tty_color mtu_tty_color 'MTU TTY colorized output' "\"${BIN}\" --mtu --timeout 1000 -q 1 -m 3 1.1.1.1"
|
||||
check_mtu_non_tty_plain mtu_non_tty_plain 'MTU non-TTY output has no ANSI' "\"${BIN}\" --mtu --timeout 1000 -q 1 -m 3 1.1.1.1"
|
||||
run_cmd mtr_report 'MTR report ICMP' "\"${BIN}\" --no-color -r -q 2 -i 300 --timeout 1000 -m 4 1.1.1.1"
|
||||
run_cmd mtr_wide 'MTR wide + show-ips' "\"${BIN}\" --no-color -w --show-ips -q 2 -i 300 --timeout 1000 -m 4 1.1.1.1"
|
||||
run_cmd mtr_raw 'MTR raw stream' "\"${BIN}\" --no-color -r --raw -q 2 -i 300 --timeout 1000 -m 4 1.1.1.1"
|
||||
run_cmd fast_trace_file 'Fast trace via --file' "\"${BIN}\" --no-color --file \"${TARGETS}\" -q 1 -m 2 --timeout 1000"
|
||||
run_cmd fast_trace_file 'Fast trace via --file' "\"${BIN}\" --traceroute --no-color --file \"${TARGETS}\" -q 1 -m 2 --timeout 1000"
|
||||
run_cmd_check help_speed_main 'Main help exposes only top-level speed entry' "\"${BIN}\" --help" --speed --speed-provider
|
||||
run_cmd_check help_speed_detail 'Speed help is dedicated and detailed' "\"${BIN}\" --speed --help" --speed-provider 'hops max, .*ICMP mode'
|
||||
check_json_pure speed_apple_json 'Apple speed JSON path' "\"${BIN}\" --speed --json --no-metadata --non-interactive --max 64KiB --timeout 2000 --threads 2 --latency-count 2" '"provider":"apple"' '0,2'
|
||||
check_json_pure speed_cloudflare_json 'Cloudflare speed JSON path' "\"${BIN}\" --speed --speed-provider cloudflare --json --no-metadata --non-interactive --max 64KiB --timeout 2000 --threads 2 --latency-count 2" '"provider":"cloudflare"' '0,2'
|
||||
run_cmd tiny_smoke 'nexttrace-tiny smoke' "\"${TINY}\" --no-color -q 1 -m 2 --timeout 1000 1.1.1.1"
|
||||
run_cmd tiny_smoke 'nexttrace-tiny smoke' "\"${TINY}\" --traceroute --no-color -q 1 -m 2 --timeout 1000 1.1.1.1"
|
||||
run_cmd_check tiny_default 'Tiny default remains traditional' "\"${TINY}\" --no-color --data-provider disable-geoip -M -n -q 1 -m 1 --timeout 1000 1.1.1.1" 'hops max, .*ICMP mode' 'HOST:'
|
||||
run_cmd_check tiny_mtr_report 'Tiny finite MTR report' "\"${TINY}\" --no-color -r --data-provider disable-geoip -n -q 2 -i 300 --timeout 1000 -m 2 1.1.1.1" '^HOST:' 'hops max'
|
||||
run_cmd_check tiny_mtr_raw 'Tiny finite MTR RAW' "\"${TINY}\" --no-color --mtr --raw --data-provider disable-geoip -n -q 2 -i 300 --timeout 1000 -m 2 1.1.1.1" '^1\|' 'hops max'
|
||||
run_cmd ntr_report 'ntr report smoke' "\"${NTR}\" --no-color -r -q 2 -i 300 --timeout 1000 -m 4 1.1.1.1"
|
||||
run_cmd_check tiny_speed_reject 'nexttrace-tiny rejects --speed' "\"${TINY}\" --speed" '--speed is not available' 'panic|goroutine [0-9]+|stack trace' '1'
|
||||
run_cmd_check ntr_speed_reject 'ntr rejects --speed' "\"${NTR}\" --speed" '--speed is not available' 'panic|goroutine [0-9]+|stack trace' '1'
|
||||
|
||||
capture_psize_tos psize_tos_icmp4 'ICMPv4 psize/tos packet capture' '1.1.1.1' "\"${BIN}\" --no-color -q 1 -m 1 --timeout 1000 --psize 84 -Q 46 1.1.1.1" 'tos 0x2e' 'length 84'
|
||||
capture_psize_tos psize_tos_udp4 'UDPv4 psize/tos packet capture' '1.1.1.1' "\"${BIN}\" --no-color -U -q 1 -m 1 --timeout 1000 --psize 84 -Q 46 1.1.1.1" 'tos 0x2e' 'length 84'
|
||||
capture_psize_tos psize_tos_tcp4 'TCPv4 psize/tos packet capture' '1.1.1.1' "\"${BIN}\" --no-color -T -q 1 -m 1 --timeout 1000 --psize 84 -Q 46 1.1.1.1" 'tos 0x2e' 'length 84'
|
||||
capture_psize_tos psize_tos_icmp4 'ICMPv4 psize/tos packet capture' '1.1.1.1' "\"${BIN}\" --traceroute --no-color -q 1 -m 1 --timeout 1000 --psize 84 -Q 46 1.1.1.1" 'tos 0x2e' 'length 84'
|
||||
capture_psize_tos psize_tos_udp4 'UDPv4 psize/tos packet capture' '1.1.1.1' "\"${BIN}\" --traceroute --no-color -U -q 1 -m 1 --timeout 1000 --psize 84 -Q 46 1.1.1.1" 'tos 0x2e' 'length 84'
|
||||
capture_psize_tos psize_tos_tcp4 'TCPv4 psize/tos packet capture' '1.1.1.1' "\"${BIN}\" --traceroute --no-color -T -q 1 -m 1 --timeout 1000 --psize 84 -Q 46 1.1.1.1" 'tos 0x2e' 'length 84'
|
||||
if (( IPV6_AVAILABLE )); then
|
||||
capture_psize_tos psize_tos_icmp6 'ICMPv6 psize/tos packet capture' '2606:4700:4700::1111' "\"${BIN}\" --no-color -6 -q 1 -m 1 --timeout 1000 --psize 84 -Q 46 2606:4700:4700::1111" 'class 0x2e' 'payload length: 44'
|
||||
capture_psize_tos psize_tos_udp6 'UDPv6 psize/tos packet capture' '2606:4700:4700::1111' "\"${BIN}\" --no-color -6 -U -q 1 -m 1 --timeout 1000 --psize 84 -Q 46 2606:4700:4700::1111" 'class 0x2e' 'payload length: 44'
|
||||
capture_psize_tos psize_tos_tcp6 'TCPv6 psize/tos packet capture' '2606:4700:4700::1111' "\"${BIN}\" --no-color -6 -T -q 1 -m 1 --timeout 1000 --psize 84 -Q 46 2606:4700:4700::1111" 'class 0x2e' 'payload length: 44'
|
||||
capture_psize_tos psize_tos_icmp6 'ICMPv6 psize/tos packet capture' '2606:4700:4700::1111' "\"${BIN}\" --traceroute --no-color -6 -q 1 -m 1 --timeout 1000 --psize 84 -Q 46 2606:4700:4700::1111" 'class 0x2e' 'payload length: 44'
|
||||
capture_psize_tos psize_tos_udp6 'UDPv6 psize/tos packet capture' '2606:4700:4700::1111' "\"${BIN}\" --traceroute --no-color -6 -U -q 1 -m 1 --timeout 1000 --psize 84 -Q 46 2606:4700:4700::1111" 'class 0x2e' 'payload length: 44'
|
||||
capture_psize_tos psize_tos_tcp6 'TCPv6 psize/tos packet capture' '2606:4700:4700::1111' "\"${BIN}\" --traceroute --no-color -6 -T -q 1 -m 1 --timeout 1000 --psize 84 -Q 46 2606:4700:4700::1111" 'class 0x2e' 'payload length: 44'
|
||||
else
|
||||
record_ipv6_skip psize_tos_icmp6 'ICMPv6 psize/tos packet capture'
|
||||
record_ipv6_skip psize_tos_udp6 'UDPv6 psize/tos packet capture'
|
||||
|
||||
@@ -710,20 +710,20 @@ finally {
|
||||
Pop-Location
|
||||
}
|
||||
|
||||
$icmp4Capability = Get-CapabilityStatus -Name "icmp4" -Label "ICMPv4 tracing" -Command "`"$Bin`" --no-color -q 1 -m 1 --timeout 1000 1.1.1.1" -SuccessPattern "hops max, .*ICMP mode"
|
||||
$tcp4Capability = Get-CapabilityStatus -Name "tcp4" -Label "TCPv4 tracing" -Command "`"$Bin`" --no-color -T -q 1 -m 1 --timeout 1000 1.1.1.1" -SuccessPattern "hops max, .*TCP mode"
|
||||
$udp4Capability = Get-CapabilityStatus -Name "udp4" -Label "UDPv4 tracing" -Command "`"$Bin`" --no-color -U -q 1 -m 1 --timeout 1000 1.1.1.1" -SuccessPattern "hops max, .*UDP mode"
|
||||
$icmp4Capability = Get-CapabilityStatus -Name "icmp4" -Label "ICMPv4 tracing" -Command "`"$Bin`" --traceroute --no-color -q 1 -m 1 --timeout 1000 1.1.1.1" -SuccessPattern "hops max, .*ICMP mode"
|
||||
$tcp4Capability = Get-CapabilityStatus -Name "tcp4" -Label "TCPv4 tracing" -Command "`"$Bin`" --traceroute --no-color -T -q 1 -m 1 --timeout 1000 1.1.1.1" -SuccessPattern "hops max, .*TCP mode"
|
||||
$udp4Capability = Get-CapabilityStatus -Name "udp4" -Label "UDPv4 tracing" -Command "`"$Bin`" --traceroute --no-color -U -q 1 -m 1 --timeout 1000 1.1.1.1" -SuccessPattern "hops max, .*UDP mode"
|
||||
$mtrCapability = Get-CapabilityStatus -Name "mtr" -Label "MTR ICMP tracing" -Command "`"$Bin`" --no-color -r -q 1 -i 300 --timeout 1000 -m 2 1.1.1.1" -SuccessPattern "(?m)^HOST:"
|
||||
$mtuCapability = Get-CapabilityStatus -Name "mtu" -Label "MTU tracing" -Command "`"$Bin`" --no-color --mtu --timeout 1000 -q 1 -m 1 1.1.1.1" -SuccessPattern "Path MTU:"
|
||||
$globalpingCapability = Get-CapabilityStatus -Name "globalping" -Label "Globalping tracing" -Command "`"$Bin`" --no-color --json --from Germany -q 1 -m 1 --timeout 1000 1.1.1.1" -SuccessPattern '^\s*\{'
|
||||
$globalpingCapability = Get-CapabilityStatus -Name "globalping" -Label "Globalping tracing" -Command "`"$Bin`" --traceroute --no-color --json --from Germany -q 1 -m 1 --timeout 1000 1.1.1.1" -SuccessPattern '^\s*\{'
|
||||
$speedCapability = Get-CapabilityStatus -Name "speed" -Label "speed mode" -Command "`"$Bin`" --speed --help" -SuccessPattern "--speed-provider"
|
||||
$tinyCliCapability = Get-CapabilityStatus -Name "tiny_cli" -Label "nexttrace-tiny CLI" -Command "`"$Tiny`" --help" -SuccessPattern "--help"
|
||||
$ntrCliCapability = Get-CapabilityStatus -Name "ntr_cli" -Label "ntr CLI" -Command "`"$Ntr`" --help" -SuccessPattern "--help"
|
||||
|
||||
if ($IPv6Available) {
|
||||
$icmp6Capability = Get-CapabilityStatus -Name "icmp6" -Label "ICMPv6 tracing" -Command "`"$Bin`" --no-color -6 -q 1 -m 1 --timeout 1000 2606:4700:4700::1111" -SuccessPattern "hops max, .*ICMP mode"
|
||||
$tcp6Capability = Get-CapabilityStatus -Name "tcp6" -Label "TCPv6 tracing" -Command "`"$Bin`" --no-color -6 -T -q 1 -m 1 --timeout 1000 2606:4700:4700::1111" -SuccessPattern "hops max, .*TCP mode"
|
||||
$udp6Capability = Get-CapabilityStatus -Name "udp6" -Label "UDPv6 tracing" -Command "`"$Bin`" --no-color -6 -U -q 1 -m 1 --timeout 1000 2606:4700:4700::1111" -SuccessPattern "hops max, .*UDP mode"
|
||||
$icmp6Capability = Get-CapabilityStatus -Name "icmp6" -Label "ICMPv6 tracing" -Command "`"$Bin`" --traceroute --no-color -6 -q 1 -m 1 --timeout 1000 2606:4700:4700::1111" -SuccessPattern "hops max, .*ICMP mode"
|
||||
$tcp6Capability = Get-CapabilityStatus -Name "tcp6" -Label "TCPv6 tracing" -Command "`"$Bin`" --traceroute --no-color -6 -T -q 1 -m 1 --timeout 1000 2606:4700:4700::1111" -SuccessPattern "hops max, .*TCP mode"
|
||||
$udp6Capability = Get-CapabilityStatus -Name "udp6" -Label "UDPv6 tracing" -Command "`"$Bin`" --traceroute --no-color -6 -U -q 1 -m 1 --timeout 1000 2606:4700:4700::1111" -SuccessPattern "hops max, .*UDP mode"
|
||||
}
|
||||
else {
|
||||
$icmp6Capability = [pscustomobject]@{ Supported = $false; Reason = $IPv6Reason }
|
||||
@@ -731,47 +731,54 @@ else {
|
||||
$udp6Capability = [pscustomobject]@{ Supported = $false; Reason = $IPv6Reason }
|
||||
}
|
||||
|
||||
Run-CmdIfSupported $icmp4Capability.Supported $icmp4Capability.Reason "icmp4_basic" "ICMP IPv4 basic trace" "`"$Bin`" --no-color -q 1 -m 3 --timeout 1000 1.1.1.1" "hops max, .*ICMP mode"
|
||||
Run-CmdIfSupported $tcp4Capability.Supported $tcp4Capability.Reason "tcp4_basic" "TCP IPv4 basic trace" "`"$Bin`" --no-color -T -q 1 -m 3 --timeout 1000 1.1.1.1" "hops max, .*TCP mode"
|
||||
Run-CmdIfSupported $udp4Capability.Supported $udp4Capability.Reason "udp4_basic" "UDP IPv4 basic trace" "`"$Bin`" --no-color -U -q 1 -m 3 --timeout 1000 1.1.1.1" "hops max, .*UDP mode"
|
||||
Run-CmdIfSupported $icmp6Capability.Supported $icmp6Capability.Reason "icmp6_basic" "ICMP IPv6 basic trace" "`"$Bin`" --no-color -6 -q 1 -m 3 --timeout 1000 2606:4700:4700::1111" "hops max, .*ICMP mode"
|
||||
Run-CmdIfSupported $tcp6Capability.Supported $tcp6Capability.Reason "tcp6_basic" "TCP IPv6 basic trace" "`"$Bin`" --no-color -6 -T -q 1 -m 3 --timeout 1000 2606:4700:4700::1111" "hops max, .*TCP mode"
|
||||
Run-CmdIfSupported $udp6Capability.Supported $udp6Capability.Reason "udp6_basic" "UDP IPv6 basic trace" "`"$Bin`" --no-color -6 -U -q 1 -m 3 --timeout 1000 2606:4700:4700::1111" "hops max, .*UDP mode"
|
||||
Run-CmdIfSupported $icmp4Capability.Supported $icmp4Capability.Reason "raw_output" "Raw hop rows" "`"$Bin`" --no-color --raw -q 1 -m 2 --timeout 1000 1.1.1.1" "(?m)^1\|"
|
||||
Run-CmdIfSupported $icmp4Capability.Supported $icmp4Capability.Reason "classic_output" "Classic printer" "`"$Bin`" --no-color --classic -q 1 -m 2 --timeout 1000 1.1.1.1" "hops max, .*ICMP mode"
|
||||
Run-CmdIfSupported $icmp4Capability.Supported $icmp4Capability.Reason "route_path" "Route-path summary" "`"$Bin`" --no-color --route-path -q 1 -m 2 --timeout 1000 1.1.1.1" "Route-Path|hops max, .*ICMP mode"
|
||||
Run-CmdIfSupported $icmp4Capability.Supported $icmp4Capability.Reason "provider_lang" "IP.SB + sakura + en" "`"$Bin`" --no-color -q 1 -m 2 --timeout 1000 --data-provider IP.SB --pow-provider sakura --language en 1.1.1.1" "hops max, .*ICMP mode"
|
||||
Run-CmdIfSupported $icmp4Capability.Supported $icmp4Capability.Reason "dot_resolver" "DoT resolver via aliyun" "`"$Bin`" --no-color --dot-server aliyun -q 1 -m 1 --timeout 1000 ipv4.pek-4134.endpoint.nxtrace.org" "hops max, .*ICMP mode"
|
||||
Run-CmdIfSupported $icmp4Capability.Supported $icmp4Capability.Reason "disable_geoip" "disable-geoip path" "`"$Bin`" --no-color --data-provider disable-geoip -M -q 1 -m 2 --timeout 1000 1.1.1.1" "hops max, .*ICMP mode"
|
||||
Run-CmdIfSupported $icmp4Capability.Supported $icmp4Capability.Reason "dn42_mode" "DN42 mode switch" "`"$Bin`" --no-color --dn42 -q 1 -m 2 --timeout 1000 1.1.1.1" "hops max, .*ICMP mode"
|
||||
Check-JsonPureIfSupported $icmp4Capability.Supported $icmp4Capability.Reason "json_trace" "Traceroute JSON stdout purity" "`"$Bin`" --no-color --json -q 1 -m 3 --timeout 1000 1.1.1.1"
|
||||
Run-CmdIfSupported $icmp4Capability.Supported $icmp4Capability.Reason "default_trace" "Default remains traditional" "`"$Bin`" --no-color -q 1 -m 1 --timeout 1000 1.1.1.1" "hops max, .*ICMP mode"
|
||||
Run-CmdIfSupported $icmp4Capability.Supported $icmp4Capability.Reason "default_raw" "Bare RAW remains traditional" "`"$Bin`" --raw --no-color -q 1 -m 1 --timeout 1000 1.1.1.1" "hops max, .*ICMP mode"
|
||||
Run-CmdIfSupported $icmp4Capability.Supported $icmp4Capability.Reason "traceroute_short" "Short traditional flag" "`"$Bin`" -k --no-color -q 1 -m 1 --timeout 1000 1.1.1.1" "hops max, .*ICMP mode"
|
||||
Run-CmdIfSupported -Supported $true -Reason "" -Name "traceroute_mtr_conflict" -Note "Explicit modes conflict before probing" -Command "`"$Bin`" -k --mtr 1.1.1.1" -SuccessPattern "cannot be combined" -ForbiddenPattern "hops max|HOST:" -AllowedExitCodes @(1)
|
||||
Run-CmdIfSupported $icmp4Capability.Supported $icmp4Capability.Reason "icmp4_basic" "ICMP IPv4 basic trace" "`"$Bin`" --traceroute --no-color -q 1 -m 3 --timeout 1000 1.1.1.1" "hops max, .*ICMP mode"
|
||||
Run-CmdIfSupported $tcp4Capability.Supported $tcp4Capability.Reason "tcp4_basic" "TCP IPv4 basic trace" "`"$Bin`" --traceroute --no-color -T -q 1 -m 3 --timeout 1000 1.1.1.1" "hops max, .*TCP mode"
|
||||
Run-CmdIfSupported $udp4Capability.Supported $udp4Capability.Reason "udp4_basic" "UDP IPv4 basic trace" "`"$Bin`" --traceroute --no-color -U -q 1 -m 3 --timeout 1000 1.1.1.1" "hops max, .*UDP mode"
|
||||
Run-CmdIfSupported $icmp6Capability.Supported $icmp6Capability.Reason "icmp6_basic" "ICMP IPv6 basic trace" "`"$Bin`" --traceroute --no-color -6 -q 1 -m 3 --timeout 1000 2606:4700:4700::1111" "hops max, .*ICMP mode"
|
||||
Run-CmdIfSupported $tcp6Capability.Supported $tcp6Capability.Reason "tcp6_basic" "TCP IPv6 basic trace" "`"$Bin`" --traceroute --no-color -6 -T -q 1 -m 3 --timeout 1000 2606:4700:4700::1111" "hops max, .*TCP mode"
|
||||
Run-CmdIfSupported $udp6Capability.Supported $udp6Capability.Reason "udp6_basic" "UDP IPv6 basic trace" "`"$Bin`" --traceroute --no-color -6 -U -q 1 -m 3 --timeout 1000 2606:4700:4700::1111" "hops max, .*UDP mode"
|
||||
Run-CmdIfSupported $icmp4Capability.Supported $icmp4Capability.Reason "raw_output" "Raw hop rows" "`"$Bin`" --traceroute --no-color --raw -q 1 -m 2 --timeout 1000 1.1.1.1" "(?m)^1\|"
|
||||
Run-CmdIfSupported $icmp4Capability.Supported $icmp4Capability.Reason "classic_output" "Classic printer" "`"$Bin`" --traceroute --no-color --classic -q 1 -m 2 --timeout 1000 1.1.1.1" "hops max, .*ICMP mode"
|
||||
Run-CmdIfSupported $icmp4Capability.Supported $icmp4Capability.Reason "route_path" "Route-path summary" "`"$Bin`" --traceroute --no-color --route-path -q 1 -m 2 --timeout 1000 1.1.1.1" "Route-Path|hops max, .*ICMP mode"
|
||||
Run-CmdIfSupported $icmp4Capability.Supported $icmp4Capability.Reason "provider_lang" "IP.SB + sakura + en" "`"$Bin`" --traceroute --no-color -q 1 -m 2 --timeout 1000 --data-provider IP.SB --pow-provider sakura --language en 1.1.1.1" "hops max, .*ICMP mode"
|
||||
Run-CmdIfSupported $icmp4Capability.Supported $icmp4Capability.Reason "dot_resolver" "DoT resolver via aliyun" "`"$Bin`" --traceroute --no-color --dot-server aliyun -q 1 -m 1 --timeout 1000 ipv4.pek-4134.endpoint.nxtrace.org" "hops max, .*ICMP mode"
|
||||
Run-CmdIfSupported $icmp4Capability.Supported $icmp4Capability.Reason "disable_geoip" "disable-geoip path" "`"$Bin`" --traceroute --no-color --data-provider disable-geoip -M -q 1 -m 2 --timeout 1000 1.1.1.1" "hops max, .*ICMP mode"
|
||||
Run-CmdIfSupported $icmp4Capability.Supported $icmp4Capability.Reason "dn42_mode" "DN42 mode switch" "`"$Bin`" --traceroute --no-color --dn42 -q 1 -m 2 --timeout 1000 1.1.1.1" "hops max, .*ICMP mode"
|
||||
Check-JsonPureIfSupported $icmp4Capability.Supported $icmp4Capability.Reason "json_trace" "Traceroute JSON stdout purity" "`"$Bin`" --traceroute --no-color --json -q 1 -m 3 --timeout 1000 1.1.1.1"
|
||||
Check-JsonPureIfSupported $mtuCapability.Supported $mtuCapability.Reason "json_mtu" "MTU JSON stdout purity" "`"$Bin`" --no-color --mtu --json --timeout 1000 -q 1 -m 3 1.1.1.1"
|
||||
Check-JsonPureIfSupported $globalpingCapability.Supported $globalpingCapability.Reason "json_globalping" "Globalping JSON stdout purity" "`"$Bin`" --no-color --json --from Germany -q 1 -m 3 --timeout 1000 1.1.1.1"
|
||||
Run-CmdIfSupported $icmp4Capability.Supported $icmp4Capability.Reason "table_non_tty" "Table output smoke" "`"$Bin`" --no-color --table -q 1 -m 2 --timeout 1000 1.1.1.1" "(?m)^Hop\s+IP\s+Latency"
|
||||
Check-OutputFileIfSupported $icmp4Capability.Supported $icmp4Capability.Reason "output_custom" "Custom output file path" "`"$Bin`" --no-color -q 1 -m 2 --timeout 1000 -o `"$ArtifactsRoot\custom.log`" 1.1.1.1" (Join-Path $ArtifactsRoot "custom.log")
|
||||
Check-OutputFileIfSupported $icmp4Capability.Supported $icmp4Capability.Reason "output_default" "Default output file path" "set TEMP=$DefaultTmp && set TMP=$DefaultTmp && `"$Bin`" --no-color -q 1 -m 2 --timeout 1000 -O 1.1.1.1" $DefaultLog
|
||||
Check-JsonPureIfSupported $globalpingCapability.Supported $globalpingCapability.Reason "json_globalping" "Globalping JSON stdout purity" "`"$Bin`" --traceroute --no-color --json --from Germany -q 1 -m 3 --timeout 1000 1.1.1.1"
|
||||
Run-CmdIfSupported $icmp4Capability.Supported $icmp4Capability.Reason "table_non_tty" "Table output smoke" "`"$Bin`" --traceroute --no-color --table -q 1 -m 2 --timeout 1000 1.1.1.1" "(?m)^Hop\s+IP\s+Latency"
|
||||
Check-OutputFileIfSupported $icmp4Capability.Supported $icmp4Capability.Reason "output_custom" "Custom output file path" "`"$Bin`" --traceroute --no-color -q 1 -m 2 --timeout 1000 -o `"$ArtifactsRoot\custom.log`" 1.1.1.1" (Join-Path $ArtifactsRoot "custom.log")
|
||||
Check-OutputFileIfSupported $icmp4Capability.Supported $icmp4Capability.Reason "output_default" "Default output file path" "set TEMP=$DefaultTmp && set TMP=$DefaultTmp && `"$Bin`" --traceroute --no-color -q 1 -m 2 --timeout 1000 -O 1.1.1.1" $DefaultLog
|
||||
Run-CmdIfSupported $mtuCapability.Supported $mtuCapability.Reason "mtu_text" "MTU text mode" "`"$Bin`" --no-color --mtu --timeout 1000 -q 1 -m 3 1.1.1.1" "Path MTU:"
|
||||
Write-Record mtu_tty_color SKIP "MTU TTY colorized output; no portable Windows PTY capture in this script"
|
||||
Run-CmdIfSupported $mtuCapability.Supported $mtuCapability.Reason "mtu_non_tty_plain" "MTU non-TTY output has no ANSI" "`"$Bin`" --mtu --timeout 1000 -q 1 -m 3 1.1.1.1" "Path MTU:" "\x1b\[[0-9;]*[A-Za-z]"
|
||||
Run-CmdIfSupported $mtrCapability.Supported $mtrCapability.Reason "mtr_report" "MTR report ICMP" "`"$Bin`" --no-color -r -q 2 -i 300 --timeout 1000 -m 4 1.1.1.1" "(?m)^HOST:"
|
||||
Run-CmdIfSupported $mtrCapability.Supported $mtrCapability.Reason "mtr_wide" "MTR wide + show-ips" "`"$Bin`" --no-color -w --show-ips -q 2 -i 300 --timeout 1000 -m 4 1.1.1.1" "(?m)^HOST:"
|
||||
Run-CmdIfSupported $mtrCapability.Supported $mtrCapability.Reason "mtr_raw" "MTR raw stream" "`"$Bin`" --no-color -r --raw -q 2 -i 300 --timeout 1000 -m 4 1.1.1.1" "(?m)^1\|"
|
||||
Run-CmdIfSupported $icmp4Capability.Supported $icmp4Capability.Reason "fast_trace_file" "Fast trace via --file" "`"$Bin`" --no-color --file `"$Targets`" -q 1 -m 2 --timeout 1000" "traceroute to "
|
||||
Run-CmdIfSupported $icmp4Capability.Supported $icmp4Capability.Reason "fast_trace_file" "Fast trace via --file" "`"$Bin`" --traceroute --no-color --file `"$Targets`" -q 1 -m 2 --timeout 1000" "traceroute to "
|
||||
Run-CmdIfSupported -Supported $speedCapability.Supported -Reason $speedCapability.Reason -Name "help_speed_main" -Note "Main help exposes only top-level speed entry" -Command "`"$Bin`" --help" -SuccessPattern "--speed" -ForbiddenPattern "--speed-provider"
|
||||
Run-CmdIfSupported -Supported $speedCapability.Supported -Reason $speedCapability.Reason -Name "help_speed_detail" -Note "Speed help is dedicated and detailed" -Command "`"$Bin`" --speed --help" -SuccessPattern "--speed-provider" -ForbiddenPattern "hops max, .*ICMP mode"
|
||||
Check-JsonPureIfSupported -Supported $speedCapability.Supported -Reason $speedCapability.Reason -Name "speed_apple_json" -Note "Apple speed JSON path" -Command "`"$Bin`" --speed --json --no-metadata --non-interactive --max 64KiB --timeout 2000 --threads 2 --latency-count 2" -ExpectedJsonPattern '"provider":"apple"' -AllowedExitCodes @(0, 2)
|
||||
Check-JsonPureIfSupported -Supported $speedCapability.Supported -Reason $speedCapability.Reason -Name "speed_cloudflare_json" -Note "Cloudflare speed JSON path" -Command "`"$Bin`" --speed --speed-provider cloudflare --json --no-metadata --non-interactive --max 64KiB --timeout 2000 --threads 2 --latency-count 2" -ExpectedJsonPattern '"provider":"cloudflare"' -AllowedExitCodes @(0, 2)
|
||||
Run-CmdIfSupported $icmp4Capability.Supported $icmp4Capability.Reason "tiny_smoke" "nexttrace-tiny smoke" "`"$Tiny`" --no-color -q 1 -m 2 --timeout 1000 1.1.1.1" "hops max, .*ICMP mode"
|
||||
Run-CmdIfSupported $icmp4Capability.Supported $icmp4Capability.Reason "tiny_smoke" "nexttrace-tiny smoke" "`"$Tiny`" --traceroute --no-color -q 1 -m 2 --timeout 1000 1.1.1.1" "hops max, .*ICMP mode"
|
||||
Run-CmdIfSupported $icmp4Capability.Supported $icmp4Capability.Reason "tiny_default" "Tiny default remains traditional" "`"$Tiny`" --no-color -q 1 -m 1 --timeout 1000 1.1.1.1" "hops max, .*ICMP mode"
|
||||
Run-CmdIfSupported $mtrCapability.Supported $mtrCapability.Reason "tiny_mtr_report" "Tiny finite MTR report" "`"$Tiny`" --no-color -r --data-provider disable-geoip -n -q 2 -i 300 --timeout 1000 -m 2 1.1.1.1" "(?m)^HOST:"
|
||||
Run-CmdIfSupported $mtrCapability.Supported $mtrCapability.Reason "tiny_mtr_raw" "Tiny finite MTR RAW" "`"$Tiny`" --no-color --mtr --raw --data-provider disable-geoip -n -q 2 -i 300 --timeout 1000 -m 2 1.1.1.1" "(?m)^1\|"
|
||||
Run-CmdIfSupported $mtrCapability.Supported $mtrCapability.Reason "ntr_report" "ntr report smoke" "`"$Ntr`" --no-color -r -q 2 -i 300 --timeout 1000 -m 4 1.1.1.1" "(?m)^HOST:"
|
||||
Run-CmdIfSupported -Supported $tinyCliCapability.Supported -Reason $tinyCliCapability.Reason -Name "tiny_speed_reject" -Note "nexttrace-tiny rejects --speed" -Command "`"$Tiny`" --speed" -SuccessPattern "--speed is not available" -ForbiddenPattern "panic|goroutine [0-9]+|stack trace" -AllowedExitCodes @(1)
|
||||
Run-CmdIfSupported -Supported $ntrCliCapability.Supported -Reason $ntrCliCapability.Reason -Name "ntr_speed_reject" -Note "ntr rejects --speed" -Command "`"$Ntr`" --speed" -SuccessPattern "--speed is not available" -ForbiddenPattern "panic|goroutine [0-9]+|stack trace" -AllowedExitCodes @(1)
|
||||
|
||||
Check-PacketCaptureIfSupported $icmp4Capability.Supported $icmp4Capability.Reason "psize_tos_icmp4" "ICMPv4 psize/tos packet capture" "`"$Bin`" --no-color -q 1 -m 1 --timeout 1000 --psize 84 -Q 46 1.1.1.1" "1.1.1.1" "host 1.1.1.1" "Differentiated Services Field: 0x2e" "Total Length: 84"
|
||||
Check-PacketCaptureIfSupported $udp4Capability.Supported $udp4Capability.Reason "psize_tos_udp4" "UDPv4 psize/tos packet capture" "`"$Bin`" --no-color -U -q 1 -m 1 --timeout 1000 --psize 84 -Q 46 1.1.1.1" "1.1.1.1" "host 1.1.1.1" "Differentiated Services Field: 0x2e" "Total Length: 84"
|
||||
Check-PacketCaptureIfSupported $tcp4Capability.Supported $tcp4Capability.Reason "psize_tos_tcp4" "TCPv4 psize/tos packet capture" "`"$Bin`" --no-color -T -q 1 -m 1 --timeout 1000 --psize 84 -Q 46 1.1.1.1" "1.1.1.1" "host 1.1.1.1" "Differentiated Services Field: 0x2e" "Total Length: 84"
|
||||
Check-PacketCaptureIfSupported $icmp6Capability.Supported $icmp6Capability.Reason "psize_tos_icmp6" "ICMPv6 psize/tos packet capture" "`"$Bin`" --no-color -6 -q 1 -m 1 --timeout 1000 --psize 84 -Q 46 2606:4700:4700::1111" "2606:4700:4700::1111" "host 2606:4700:4700::1111" "Traffic Class: 0x2e" "Payload Length: 44"
|
||||
Check-PacketCaptureIfSupported $udp6Capability.Supported $udp6Capability.Reason "psize_tos_udp6" "UDPv6 psize/tos packet capture" "`"$Bin`" --no-color -6 -U -q 1 -m 1 --timeout 1000 --psize 84 -Q 46 2606:4700:4700::1111" "2606:4700:4700::1111" "host 2606:4700:4700::1111" "Traffic Class: 0x2e" "Payload Length: 44"
|
||||
Check-PacketCaptureIfSupported $tcp6Capability.Supported $tcp6Capability.Reason "psize_tos_tcp6" "TCPv6 psize/tos packet capture" "`"$Bin`" --no-color -6 -T -q 1 -m 1 --timeout 1000 --psize 84 -Q 46 2606:4700:4700::1111" "2606:4700:4700::1111" "host 2606:4700:4700::1111" "Traffic Class: 0x2e" "Payload Length: 44"
|
||||
Check-PacketCaptureIfSupported $icmp4Capability.Supported $icmp4Capability.Reason "psize_tos_icmp4" "ICMPv4 psize/tos packet capture" "`"$Bin`" --traceroute --no-color -q 1 -m 1 --timeout 1000 --psize 84 -Q 46 1.1.1.1" "1.1.1.1" "host 1.1.1.1" "Differentiated Services Field: 0x2e" "Total Length: 84"
|
||||
Check-PacketCaptureIfSupported $udp4Capability.Supported $udp4Capability.Reason "psize_tos_udp4" "UDPv4 psize/tos packet capture" "`"$Bin`" --traceroute --no-color -U -q 1 -m 1 --timeout 1000 --psize 84 -Q 46 1.1.1.1" "1.1.1.1" "host 1.1.1.1" "Differentiated Services Field: 0x2e" "Total Length: 84"
|
||||
Check-PacketCaptureIfSupported $tcp4Capability.Supported $tcp4Capability.Reason "psize_tos_tcp4" "TCPv4 psize/tos packet capture" "`"$Bin`" --traceroute --no-color -T -q 1 -m 1 --timeout 1000 --psize 84 -Q 46 1.1.1.1" "1.1.1.1" "host 1.1.1.1" "Differentiated Services Field: 0x2e" "Total Length: 84"
|
||||
Check-PacketCaptureIfSupported $icmp6Capability.Supported $icmp6Capability.Reason "psize_tos_icmp6" "ICMPv6 psize/tos packet capture" "`"$Bin`" --traceroute --no-color -6 -q 1 -m 1 --timeout 1000 --psize 84 -Q 46 2606:4700:4700::1111" "2606:4700:4700::1111" "host 2606:4700:4700::1111" "Traffic Class: 0x2e" "Payload Length: 44"
|
||||
Check-PacketCaptureIfSupported $udp6Capability.Supported $udp6Capability.Reason "psize_tos_udp6" "UDPv6 psize/tos packet capture" "`"$Bin`" --traceroute --no-color -6 -U -q 1 -m 1 --timeout 1000 --psize 84 -Q 46 2606:4700:4700::1111" "2606:4700:4700::1111" "host 2606:4700:4700::1111" "Traffic Class: 0x2e" "Payload Length: 44"
|
||||
Check-PacketCaptureIfSupported $tcp6Capability.Supported $tcp6Capability.Reason "psize_tos_tcp6" "TCPv6 psize/tos packet capture" "`"$Bin`" --traceroute --no-color -6 -T -q 1 -m 1 --timeout 1000 --psize 84 -Q 46 2606:4700:4700::1111" "2606:4700:4700::1111" "host 2606:4700:4700::1111" "Traffic Class: 0x2e" "Payload Length: 44"
|
||||
|
||||
$deployBaseUrl = $null
|
||||
$deployLog = Join-Path $ArtifactsDir "deploy_server.txt"
|
||||
|
||||
@@ -7,12 +7,14 @@ Fallback must preserve explicit user inputs: `target`, `protocol`, `port`, `sour
|
||||
## Local Traceroute
|
||||
|
||||
```bash
|
||||
nexttrace example.com
|
||||
nexttrace --tcp -p 443 example.com
|
||||
nexttrace --udp -p 33494 example.com
|
||||
nexttrace --json example.com
|
||||
nexttrace --traceroute example.com
|
||||
nexttrace --traceroute --tcp -p 443 example.com
|
||||
nexttrace --traceroute --udp -p 33494 example.com
|
||||
nexttrace --traceroute --json example.com
|
||||
```
|
||||
|
||||
Full and tiny builds support `-k/--traceroute` and optional MTR. Their default remains traditional traceroute in this release; the default and bare `--raw` will switch to MTR no earlier than 2027, in a separately announced release. Use `--traceroute --raw` to pin traditional RAW (12-column success rows, historical 8-column timeout rows). Detect `--traceroute` in `--help` before using it with older binaries; do not retry failed probes with different mode flags. Explicit traditional mode conflicts with MTR/report/wide and standalone DNS/MTU/speed/nali/deploy modes.
|
||||
|
||||
JSON includes optional `StopReason` with lowercase nested fields `hop`, `reason`, `responses`, and `markers`. `responses` contains human-readable descriptions; `markers` contains machine-readable codes. Use `reason` as the reachability conclusion; do not compare the last hop IP with the target.
|
||||
|
||||
Normal traceroute output precedence is `--json` > `--table` > `--classic` > `--raw` > `--output` > realtime. A higher-priority mode that overrides an explicit output file emits a warning on stderr.
|
||||
|
||||
Reference in new issue
Block a user