Commit Graph
136 Commits
Author SHA1 Message Date
tsosunchia a2cfb9a39f test(geo): 动态扩容 goroutine 堆栈快照
- 检测截断并扩容至 16 MiB 后再扫描完整 dump
- 同步覆盖 util 与 ipgeo 两条 resolver scope 阻塞测试
2026-09-04 19:33:37 +08:00
tsosunchia 75a5db6ffb test(geo): 统一 Windows 代理环境别名 2026-09-04 19:33:31 +08:00
tsosunchia 5d20b56510 test(geo): 隔离代理子进程 CGI 环境
- 清除 REQUEST_METHOD,避免继承环境绕过 HTTP proxy 验证
- 显式检查响应体与测试连接的关闭错误
2026-09-04 19:27:38 +08:00
tsosunchia dfd0fb645e fix(geo): 保留旧 client 的动态 DNS 语义 2026-09-04 18:51:53 +08:00
tsosunchia 407d843943 perf(geo): 扩展共享连接池空闲容量 2026-09-04 18:03:44 +08:00
tsosunchia af2b952698 perf(geo): 复用不可变 DNS 策略 Transport 2026-09-04 17:50:10 +08:00
tsosunchia 83d906bb31 refactor(runtime): 采用 Go 1.27 标准库并发与集合接口 2026-09-04 15:21:58 +08:00
tsosunchia c4b4f30b7f test(bench): 让 Geo HTTP 并发名称跟随配置 2026-09-04 12:45:49 +08:00
tsosunchia 2cab379924 test(bench): 建立 geo mtr websocket 性能与输出基线 2026-09-04 11:43:21 +08:00
tsosunchia df516310ec refactor(api): 统一官方 API 命名与 provider 规范值
- 将公共 data_provider 统一为 NextTrace-API,并保留旧别名输入兼容
- 按 v3/v4 语义重命名内部实现并保留 Deprecated Go 包装
- 同步 CLI、Web、MCP、文档及输出规范化测试
2026-08-14 19:37:55 +08:00
tsosunchia efc9464193 fix(util): 使用八进制输出 token 目录权限 2026-05-26 02:29:38 +08:00
tsosunchia f403d93ee6 fix(util): 支持 Windows 覆盖写入 API v4 token 2026-05-25 18:24:32 +08:00
tsosunchia b58fa4b0f6 fix(api-v4): 保留预热失败与代理场景的回退路径 2026-05-25 18:02:36 +08:00
tsosunchia 2bf1ca3b1c fix(ipgeo): 规范化GeoDNS和v4 endpoint 2026-05-22 16:45:29 +08:00
tsosunchia b40ccb9883 perf(ipgeo): 有界复用 NextTrace API v4 客户端 2026-05-22 16:11:46 +08:00
tsosunchia 7670936c72 fix(util): 将 v4 token debug 输出改到 stderr
- session token 写成功后 latest fallback 写失败不再导致 setup 失败
- NEXTTRACE_DEBUG 诊断写入 stderr,避免污染 stdout/JSON 输出
2026-05-22 11:16:55 +08:00
tsosunchia cb2b3e6cbd fix(api): 补齐 v4 client timeout 和恢复错误处理
- nil HTTP client 默认使用带超时的 Geo client
- NEXTTRACE_DEBUG 输出 token 文件读取错误和候选路径
- 合并 TTY read/restore 错误并保留 interrupted sentinel
2026-05-22 11:16:55 +08:00
tsosunchia a929cd67bf fix(util): 读取 v4 token 前校验目录和文件
- 读取 session/latest token 前拒绝 symlink、目录和宽松权限
- 父目录缺失仍按未保存 session token 处理
2026-05-22 11:16:55 +08:00
tsosunchia ed45af1ee7 fix(util): 拒绝无法校验 owner 的 token 目录
- Unix-like 平台在缺少 Stat_t 时拒绝 token 目录
- 调整 pipe cleanup 测试避免资源泄漏
2026-05-22 11:16:54 +08:00
tsosunchia 588cb3bc29 fix(util): 放宽非 Unix token 文件权限断言
- Unix-like 平台继续校验 0700/0600 和 owner
- Windows/other 平台仅校验可表达的目录、symlink 和 rename 约束
2026-05-22 11:16:54 +08:00
tsosunchia c966d93d3c fix(api): 限制 v4 lookup 总耗时并加固 token 文件写入
- 让 v4 retry 总耗时受调用方 timeout 限制
- 对成功和错误响应 body 增加读取上限
- 写 token 文件时校验目录并使用同目录临时文件原子替换
2026-05-22 11:16:54 +08:00
tsosunchia 618bd13579 fix(util): 读取 latest fallback v4 token 文件
- 额外写入 latest token 文件作为不同进程树 fallback
- 读取 session token 失败或缺失时尝试 latest token
2026-05-22 11:16:54 +08:00
tsosunchia 564d97b2c2 feat(util): 用临时文件保存 session v4 token
- 将 -x 从父进程 env 写入脚本调整为 session token 文件
- 启动时从 session token 文件加载 NEXTTRACE_API_V4_TOKEN
2026-05-22 11:16:54 +08:00
tsosunchia f619e7b660 refactor(api): 统一 NextTrace API v4 命名
- 将抽象 API v4 文件和符号改为 NextTrace API v4
- 同步 CLI flag、文档和测试命名
2026-05-22 11:16:54 +08:00
tsosunchia 97bcf79f8d feat(ipgeo): 添加 NextTrace API v4 HTTP GeoIP provider
- 仅在 NEXTTRACE_API_V4_TOKEN 存在时接管 LeoMoeAPI
- 保留未配置 v4 token 时的 v3 WebSocket 默认路径
2026-05-22 11:16:54 +08:00
tsosunchia 11f6b48fa7 fix(mcp): 修复 PR review 反馈
- 为 stdin reader 使用 per-request response,避免并发调用串线
- 统一 Fast Trace IPv4/IPv6 非取消错误处理,移除 log.Fatal 分支
- 加固 deploy auth cookie 与 MCP session 测试 helper
- 显式断言 MTR MCP capability 工具存在
2026-05-01 08:05:22 +08:00
tsosunchia fc0d9af40f fix(nexttrace): stop cancel-triggered retry loops 2026-04-30 14:49:22 +08:00
tsosunchia 1c8155a502 feat: add deploy MCP auth 2026-04-29 12:01:04 +08:00
tsosunchia 0ddac64b7a Fix source-device normalization and deploy smoke tests 2026-04-08 20:46:33 +08:00
tsosunchia 1cda0e53bb Fix context propagation and FastIP cache synchronization 2026-03-19 15:58:35 +08:00
tsosunchia 7b8e68710c Fix cancellation handling across DNS, trace, and ws flows 2026-03-19 12:22:02 +08:00
tsosunchia 21396148d0 fix: improve Windows mtu handling and privilege prompts 2026-03-19 00:14:08 +08:00
tsosunchia 81797d4b5f Improve gocyclo complexity 2026-03-08 10:54:41 +08:00
tsosunchia 27a84fa5b5 feat: add environment variable documentation and implement CORS middleware for browser access 2026-03-08 08:17:13 +08:00
tsosunchia d8e93c2a35 feat: improve fast trace flag naming and enhance layout computation tests 2026-03-07 23:05:43 +08:00
tsosunchia 77abf1b515 Refactor MTR signal handling and context management
- Unified signal handling in MTR CLI using `signal.NotifyContext(...)` for Ctrl-C/SIGTERM, removing the need for separate `sigCh` and goroutine.
- Updated `runMTRTUI`, `runMTRReport`, and `runMTRRaw` functions to utilize the new context management.
- Enhanced `mtrUI` to safely call `cancel()` only if it is not nil.
- Modified `IPDBOneClient` to clone HTTP clients with timeout settings, ensuring proper timeout handling without modifying global state.
- Adjusted raw aggregation keys in the frontend to collapse based on TTL, improving display of timeout/success results.
- Added context support in various tracer functions to allow cancellation and timeout handling.
- Improved error handling and test coverage for MTR operations, ensuring robustness against nil results and empty responses.
- Refined DNS resolver functions to use mutexes for thread-safe access to the geo resolver override.
2026-03-06 14:07:58 +08:00
tsosunchia a9a2325762 feat: enhance build scripts and improve error handling for Windows TCP traces 2026-03-06 13:48:16 +08:00
tsosunchia f69903a00c fix(web): resolve post-v1.5.0 review findings
Address all three review findings from the v1.5.0..HEAD audit:\n- Remove Web MTR reliance on process-wide globals (SrcDev/DisableMPLS) by passing session-scoped trace.Config fields.\n- Apply dot_server consistently to Web/API Geo DNS and LeoMoe/FastIP initialization via scoped resolver setup.\n- Restore Web MTR default per-hop cadence to 1000ms and send hop_interval_ms from frontend.\n\nAlso added regression tests in server/trace_handler_test.go and util/dns_resolver_test.go, and updated CLAUDE.md.\n\nValidation passed:\n- go test ./...\n- go build ./...\n- go build -tags flavor_ntr ./...\n- go build -tags flavor_tiny ./...\n- node --check server/web/assets/app.js
2026-03-06 13:04:42 +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 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 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 ac655be473 feat: replace Npcap with WinDivert SNIFF mode on Windows
- Remove gopacket/pcap dependency from Windows builds
- Replace pcapAvailable() with winDivertAvailable() using WinDivert SNIFF test
- Refactor listenICMPPcap() to listenICMPWinDivert() for ICMP traceroute
- Refactor ListenTCP() to use WinDivert SNIFF mode for TCP response capture
- Update util/pcap.go build tag from 'darwin || (windows && amd64)' to 'darwin only'
- WinDivert now handles all packet reception on Windows (ICMP, TCP, UDP modes)
- Tested on macOS, Windows (cross-compile), and Linux
- All tests passing
2026-02-09 20:13:00 +08:00
tsosunchia eb2ba884d1 Enhance DNS lookup in util.go: add timeout for context and improve IP parsing logic
Signed-off-by: tsosunchia <59512455+tsosunchia@users.noreply.github.com>
2025-10-29 20:55:31 +08:00
tsosunchia 75db288c0b 移除 trace/trace.go 中的全局 lastErr,改为线程安全的错误处理。加强 util/util.go 的 DomainLookUp 返回逻辑,确保在无可用 IP 时优雅地报错而不是 panic。
Signed-off-by: tsosunchia <59512455+tsosunchia@users.noreply.github.com>
2025-10-29 19:50:38 +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 3a09d28ea3 Handle error on response body close to prevent panic 2025-10-29 13:03:35 +08:00
tsosunchia 50a164c5ea Add nil check for response body to prevent panic 2025-10-29 12:58:16 +08:00