Commit Graph
107 Commits
Author SHA1 Message Date
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
tsosunchia 123246c4ac 添加v6默认IP 2025-10-29 10:10:16 +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 f6598edf18 整合depoly模式的ENV到env.go 2025-10-20 23:11:26 +08:00
Yunlq 72a3781ec5 优化了ICMP模式,提升了其在Windows上的表现 2025-10-04 10:59:43 +08:00
Yunlq c7e663fa99 优化了UDP模式,提升了其在NAT环境下的表现 2025-09-22 21:01:43 +08:00
Yunlq 1d1591ca6b 调整了go:build选项 2025-09-13 19:48:17 +08:00
Yunlq 10c567287e 完成了windows上的TCP路由跟踪 2025-09-13 02:04:26 +08:00
Yunlq b5b4259953 优化了环境变量相关的处理 2025-08-26 17:40:21 +08:00
Yunlq e1ec195b00 修复了TCP/TCPv6模式中,mac端最终跳捕获失败的bug 2025-08-22 20:36:21 +08:00
Yunlq 267ee4aa2e 完成了UDP/UDPv6模式的并发优化 2025-08-21 17:05:20 +08:00
tsosunchia 424d31760a 稳定mpls表现 2025-08-19 00:21:55 +08:00
Yunlq f177e370ad 新增环境变量NEXTTRACE_DEVMODE,启用时输出panic日志而非直接退出 2025-08-17 15:53:31 +08:00
Yunlq ea54b2c0c4 优化并统一了环境变量的读取和使用 2025-08-17 15:04:57 +08:00
Yunlq 6bb278a22b 允许用户设置SrcPort=-1来启用随机源端口模式 2025-08-17 02:11:15 +08:00
Yunlq 3e2f16be8b 精简了listenICMP()函数中重复的逻辑 2025-08-16 23:05:53 +08:00
Yunlq 0905975c24 完善了fetchIPData()函数的类型断言和nil保护 2025-08-16 15:59:36 +08:00
Yunlq 1a1a86a417 完善TCP/UDP的SrcIP绑定与端口可用性检测 2025-08-15 23:30:43 +08:00
Yunlq ffd67a1d2d 优化了低Query场景下高丢包跳的输出 2025-08-10 23:27:50 +08:00
Yunlq f697c9bfd7 优化了ICMP模式中listenICMP()函数的实现 2025-08-09 02:13:04 +08:00
Yunlq 0485e3ae01 修复 trace 时延迟计时错误的问题 2025-08-07 22:53:24 +08:00
tsosunchia b4d2038895 SNI和DNS不再分离,统一使用api.nxtrace.org 2025-07-08 11:30:21 +08:00
Yunlq b20c4b74cc add support for custom source ports and optimize some code 2025-04-16 02:54:19 +08:00
tsosunchia 90b1a3c1ad 固定TCP模式的源端口,改善在一些负载均衡网络环境下的效果,在使用ENV "NEXTTRACE_RANDOMPORT" 支持继续随机分配源端口。
https://github.com/nxtrace/NTrace-core/issues/296
2025-04-13 20:26:54 +08:00
tsosunchia 6c49957be8 解决网络不通时的卡死问题 2025-01-05 12:24:58 +08:00
breakertt eea77b1f0d Enhance ipinfoLocal.mmdb file lookup (#66)
* Enhance ipinfoLocal.mmdb file lookup
* Refactor get NEXTTRACE_IPINFOLOCALPATH env variable into util
2024-08-15 21:26:57 +08:00
tsosunchia 970cff3b72 优化代码 2024-05-13 20:42:56 +08:00
tsosunchia 760e751076 设置latency测试时的fallback 2024-02-05 16:31:07 +08:00
tsosunchia 156f8914d8 删除一些没必要的赋值 2023-12-08 16:01:06 +08:00
tsosunchia c0455ca8e7 api变更 2023-12-01 16:32:44 +08:00