Commit Graph
123 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
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 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 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 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 69f2ca680b feat: 更新文档和代码,增强 MTR 功能,优化 API 信息输出 2026-02-28 13:14:03 +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 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 a523cda440 feat: 更新 Go 版本至 1.26.0,调整构建和测试工作流,增强输入解析器 2026-02-28 00:13:21 +08:00
tsosunchia 6c8912d78d feat(dns): 添加 Geo DNS 解析策略,支持 DoT 和系统 DNS 回退 2026-02-27 23:16:34 +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 52b6b5cb22 mtr模式 2026-02-27 17:34:46 +08:00
tsosunchia 26e2ff547c fix: 更新文档以移除对 Npcap 的依赖,改为使用 WinDivert 进行 ICMP 和 TCP/UDP 监听 2026-02-10 10:17:59 +08:00
Yunlq 071a496cc3 修改了README,并完善了一些参数的说明和处理 2025-11-20 01:39:21 +08:00
tsosunchia 2240f7959d fix: handle LeoMoe override correctly
- re-evaluate LeoMoe websocket flag after NEXTTRACE_DATAPROVIDER override in server trace handler
  - mirror the same check in CLI init so the websocket is only opened when the final provider is still
    LEOMOEAPI

Signed-off-by: tsosunchia <59512455+tsosunchia@users.noreply.github.com>
2025-10-29 22:38:28 +08:00
tsosunchia 6c12de9842 Ensure Leo data provider always initialises websocket 2025-10-29 22:16:12 +08:00
tsosunchia aa3df62875 Add tests for DN42 and PTR record functionalities
- Added focused unit tests for listener parsing helpers so buildListenInfo and isDigitsOnly are now validated without invoking the full CLI stack (cmd/listen_info_test.go:10-32).
  - Replaced placeholder DN42 tests with deterministic coverage for geofeed parsing and PTR matching, using temp CSV fixtures to check both positive and negative paths (dn42/geofeed_test.go:13-57, dn42/ptr_test.go:13-56).
  - Rebuilt the ipgeo tests to assert provider lookup mappings, DN42 integration (including PTR fallback and “unknown” defaults), and the disableGeoIP shim (ipgeo/ipgeo_test.go:12-53, ipgeo/dn42_test.go:14-78).
  - Introduced environment helper tests that exercise trimming, boolean, default, and integer reads without touching external DNS (util/env_test.go:9-46).
  - Removed legacy network-dependent tests that only printed output, ensuring the suite is deterministic.
2025-10-29 13:27:37 +08:00
tsosunchia 40f50e3e96 Add error handling for empty globalping measurement results 2025-10-29 10:40:09 +08:00
tsosunchia 0285fafa35 Add default local listen address handling with IPv4 and IPv6 support 2025-10-29 10:36:23 +08:00
tsosunchia cb6cf066a7 Refactor address handling in cmd.go to improve input validation and access host determination
规范化监听地址:支持纯端口输入并统一回传可访问地址
2025-10-29 10:33:37 +08:00
tsosunchiaandCopilot b1b8e0407f Update cmd/cmd.go:typo
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-10-29 10:22:52 +08:00
tsosunchia b6bd2dd351 docs: update Globalping references and add project description
https://github.com/nxtrace/NTrace-V1/pull/123
2025-10-24 23:02:26 +08:00
Radu Lucuț 42f3b7d0f9 Merge pull request #123 from radulucut/globalping
feat: add support for Globalping
2025-10-24 22:51:08 +08:00
tsosunchia 6f2bd1acc5 fix: update data provider options and remove deprecated references : IP2region 2025-10-21 00:31:47 +08:00
tsosunchia 57683fcbdf feat: add security warning for web console usage 2025-10-20 23:51:43 +08:00
tsosunchia f6598edf18 整合depoly模式的ENV到env.go 2025-10-20 23:11:26 +08:00
tsosunchia 46dd4a11f1 流式传输 2025-10-20 17:16:08 +08:00
tsosunchia 762579e8be 增加depoly模式 2025-10-20 16:25:48 +08:00
tsosunchia e62ae2b6d2 更新一些参数提示 2025-10-09 10:09:02 +08:00
Yunlq 72a3781ec5 优化了ICMP模式,提升了其在Windows上的表现 2025-10-04 10:59:43 +08:00
tsosunchia f9de92fd58 tcp默认端口80,udp默认端口33494 2025-09-24 14:23:35 +08:00
Yunlq c7e663fa99 优化了UDP模式,提升了其在NAT环境下的表现 2025-09-22 21:01:43 +08:00
Yunlq 10c567287e 完成了windows上的TCP路由跟踪 2025-09-13 02:04:26 +08:00
tsosunchia 8a5db17508 移除win udpmode 不可用的提示 2025-08-27 12:06:11 +08:00
Yunlq 81efadb8f5 完善了错误处理 2025-08-27 10:57:22 +08:00
tsosunchia 7fec94c6d9 移除DontFragment功能 2025-08-26 19:58:04 +08:00
Yunlq b5b4259953 优化了环境变量相关的处理 2025-08-26 17:40:21 +08:00
Yunlq d66a63b011 移除了PrintFunc中的status通道,使用WithCancelCause区分中断退出 2025-08-26 15:56:42 +08:00
tsosunchia b7756fa731 增加提示,仅在使用 UDP 探测时,确保 UDP 负载长度 ≥ 2 2025-08-25 10:09:33 +08:00
Yunlq e1ec195b00 修复了TCP/TCPv6模式中,mac端最终跳捕获失败的bug 2025-08-22 20:36:21 +08:00