Commit Graph
100 Commits
Author SHA1 Message Date
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 210d89f26f fix(ipgeo): 对齐 v4 组织信息与 v3 输出 2026-07-27 01:37:35 +08:00
tsosunchia b58fa4b0f6 fix(api-v4): 保留预热失败与代理场景的回退路径 2026-05-25 18:02:36 +08:00
tsosunchia 8dd2db97bb fix(ipgeo): 复用 GeoHTTPClient 构造 v4 客户端 2026-05-22 20:56:56 +08:00
tsosunchia 1b2b0c77f4 fix(ipgeo): 修正 v4 FastIP 预热与回退逻辑 2026-05-22 20:28:32 +08:00
tsosunchia 8b81f0365f Add FastIP-aware NextTrace API v4 HTTP path 2026-05-22 17:32:10 +08:00
tsosunchia 61dc9b1304 perf(ipgeo): 优化 v4 缓存批量淘汰 2026-05-22 17:03:59 +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 eeea3be636 perf(ipgeo): 缓存 NextTrace API v4 客户端 2026-05-22 15:51:45 +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 c966d93d3c fix(api): 限制 v4 lookup 总耗时并加固 token 文件写入
- 让 v4 retry 总耗时受调用方 timeout 限制
- 对成功和错误响应 body 增加读取上限
- 写 token 文件时校验目录并使用同目录临时文件原子替换
2026-05-22 11:16:54 +08:00
tsosunchia 447de62136 fix(ipgeo): 为 v4 GeoIP lookup 增加重试和最低超时
- 将 v4 lookup timeout 最低提升到 2s
- 对网络错误、408 和 5xx 做保守重试
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 bf4946243f Prevent stale labels, flaky websocket tests, and speed misreports
Bound Leo IP sends and stale response delivery by timeout, bootstrap speed-mode metadata lookups without JSON banner noise, respect --speed=false pre-dispatch, validate speed source binding, cap probe response reads, avoid caching empty nali labels, treat server-only speed metadata as healthy when no client IP is available, make websocket async tests event-driven, restart Leo receive parsing reliably, close websocket receive channels exactly once, send Leo requests on the waited websocket, back off failed Geo/RDNS metadata lookups, refresh MTR API info cache timestamps after lookup, report upload response read errors, avoid launching latency probes after cancellation, and keep speed JSON tests tolerant of degraded latency samples.
2026-04-19 23:45:16 +08:00
tsosunchia 945b51ce5a guard leo receive parser against missing websocket 2026-04-19 09:22:01 +08:00
tsosunchia 1d1c9e1ab1 address remaining async mtr review feedback 2026-04-19 08:48:57 +08:00
tsosunchia 9edb724581 fix review regressions in async mtr metadata 2026-04-19 01:07:57 +08:00
tsosunchia ed3fd408c6 speed up mtr startup with async metadata 2026-04-19 00:18:48 +08:00
tsosunchia 81797d4b5f Improve gocyclo complexity 2026-03-08 10:54:41 +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 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 25a20a89be ipgeo/dn42.go 国家/地区名称存在前后空格污染 2025-10-29 14:48:42 +08:00
tsosunchia 6ee87dc60b Update LtdCodeToCountryOrAreaName to use region names and codes 2025-10-29 14:37:54 +08:00
tsosunchia 3528c2de6c 移除无效的单元测试 2025-10-29 14:33:58 +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 6f2bd1acc5 fix: update data provider options and remove deprecated references : IP2region 2025-10-21 00:31:47 +08:00
PukNgae Cryolitia 7749dd3fcd fix(dn42): fill Owner field from IPWhois instead of Whois
So that it could be displayed correctly
2025-10-20 01:34:17 +08:00
Yunlq 114fa5c543 增加geoip查询失败时的重试次数,减少由此引起的panic概率 2025-10-04 12:07:54 +08:00
tsosunchia 7580acd5fb fix(ipgeo): 用 RWMutex 统一保护 IPPools,局部缓存 ch,避免 concurrent map read/write panic 2025-09-24 15:40:20 +08:00
Yunlq b5b4259953 优化了环境变量相关的处理 2025-08-26 17:40:21 +08:00
Yunlq 0070082101 运行了go fmt和goimports 2025-08-17 16:12:26 +08:00
Yunlq ea54b2c0c4 优化并统一了环境变量的读取和使用 2025-08-17 15:04:57 +08:00
SaltyFishEd 7bfccf9da4 feat(geoip): overwrite the owner field when asn.domain exists for ipdb.one datasource
feat(geoip): add asn.asname as whois field for ipdb.one datasource
2025-04-27 00:25:47 +08:00
SaltyFishEd b5673b65a1 feat(geoip): support geoip data from ipdb.one 2025-04-18 14:43:56 +08:00
tsosunchia 9af629b6f9 ipgeo/leo.go 优化 receiveParse 的单例调用(WebSocket 连接的并发控制) 2025-04-15 13:36:42 +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
bobo liu 3260753a66 provide ability to override baseurl of APIs 2024-06-22 20:16:29 +08:00
tsosunchia 970cff3b72 优化代码 2024-05-13 20:42:56 +08:00
tsosunchia 7afc4c5104 fix issue: https://github.com/nxtrace/NTrace-V1/issues/40
要提交的变更:
	修改:     ipgeo/ip2region.go
2024-02-15 18:00:31 +08:00
tsosunchia 8b30ef39dd fix bug: ipv6局域网地址错误显示为INVALID 2023-10-11 10:22:14 +08:00
tsosunchia 1580c6111f add mpls func 2023-10-06 21:03:38 +08:00
tsosunchia 580612ce08 refactor: preparatory work 2023-06-26 14:49:05 +08:00
tsosunchia 7c37598804 将GeoIPInformatinDataCache推广到所有数据源 2023-06-02 18:13:27 +08:00
tsosunchia 8578109243 对rdns也进行了缓存 2023-06-02 02:12:35 +08:00