Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 66 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,52 +1,114 @@
# Changelog

All notable changes to this project will be documented in this file.
## 1.0.1

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
### Added / 新增

- **Web platform (partial)** — the package now compiles and runs on Flutter Web.
Connectivity is backed by `connectivity_plus`, ping falls back to an HTTPS
round trip, DNS resolution uses DNS-over-HTTPS, and the speed test, quality
score and benchmarks work unchanged. Capabilities the browser sandbox forbids
degrade gracefully: native details (SSID / gateway / MAC / VPN) report `null`
and TCP port checks return an "unavailable" result instead of throwing. Call
`NetworkCapabilities.current()` to discover the supported set at runtime.
- **Web 平台(部分支持)**——包现已可在 Flutter Web 上编译运行。连通性由
`connectivity_plus` 提供,Ping 退化为 HTTPS 往返耗时,DNS 解析改用
DNS-over-HTTPS,测速、质量评分与基准测试行为不变。浏览器沙箱禁止的能力会优雅降级:
原生详情(SSID / 网关 / MAC / VPN)返回 `null`,TCP 端口检测返回"不可用"结果而非抛异常。
运行时可调用 `NetworkCapabilities.current()` 查询当前支持的能力集合。

### Fixed / 修复

- **Speed test on the web** — download and upload requests no longer send a
`Cache-Control` header. It is not a CORS-safelisted header, so it forced an
OPTIONS preflight that speed-test endpoints reject, surfacing as
`Failed to fetch`.
- **Web 端测速**——下载与上传请求不再携带 `Cache-Control` 头。该头不属于 CORS
安全头,会触发 OPTIONS 预检,而测速端点会拒绝该预检,最终表现为 `Failed to fetch`。

### Changed / 变更

- **Windows VPN detection** — adapters are now also recognised from the driver
name in their description (TAP-Windows, Wintun, WireGuard, OpenVPN, …) in
addition to `IF_TYPE_TUNNEL`. `IF_TYPE_PPP` is deliberately not treated as a
VPN because PPPoE broadband reports the same interface type.
- **Windows VPN 检测**——除 `IF_TYPE_TUNNEL` 外,还会依据网卡描述中的驱动名识别
VPN 网卡(TAP-Windows、Wintun、WireGuard、OpenVPN 等)。有意**不**把
`IF_TYPE_PPP` 视为 VPN,因为 PPPoE 宽带拨号上报的也是该接口类型。

## 1.0.0

### Added
### Added / 新增

- **Connectivity** — `NetworkDiagnostic.checkConnection()` returns a
`NetworkConnectionInfo` snapshot with transport type, IPv4/IPv6, gateway,
Wi-Fi SSID, signal strength (dBm), MAC address and VPN detection.
`NetworkDiagnostic.onConnectivityChanged` streams a fresh snapshot on every
change.
- **连通性**——`NetworkDiagnostic.checkConnection()` 返回 `NetworkConnectionInfo`
快照,包含传输类型、IPv4/IPv6、网关、Wi-Fi SSID、信号强度(dBm)、MAC 地址与
VPN 检测;`NetworkDiagnostic.onConnectivityChanged` 会在每次变化时推送新快照。
- **Ping** — `NetworkDiagnostic.ping()` measures latency with TCP handshake
round trips on every platform, and can use the system ICMP `ping` command on
desktop (`PingMode.icmp`). `PingResult` reports sent/received, packet loss,
min/avg/max and jitter.
- **Ping**——`NetworkDiagnostic.ping()` 在各平台以 TCP 握手往返测量延迟,桌面端还
可使用系统 ICMP `ping` 命令(`PingMode.icmp`)。`PingResult` 提供发送/接收数、
丢包率、最小/平均/最大耗时与抖动。
- **DNS** — `NetworkDiagnostic.resolve()` queries `system` plus any explicit
resolvers over raw UDP, using the built-in DNS wire-format codec
(`DnsPacket`), with concurrent or serialised execution and per-server
`DnsTestResult`.
- **DNS**——`NetworkDiagnostic.resolve()` 通过原始 UDP 查询 `system` 及任意指定
DNS 服务器,使用内置 DNS 报文编解码器(`DnsPacket`),支持并发或串行执行,
并为每台服务器返回 `DnsTestResult`。
- **Speed test** — `NetworkDiagnostic.runSpeedTest()` measures download and
upload throughput plus latency/jitter/packet loss, with progress callbacks via
`SpeedTestProgress`.
- **测速**——`NetworkDiagnostic.runSpeedTest()` 测量下载与上传速率,并附带延迟、
抖动与丢包率,通过 `SpeedTestProgress` 回调进度。
- **Port check** — `NetworkDiagnostic.checkPort()` returns a `PortCheckResult`
(use `isPortOpen()` for a plain boolean) and `scanPorts()` performs
bounded-concurrency TCP reachability checks.
- **端口检测**——`NetworkDiagnostic.checkPort()` 返回 `PortCheckResult`(仅需布尔值
时可用 `isPortOpen()`);`scanPorts()` 以受限并发执行 TCP 可达性检测。
- **Quality score** — `NetworkDiagnostic.evaluateQuality()` and
`NetworkQualityEvaluator` produce a 0–100 weighted score with a
`NetworkQualityLevel` and actionable suggestions.
- **质量评分**——`NetworkDiagnostic.evaluateQuality()` 与 `NetworkQualityEvaluator`
产出 0–100 的加权评分,附带 `NetworkQualityLevel` 与可执行的优化建议。
- **Full report** — `NetworkDiagnostic.diagnose()` aggregates every
probe into a `NetworkDiagnosticReport`.
- **汇总报告**——`NetworkDiagnostic.diagnose()` 将全部探测结果汇总为
`NetworkDiagnosticReport`。
- **Benchmarks** — `NetworkBenchmark.runAll()` and friends measure the
diagnostics API itself and return `BenchmarkSuiteResult`.
- **基准测试**——`NetworkBenchmark.runAll()` 等方法测量诊断 API 自身的性能,
返回 `BenchmarkSuiteResult`。
- **Configuration** — `NetworkDiagnosticConfig` centralises hosts, timeouts,
payload sizes and quality targets; `ZeroNetworkKit.init()` applies it globally
and `dispose()` releases the owned HTTP client.
- **配置**——`NetworkDiagnosticConfig` 集中管理主机、超时、负载大小与质量目标;
`ZeroNetworkKit.init()` 全局生效,`dispose()` 释放其持有的 HTTP 客户端。
- **Native channel** — `getPlatformVersion()` and `getNetworkDetails()`
implemented for Android (Kotlin) and iOS (Swift).
- **原生通道**——`getPlatformVersion()` 与 `getNetworkDetails()` 已在 Android
(Kotlin)与 iOS(Swift)实现。
- **Desktop platforms** — Windows, macOS and Linux are now supported
(`pubspec.yaml` declares them); `getPlatformVersion()` and `getNetworkDetails()`
are implemented for each. On desktop, SSID / signal strength are `null`; Windows
additionally exposes gateway / MAC / VPN via the native layer.
- **桌面平台**——已支持 Windows、macOS 与 Linux(`pubspec.yaml` 已声明),并为各自
实现 `getPlatformVersion()` 与 `getNetworkDetails()`。桌面端 SSID 与信号强度为
`null`;Windows 还通过原生层额外提供网关 / MAC / VPN。
- **Capabilities** — `NetworkDiagnostic.capabilities` returns
`NetworkCapabilities`, so callers can query-then-call and hide unsupported
cards (e.g. SSID on desktop).
- **能力集**——`NetworkDiagnostic.capabilities` 返回 `NetworkCapabilities`,
调用方可"先查询再调用",隐藏不支持的卡片(例如桌面端的 SSID)。
- **Advanced API** — services, `ConnectivityAdapter`, `QualityEvaluator` and the
`DnsPacket` codec moved into `package:zero_network_kit/advanced.dart`; the root
barrel stays small (models + facades + config).
- **进阶 API**——各项 service、`ConnectivityAdapter`、`QualityEvaluator` 与
`DnsPacket` 编解码器已移入 `package:zero_network_kit/advanced.dart`;根 barrel
保持精简(仅模型 + 门面 + 配置)。
34 changes: 27 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@

A Flutter plugin for **network diagnostics**: connectivity inspection, latency
probing, DNS resolution, port checks, bandwidth measurement, quality scoring and
micro-benchmarks — for Android, iOS, macOS, Windows and Linux (no Web).
micro-benchmarks — for Android, iOS, macOS, Windows, Linux and Web (partial).

[![pub version](https://img.shields.io/pub/v/zero_network_kit.svg)](https://pub.dev/packages/zero_network_kit)
[![pub points](https://img.shields.io/pub/points/zero_network_kit.svg)](https://pub.dev/packages/zero_network_kit/score)
[![CI](https://github.com/zero-labsco/zero_network_kit/actions/workflows/ci.yml/badge.svg)](https://github.com/zero-labsco/zero_network_kit/actions/workflows/ci.yml)
[![License: MPL-2.0](https://img.shields.io/badge/License-MPL--2.0-blue.svg)](https://github.com/zero-labsco/zero_network_kit/blob/main/LICENSE)
[![Platform](https://img.shields.io/badge/Platform-Android%20%7C%20iOS%20%7C%20macOS%20%7C%20Windows%20%7C%20Linux-green.svg)](https://pub.dev/packages/zero_network_kit)
[![Platform](https://img.shields.io/badge/Platform-Android%20%7C%20iOS%20%7C%20macOS%20%7C%20Windows%20%7C%20Linux%20%7C%20Web-green.svg)](https://pub.dev/packages/zero_network_kit)
[![Flutter](https://img.shields.io/badge/Flutter-✓-02569B?logo=flutter)](https://flutter.dev)
[![Dart](https://img.shields.io/badge/Dart-✓-0175C2?logo=dart)](https://dart.dev)
[![Style: effective dart](https://img.shields.io/badge/style-effective_dart-40c4ff.svg)](https://pub.dev/packages/effective_dart)

> **🔔 First release:** `zero_network_kit` `1.0.0` is the initial public release, supporting Android, iOS, macOS, Windows and Linux. Web is **not** supported because the plugin relies on `dart:io`. Issues and pull requests are welcome!
> **🔔 Upgrade recommended:** `1.0.1` adds partial Web support — the plugin now compiles and runs in the browser, and the capabilities the sandbox forbids degrade gracefully instead of failing. It also fixes the speed test on the web. Upgrade to `^1.0.1`.

🌐 **[Official Website](https://www.zerolabsco.com/)**  ·  📦 **[View on pub.dev](https://pub.dev/packages/zero_network_kit)**  ·  🔗 **[View on GitHub](https://github.com/zero-labsco/zero_network_kit)**

Expand Down Expand Up @@ -74,7 +74,7 @@ Design goals:

```yaml
dependencies:
zero_network_kit: ^1.0.0
zero_network_kit: ^1.0.1
```

### Android permissions
Expand Down Expand Up @@ -266,10 +266,30 @@ NetworkDiagnostic.configure(
| macOS | ✅ Supported (Swift native side) |
| Windows | ✅ Supported (C++ native side) |
| Linux | ✅ Supported (C++ native side) |
| Web | ❌ Not supported — the plugin uses `dart:io`, which does not compile to Web. |
| Web | ⚠️ Partial — see [Web support](#web-support) below |

> The pure-Dart services can be compiled on desktop, but only the five platforms
> above are part of the officially supported matrix.
### Web support

The web build exposes the same static API. Capabilities that the browser sandbox
forbids degrade gracefully — they return `null` or an "unavailable" result
instead of throwing:

| Capability | Web | Notes |
| --- | --- | --- |
| Connectivity | ✅ | via `connectivity_plus` |
| Ping (`PingMode.tcp`) | ⚠️ | HTTPS round trip; the target must send CORS headers |
| Ping (`PingMode.icmp`) | ❌ | throws `UnsupportedError` |
| DNS (system resolver) | ✅ | via DNS-over-HTTPS |
| DNS (explicit server) | ⚠️ | needs a DoH endpoint, otherwise "unsupported" |
| Speed test | ✅ | HTTP download / upload |
| Quality score | ✅ | pure function |
| Benchmark | ✅ | pure function |
| Port check / scan | ❌ | returns "unavailable" results |
| Native details (SSID, gateway, MAC, VPN) | ❌ | `null` |

`ZeroNetworkKit.getNativeNetworkDetails()` returns `null` on the web and
`ZeroNetworkKit.getPlatformVersion()` returns `Web`. Call
`NetworkCapabilities.current()` to discover the supported set at runtime.

## Documentation

Expand Down
32 changes: 26 additions & 6 deletions README_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@
</div>

一个 Flutter **网络诊断**插件:连通性检测、延迟探测、DNS 解析、端口检测、带宽
测速、质量评分与微基准测试,支持 Android、iOS、macOS、Windows 与 Linux(不支持 Web)。
测速、质量评分与微基准测试,支持 Android、iOS、macOS、Windows、Linux 与 Web(部分支持)。

[![pub version](https://img.shields.io/pub/v/zero_network_kit.svg)](https://pub.dev/packages/zero_network_kit)
[![pub points](https://img.shields.io/pub/points/zero_network_kit.svg)](https://pub.dev/packages/zero_network_kit/score)
[![CI](https://github.com/zero-labsco/zero_network_kit/actions/workflows/ci.yml/badge.svg)](https://github.com/zero-labsco/zero_network_kit/actions/workflows/ci.yml)
[![License: MPL-2.0](https://img.shields.io/badge/License-MPL--2.0-blue.svg)](https://github.com/zero-labsco/zero_network_kit/blob/main/LICENSE)
[![Platform](https://img.shields.io/badge/Platform-Android%20%7C%20iOS%20%7C%20macOS%20%7C%20Windows%20%7C%20Linux-green.svg)](https://pub.dev/packages/zero_network_kit)
[![Platform](https://img.shields.io/badge/Platform-Android%20%7C%20iOS%20%7C%20macOS%20%7C%20Windows%20%7C%20Linux%20%7C%20Web-green.svg)](https://pub.dev/packages/zero_network_kit)
[![Flutter](https://img.shields.io/badge/Flutter-✓-02569B?logo=flutter)](https://flutter.dev)
[![Dart](https://img.shields.io/badge/Dart-✓-0175C2?logo=dart)](https://dart.dev)
[![Style: effective dart](https://img.shields.io/badge/style-effective_dart-40c4ff.svg)](https://pub.dev/packages/effective_dart)

> **🔔 首次发布:** `zero_network_kit` `1.0.0` 为首个公开版本,支持 Android、iOS、macOS、Windows 与 Linux;**不支持 Web**(插件依赖 `dart:io`)。欢迎提 issue 与 PR!
> **🔔 推荐升级:** `1.0.1` 新增 Web 平台部分支持——插件现已可在浏览器中编译运行,浏览器沙箱禁止的能力会优雅降级而不会报错;同时修复了 Web 端测速失败的问题。建议升级到 `^1.0.1`。

🌐 **[官方网站](https://www.zerolabsco.com/)** &nbsp;·&nbsp; 📦 **[在 pub.dev 查看](https://pub.dev/packages/zero_network_kit)** &nbsp;·&nbsp; 🔗 **[查看 GitHub 仓库](https://github.com/zero-labsco/zero_network_kit)**

Expand Down Expand Up @@ -72,7 +72,7 @@

```yaml
dependencies:
zero_network_kit: ^1.0.0
zero_network_kit: ^1.0.1
```

### Android 权限
Expand Down Expand Up @@ -259,9 +259,29 @@ NetworkDiagnostic.configure(
| macOS | ✅ 支持(Swift 原生实现) |
| Windows | ✅ 支持(C++ 原生实现) |
| Linux | ✅ 支持(C++ 原生实现) |
| Web | ❌ 不支持——插件使用 `dart:io`,无法编译到 Web。 |
| Web | ⚠️ 部分支持——详见下方 [Web 支持](#web-支持) |

> 纯 Dart 服务可在桌面端编译,但仅有以上五个平台属于官方受支持矩阵。
### Web 支持

Web 构建提供同样的静态 API;浏览器沙箱禁止的能力会优雅降级(返回 `null`
或“不可用”结果,而不是抛异常):

| 能力 | Web | 说明 |
| --- | --- | --- |
| 连通性检测 | ✅ | 通过 `connectivity_plus` |
| Ping(`PingMode.tcp`) | ⚠️ | 以 HTTPS 往返耗时度量,目标主机需下发 CORS 头 |
| Ping(`PingMode.icmp`) | ❌ | 抛出 `UnsupportedError` |
| DNS(系统解析器) | ✅ | 通过 DNS-over-HTTPS |
| DNS(指定服务器) | ⚠️ | 需要 DoH 端点,否则返回“不支持” |
| 带宽测速 | ✅ | HTTP 下载 / 上传 |
| 质量评分 | ✅ | 纯函数 |
| 微基准 | ✅ | 纯函数 |
| 端口检测 / 扫描 | ❌ | 返回“不可用”结果 |
| 原生详情(SSID、网关、MAC、VPN) | ❌ | 返回 `null` |

Web 上 `ZeroNetworkKit.getNativeNetworkDetails()` 返回 `null`,
`ZeroNetworkKit.getPlatformVersion()` 返回 `Web`;运行时可用
`NetworkCapabilities.current()` 查询当前平台支持的能力集合。

## 文档

Expand Down
Loading
Loading