Commit Graph
1223 Commits
Author SHA1 Message Date
tsosunchia 9eff7aabf4 feat: introduce build variants for NextTrace with flavor options
- Added three build flavors: `nexttrace` (full), `nexttrace-tiny`, and `ntr` (MTR-focused).
- Updated README.md and README_zh_CN.md to reflect new build variants and their features.
- Implemented manual build instructions for each flavor.
- Enhanced command-line argument parsing to accommodate flavor-specific options.
- Disabled WebUI and Globalping features in `nexttrace-tiny` and `ntr` flavors.
- Created separate files for handling Globalping and WebUI functionality based on build flavor.
- Added error handling for unavailable features in non-full builds.
2026-03-05 22:05:38 +08:00
dependabot[bot] d67dcc320a chore(deps): bump github.com/mattn/go-runewidth from 0.0.16 to 0.0.20
Bumps [github.com/mattn/go-runewidth](https://github.com/mattn/go-runewidth) from 0.0.16 to 0.0.20.
- [Commits](https://github.com/mattn/go-runewidth/compare/v0.0.16...v0.0.20)

---
updated-dependencies:
- dependency-name: github.com/mattn/go-runewidth
  dependency-version: 0.0.20
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-03-03 07:44:56 +08:00
dependabot[bot] 9ea0d7220b chore(deps): bump actions/download-artifact from 7 to 8
Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 7 to 8.
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](https://github.com/actions/download-artifact/compare/v7...v8)

---
updated-dependencies:
- dependency-name: actions/download-artifact
  dependency-version: '8'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-03-03 07:44:56 +08:00
dependabot[bot] 014ec82e1c chore(deps): bump actions/upload-artifact from 6 to 7
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 6 to 7.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v6...v7)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-version: '7'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-03-03 07:44:56 +08:00
dependabot[bot] 9e62f9d22f chore(deps): bump github.com/gin-gonic/gin from 1.11.0 to 1.12.0
Bumps [github.com/gin-gonic/gin](https://github.com/gin-gonic/gin) from 1.11.0 to 1.12.0.
- [Release notes](https://github.com/gin-gonic/gin/releases)
- [Changelog](https://github.com/gin-gonic/gin/blob/master/CHANGELOG.md)
- [Commits](https://github.com/gin-gonic/gin/compare/v1.11.0...v1.12.0)

---
updated-dependencies:
- dependency-name: github.com/gin-gonic/gin
  dependency-version: 1.12.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-03-03 07:44:56 +08:00
tsosunchia cdf799a97c Merge pull request #346 from nxtrace/main
Enhance MTR mode with layout improvements and new features
2026-03-02 20:11:51 +08:00
tsosunchia 357c03604d feat: remove unnecessary -checklinkname flag from build scripts and documentation 2026-03-02 16:31:46 +08:00
tsosunchia 52b2dd6a88 Merge pull request #149 from jason-akw/patch-1
fix: enable CGO for Android to fix DNS resolution issues
2026-03-02 15:00:52 +08:00
Jason Huang bb2623e694 Merge branch 'main' into patch-1 2026-03-02 05:47:17 +08:00
Jason Huang ecec769dd1 fix: enable CGO for Android to fix DNS resolution issues
Switch to Android NDK toolchain, enable CGO for Android builds.

Already tested with Termux 0.118.3 with Xiaomi 15 Ultra (Android 16).
                  
Thanks to: https://dave.engineer/blog/2025/11/cross-compiling-go-android/
2026-03-02 05:44:13 +08:00
tsosunchia f131a99dc1 fix: 限制mtr模式最大跳数为 255,确保调度器稳定性 2026-03-02 00:23:17 +08:00
tsosunchia efb437fbac fix: improve error handling and logging across multiple packages
- Enhanced error handling in `mtr_ui.go` to log warnings when raw mode cannot be enabled.
- Updated `geofeed.go` to return a more informative error instead of panicking when geofeed data cannot be loaded.
- Refined error handling in `ptr.go` to return an error if `ptrPath` is not configured.
- Improved error handling in `fast_trace.go` for network interface address retrieval.
- Added error checks in `chunzhen.go` and `ipapicom.go` for HTTP request creation and response reading.
- Enhanced error handling in `ipdbone.go` to return descriptive errors for authentication failures.
- Updated `ipfilter.go` to ensure proper IP parsing before filtering.
- Improved error handling in `ipinfoLocal.go` for database access and record parsing.
- Enhanced error handling in `ipsb.go` for HTTP request creation and response reading.
- Added checks for closed channels in `leo.go` to prevent panics.
- Improved panic recovery in `ws_handler.go` to log errors in the write loop.
- Added read deadline to WebSocket connections in `ws_handler.go` to prevent blocking.
- Enhanced configuration checks in `globalping.go` to avoid nil pointer dereferences.
- Improved error logging in `icmp_ipv4.go` and `icmp_ipv6.go` for send errors.
- Enhanced error handling in `icmp_darwin.go`, `icmp_unix.go`, and `icmp_windows.go` for checksum setting.
- Improved error handling in TCP and UDP implementations across various platforms for checksum settings.
- Enhanced error handling in `tracemap.go` for proxy configuration.
- Improved type assertions in `util.go` for DNS cache lookups.
2026-03-02 00:14:49 +08:00
tsosunchia 3a6ba0a99e fix(web-mtr): 修复 Per-Hop 并发下超发残影与长持锁阻塞问题
- 修复 WebSocket MTR per-hop 路径中 traceMu 长时间持锁,改为仅初始化阶段短暂加锁,避免持续探测期间阻塞其他请求
- 新增 hop_interval_ms 请求字段,保留 interval_ms 兼容,并按 hop_interval_ms -> interval_ms -> 1000ms 回退
- 前端新增 knownFinalTTL 截断逻辑:命中目标 TTL 后下调水标并清理高 TTL 过期行,拦截后续高 TTL 迟到数据
- 在 clearResult(resetState) 中重置截断水标,避免会话间状态污染
- 新增前端截断行为测试,覆盖下调、剪枝、丢弃与重置场景
- 回归通过:前端聚合测试、Go 构建与现有测试集均通过
2026-03-01 22:38:33 +08:00
tsosunchia 89ce9a660d feat: 增强 MTR 调度器,支持每跳多个并发探测,优化超时处理和统计逻辑 2026-03-01 20:20:25 +08:00
tsosunchia ad3ecbd401 fix: 统一处理 context.Canceled 错误检查,确保一致性
feat(ipgeo): 在 API 请求中添加 defer 关闭响应体
fix: 修复 MTR 模式中错误处理逻辑,确保资源正确释放
test: 更新测试用例以验证 context.Canceled 错误处理
refactor: 优化 mplsSet 初始化逻辑
test: 修改测试断言为 require,增强错误处理
2026-03-01 19:24:20 +08:00
tsosunchia e63c4159c1 fix(trace): 优化 CanonicalHostname 函数,简化去掉尾点的逻辑 2026-03-01 18:51:43 +08:00
tsosunchia 7ca42c97bb feat(go.mod): 更新依赖项,添加 go-runewidth 和 x/term,移除 indirect 依赖 2026-03-01 18:48:26 +08:00
tsosunchia 8ef2caa6de feat(tests): 增加多个单元测试以验证 IP 地址过滤和处理功能 2026-03-01 17:05:47 +08:00
tsosunchia f95cce8312 feat(cmd): 更新命令行参数帮助信息,明确 -z/--send-time 在 MTR 模式下被忽略 2026-03-01 05:08:28 +08:00
tsosunchia 361e14a27d feat(mtr): 更新 MTR 模式参数,调整每跳探测间隔,忽略 -z/--send-time,新增 MPLS 显示切换功能 2026-03-01 04:58:49 +08:00
tsosunchia c8323b97cc feat(mtr): 实现 ClearHop 方法以清除过期聚合数据,避免 ghost row 并防止 Snt 膨胀 2026-03-01 03:36:55 +08:00
tsosunchia 7e2226f186 feat(mtr): discard over-final TTL destination replies and remove Round label from CLI output
remove higher-TTL destination folding after final TTL is known
discard disabled TTL results before accounting/callback/lowering
keep lowering + MigrateStats behavior unchanged
drop "Round:" from TUI status line and table fallback
add regressions for late over-final replies and raw emission fidelity
2026-03-01 03:15:36 +08:00
tsosunchia 92e93ff0d4 feat(mtr): 压缩 TUI 指标区、折叠高 TTL 目标、重排显示模式并新增 -y/--ipinfo
本次修改仅影响 CLI 下的 MTR TUI 模式,不涉及 --report/--wide/--raw、普通 traceroute 或 Web MTR。

主要变更:
- 指标区压缩:将 Loss% 列宽缩至 5、Snt 缩至 3、RTT 五列缩至 7,列名不变,双行表头仍保留,提高 Host 列宽度。
- 目标折叠:目标在某个 TTL 确认后,后续更高 TTL 的 dst‑ip 响应不再单独显示,而是折叠到最终 TTL;折叠后 Snt 不得超过 MaxPerHop,超出部分丢弃;调度器区分 originTTL/accountTTL,disabled TTL 的 dst‑ip 回复允许折叠。
- 显示模式扩展:新增 HostModeBase (0),五档依次为 IP/PTR、ASN、City、Owner、Full;默认显示 IP/PTR。`y` 键循环顺序调整为 0→1→2→3→4→0。
- 新增 CLI 参数 `-y, --ipinfo` (0..4) 用于设置 TUI 初始显示模式;在 --report/--wide/--raw 中可解析但被忽略;非法值报错。
- `runMTRTUI`/`newMTRUI` 支持传入初始 mode,`r` 键重置统计不再影响显示模式。
- 当 mode ≥ ASN 且无 ASN 时插入 `AS???` 占位符;Base 模式不显示占位符。
- 更新 CLI 帮助、README 与 README_zh_CN 文档,说明新的默认模式、y 键循环和 `-y/--ipinfo` 映射关系。
- 新增或调整单元测试,覆盖显示模式循环、默认与初始值、参数校验与忽略逻辑、主机信息渲染、紧凑布局以及目标折叠等场景。

非目标:report/wide/raw 模式、Web MTR 和普通 traceroute。
2026-03-01 02:03:56 +08:00
tsosunchia 233d4eea5d Implement per-hop independent MTR scheduler and associated tests
- Added `mtr_scheduler.go` to implement a per-hop independent scheduling mechanism for MTR (My Traceroute) probes.
- Introduced `mtrTTLProber` interface for probing TTLs and handling probe results.
- Implemented `runMTRScheduler` function to manage the scheduling of probes based on TTL, handle errors, and aggregate results.
- Added configuration options for hop intervals, maximum hops, and error handling.
- Created `mtr_scheduler_test.go` to include comprehensive unit tests for the scheduler, covering various scenarios such as maximum probes per hop, context cancellation, destination detection, error budgets, and reset functionality.
- Mocked TTL prober to simulate probe responses and track probe counts for testing.
2026-02-28 15:47:40 +08:00
tsosunchia df19f6b58a fix: CWE-117 2026-02-28 13:38:12 +08:00
tsosunchia 69f2ca680b feat: 更新文档和代码,增强 MTR 功能,优化 API 信息输出 2026-02-28 13:14:03 +08:00
tsosunchia e377c8c7b4 Adjust traceroute interval defaults 2026-02-28 12:53:36 +08:00
tsosunchia bd32808ceb Disable geo lookup for non wide MTR 2026-02-28 11:55:31 +08:00
tsosunchia c3bfb6c21e Revert MTR TUI host spacing 2026-02-28 11:49:13 +08:00
tsosunchia 1f2491f399 Fix frontend MTR flush scheduling 2026-02-28 11:24:22 +08:00
tsosunchia ea15375b5b feat: 增强 MTR 原始流式模式,添加 API 信息输出和 TTL 间隔控制 2026-02-28 11:09:06 +08:00
tsosunchia d41d8b2fba feat: Introduce MTR raw streaming functionality
- Added support for streaming probe-level MTR raw events via `trace.RunMTRRaw`.
- Implemented a new `mtrRawAggregator` to handle raw MTR data aggregation.
- Updated the web client to handle `mtr_raw` messages and render statistics accordingly.
- Introduced new JavaScript module `mtr_agg.js` for aggregating MTR raw data.
- Created new printer functions for formatting MTR raw records.
- Added tests for the new MTR raw functionality to ensure correct behavior.
- Deprecated the legacy snapshot aggregator for MTR.
2026-02-28 09:41:25 +08:00
tsosunchia 4bf6d68dc5 feat: 添加 --show-ips 选项以在 MTR 输出中同时显示 PTR 和 IP 地址 2026-02-28 01:23:17 +08:00
tsosunchia 0c0dc89a7d rename: claude.txt -> CLAUDE.md 2026-02-28 00:14:01 +08:00
tsosunchia a523cda440 feat: 更新 Go 版本至 1.26.0,调整构建和测试工作流,增强输入解析器 2026-02-28 00:13:21 +08:00
tsosunchia 5d12ac877b feat(mtr): 重构 MTR 指标格式化,添加等待状态处理和合并逻辑 2026-02-27 23:31:20 +08:00
tsosunchia 6c8912d78d feat(dns): 添加 Geo DNS 解析策略,支持 DoT 和系统 DNS 回退 2026-02-27 23:16:34 +08:00
tsosunchia b9a6b945e7 fix(tests): 修复测试代码格式,调整注释对齐 2026-02-27 22:30:49 +08:00
tsosunchia 39ab110f82 feat(tui): 增强 TUI 渲染,支持动态前缀宽度和 tab 感知对齐 2026-02-27 22:30:22 +08:00
tsosunchia ae08ec9796 fix(mtr): 提前冲突校验并修复 report 模式 CJK 对齐
- 将 MTR 冲突检查前移到所有 early-return 分支之前,避免 `-r --from`、`-t --fast-trace`、`--file` 等组合绕过校验
- report 输出改用 `go-runewidth` 计算显示宽度与截断(`StringWidth`/`Truncate`)
- 新增 `reportPadRight`,替换 `%*s` 对齐路径,修复中文场景下 HOST 与指标列错位
- 保持 wide/非 wide 逻辑不变,仅修复布局与参数校验时序
- tests: `go test -ldflags "-checklinkname=0" ./...`
2026-02-27 21:51:38 +08:00
tsosunchia 24224cf943 feat: Enhance MTR mode with source IP resolution and name mode toggle
- Removed the conflicting `--report` flag from MTR mode.
- Added `dataOrigin` parameter to `runMTRMode` for preferred API information.
- Implemented `resolveSrcIP` function to determine source IP based on priority.
- Introduced `nameMode` in `mtrUI` to toggle between PTR/IP and IP only display.
- Updated MTR table rendering functions to accommodate the new name mode.
- Enhanced tests to cover name mode functionality and API info display in TUI.
- Suppressed output of preferred API IP in MTR mode to avoid terminal pollution.
2026-02-27 20:50:47 +08:00
tsosunchia 86a2fd555b feat(mtr): 对齐 mtr 风格显示并完善窄屏右锚定
- 重构 TUI Header:
  - Line1 改为 `NextTrace [vX.Y.Z]`
  - Line2 改为 `srcHost(srcIP) -> dstName(dstIP) + 时间戳`(时间右侧对齐)
  - Keys 行增加 `y-display(...)` 模式提示
- Host 列新增 4 种显示模式并支持 `y/Y` 循环切换:
  - ASN / City / Owner / Full
  - `r` 重置统计不影响当前显示模式
- Host 基础标识调整为 PTR-or-IP(有 PTR 显示 PTR,无 PTR 显示 IP)
- City 模式改为单级回退链:`City -> Prov -> Country`
- 语言一致性修正:默认中文,`--language en` 才优先英文(缺失字段自动回退)
- MPLS 从主行内联改为独立续行显示(更贴近 mtr)

布局修复(review P2):
- 修复窄屏下指标区未贴右边界问题:
  - `computeLayout` 在 phase-2/3 收敛后回填 slack 到 hostW
  - 保证 `metricsStart + metricsWidth == termWidth`,指标区严格右锚定

测试:
- 更新/新增 Host 模式、语言回退、MPLS 多行、Header、`y` 键循环、窄屏右锚定断言等测试
- 全量测试通过
2026-02-27 20:09:16 +08:00
tsosunchia da10275b51 feat(mtr): 对齐 mtr 交互与展示,支持流式首屏/重置统计/目的跳截断
1. 启动与刷新:引入 `mtrPeeker + ProgressThrottle`,在首轮未完成时按节流推送预览快照,不再“整轮结束才出画面”。
2. 跳数前缀:每行开头改为 mtr 简约风格(`N.` / 同 TTL 续行空前缀)。
3. 运行中重置统计:新增 `r` 键(Restart statistics),重置聚合统计、轮次计数、退避状态与目的 TTL 缓存。
4. 表头版本信息:新增 `My traceroute [NextTrace <version>]`。
5. 表头目标信息:第二行展示 `domain (ip)`;当输入本身是 IP 时避免 `1.1.1.1 (1.1.1.1)` 重复显示。
6. MPLS 展示恢复:Host 列直接拼接底层提取的 MPLS 标签,修复不显示/双重包裹问题。
7. 目的跳后停止:检测 `DstIP` 命中后记录 `roundFinalTTL/knownFinalTTL`,后续轮次提前截断,不再把目标 IP 重复打印到 `maxHops`。

补充修正:
1. 流式预览中“未发送 TTL”保持 `nil` 槽位,不再被误计为 timeout(避免虚高 `Snt/Loss`)。
2. 新增对应单测覆盖未发送 TTL 场景与流式快照路径。

测试:
1. 新增/更新 `peekPartialResult`、流式刷新、重置统计、目的跳截断、Header/IP 去重、MPLS 展示等测试。
2. `go test ./...` 全量通过。
2026-02-27 19:05:06 +08:00
tsosunchia 9b9964d61f feat(tui): 增加自适应布局和双层表头渲染功能 2026-02-27 18:07:26 +08:00
tsosunchia 52b6b5cb22 mtr模式 2026-02-27 17:34:46 +08:00
tsosunchia 8c7b296fe7 Merge pull request #345 from nxtrace/main
SYNC
2026-02-27 13:32:25 +08:00
tsosunchia de622205cb Merge pull request #147 from nxtrace/dependabot/go_modules/golang.org/x/sys-0.41.0
chore(deps): bump golang.org/x/sys from 0.40.0 to 0.41.0
2026-02-17 10:11:46 +08:00
tsosunchia c3652004f6 Merge pull request #148 from nxtrace/dependabot/go_modules/golang.org/x/net-0.50.0
chore(deps): bump golang.org/x/net from 0.49.0 to 0.50.0
2026-02-17 10:11:30 +08:00
dependabot[bot] b0e9509775 chore(deps): bump golang.org/x/net from 0.49.0 to 0.50.0
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.49.0 to 0.50.0.
- [Commits](https://github.com/golang/net/compare/v0.49.0...v0.50.0)

---
updated-dependencies:
- dependency-name: golang.org/x/net
  dependency-version: 0.50.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-02-16 15:50:41 +00:00
dependabot[bot] fd7fbe0446 chore(deps): bump golang.org/x/sys from 0.40.0 to 0.41.0
Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.40.0 to 0.41.0.
- [Commits](https://github.com/golang/sys/compare/v0.40.0...v0.41.0)

---
updated-dependencies:
- dependency-name: golang.org/x/sys
  dependency-version: 0.41.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-02-16 15:50:37 +00:00