From 2e77fcc3760b3e96a1db5cd28a2108f30599b6d2 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Thu, 26 Nov 2026 23:32:19 +0000 Subject: [PATCH 1/2] =?UTF-8?q?=E8=AE=A9=E7=94=A8=E6=88=B7=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E6=9B=B4=E6=96=B0=E6=BA=90=EF=BC=8C=E5=B9=B6=E5=90=8C?= =?UTF-8?q?=E6=AD=A5=E5=9C=A8=E7=BA=BF=E6=9B=B4=E6=96=B0=E5=8E=86=E5=8F=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 设置里可以在 YanJiu Git 和 GitHub 之间选择,默认是 YanJiu Git。选中的源连不上时改用另一个,结果会写明实际用的是哪一个。更新历史从所选源读取已发布版本并在本机缓存。表单里被省略号截断的提示可以点开。 Co-authored-by: yanjiu0721 --- README.md | 2 +- client/lib/content/release_history.dart | 40 ++ client/lib/models/session_config.dart | 6 + client/lib/ui/center_dialog.dart | 4 +- client/lib/ui/expandable_hint.dart | 90 ++++ client/lib/ui/history_page.dart | 85 +++- client/lib/ui/home_page.dart | 66 ++- client/lib/ui/settings_page.dart | 81 +++- client/lib/update/apply_update.dart | 105 ++++- client/lib/update/release_feed.dart | 558 ++++++++++++++++++++++++ client/lib/update/update_check.dart | 221 +++++++++- client/test/expandable_hint_test.dart | 73 ++++ client/test/update_source_test.dart | 503 +++++++++++++++++++++ client/test/v113_test.dart | 5 + 14 files changed, 1771 insertions(+), 68 deletions(-) create mode 100644 client/lib/ui/expandable_hint.dart create mode 100644 client/lib/update/release_feed.dart create mode 100644 client/test/expandable_hint_test.dart create mode 100644 client/test/update_source_test.dart diff --git a/README.md b/README.md index 2ed5ad1..9eb9e46 100644 --- a/README.md +++ b/README.md @@ -106,7 +106,7 @@ cd client && flutter analyze && flutter test Android 安装包是按 CPU 分开的 release 包,使用调试证书,只适合测试安装,不是应用商店签名。当前版本名 `1.1.3`,构建号 `6`。应用标识没有改。1.1.3 以及以后的版本必须用仓库里的 [client/android/keystore/debug.keystore](client/android/keystore/debug.keystore) 签名,这样后一版才能覆盖安装。1.1.2 的证书不同,升到 1.1.3 要先卸载。 -从 1.1.3 起,客户端启动后会检查更新,设置里可以关掉。先问 GitHub Releases,连不上再问 `https://git.yanjiu.ltd/YanJiu/netquality/releases`。1.1.2 没有这个功能,所以 1.1.2 升到 1.1.3 仍然要自己安装。Windows 和 Linux 会把新文件写回当前安装目录。Android 会弹出系统安装确认,这一步不能跳过。没有真正的新版本时,可以用环境变量 `NQ_UPDATE_GITHUB_API` 和 `NQ_UPDATE_GITEA_API` 指向一份同样格式的测试响应。 +从 1.1.3 起,客户端可以检查更新,设置里可以关掉,也可以选择更新源。默认先问 YanJiu Git(`https://git.yanjiu.ltd/YanJiu/netquality/releases`),连不上再问 GitHub Releases。结果里会写明这次实际用的是哪一个。1.1.2 没有这个功能,所以 1.1.2 升到 1.1.3 仍然要自己安装。已经发布的 1.1.2 和 1.1.3 安装包也没有在线更新历史。Windows 和 Linux 会把新文件写回当前安装目录。Android 会弹出系统安装确认,这一步不能跳过。没有真正的新版本时,可以用环境变量 `NQ_UPDATE_GITHUB_API` 和 `NQ_UPDATE_GITEA_API` 指向一份同样格式的测试响应。 中心也是这个 Go 程序。示例配置在 [server/example-center](server/example-center),里面的口令都是占位。本机可以这样看目录: diff --git a/client/lib/content/release_history.dart b/client/lib/content/release_history.dart index a274b65..7f69597 100644 --- a/client/lib/content/release_history.dart +++ b/client/lib/content/release_history.dart @@ -11,13 +11,48 @@ class ReleaseEntry { required this.source, required this.points, this.published, + this.tag, }); final String version; final String title; final String source; final String? published; + + /// Release tag, when this entry came from a forge. Bundled entries omit it. + final String? tag; final List points; + + Map toJson() => { + 'version': version, + 'title': title, + 'source': source, + 'published': published, + 'tag': tag, + 'points': points, + }; + + factory ReleaseEntry.fromJson(Map json) { + final rawPoints = json['points']; + final points = []; + if (rawPoints is List) { + for (final item in rawPoints) { + if (item is String && item.trim().isNotEmpty) { + points.add(item); + } + } + } + return ReleaseEntry( + version: json['version'] is String ? json['version'] as String : '', + title: json['title'] is String ? json['title'] as String : '', + source: json['source'] is String ? json['source'] as String : '', + published: json['published'] is String + ? json['published'] as String + : null, + tag: json['tag'] is String ? json['tag'] as String : null, + points: points, + ); + } } const releaseHistory = [ @@ -66,3 +101,8 @@ const releaseHistory = [ const releaseHistoryNote = '仓库里目前公开的版本标签只有 v1.1.1。1.1.1 的发布说明提到过更早的发包行为,但没有单独的标签或 Release,所以这里不写成另一个版本。'; + +/// Already shipped installers cannot grow this screen. The sentence stays +/// visible so the app does not imply that 1.1.2 or 1.1.3 already sync notes. +const onlineHistoryLimitNote = + '已经发布的 1.1.2 和 1.1.3 安装包没有在线更新历史。那些版本不会自己同步以后的发布说明,需要先安装包含这个功能的版本。'; diff --git a/client/lib/models/session_config.dart b/client/lib/models/session_config.dart index 45c06c4..af8cc9b 100644 --- a/client/lib/models/session_config.dart +++ b/client/lib/models/session_config.dart @@ -120,6 +120,7 @@ class SessionConfig { this.allowIPv4 = true, this.allowIPv6 = true, this.autoUpdate = true, + this.updateSource = 'gitea', this.httpVersion = 'auto', this.httpResolve = '', this.httpMethod = 'GET', @@ -163,6 +164,9 @@ class SessionConfig { final bool allowIPv4; final bool allowIPv6; final bool autoUpdate; + + /// `gitea` (YanJiu Git, the default) or `github`. + final String updateSource; final String httpVersion; final String httpResolve; final String httpMethod; @@ -306,6 +310,7 @@ class SessionConfig { 'allowIPv4': allowIPv4, 'allowIPv6': allowIPv6, 'autoUpdate': autoUpdate, + 'updateSource': updateSource == 'github' ? 'github' : 'gitea', 'httpVersion': httpVersion, 'httpResolve': httpResolve, 'httpMethod': httpMethod, @@ -352,6 +357,7 @@ class SessionConfig { autoUpdate: json['autoUpdate'] is bool ? json['autoUpdate'] as bool : true, + updateSource: json['updateSource'] == 'github' ? 'github' : 'gitea', httpVersion: json['httpVersion'] is String ? json['httpVersion'] as String : 'auto', diff --git a/client/lib/ui/center_dialog.dart b/client/lib/ui/center_dialog.dart index e39e439..ed8a50d 100644 --- a/client/lib/ui/center_dialog.dart +++ b/client/lib/ui/center_dialog.dart @@ -6,6 +6,7 @@ import 'package:flutter/material.dart'; import '../center/catalog.dart'; import '../center/center_client.dart'; import '../models/session_config.dart'; +import 'expandable_hint.dart'; class AddedCenter { const AddedCenter({ @@ -140,9 +141,10 @@ class _CenterAddDialogState extends State<_CenterAddDialog> { obscureText: true, decoration: const InputDecoration( labelText: '密码', - hintText: '中心要求密码、手里还没有口令时填写', + hintText: '还没有口令时填写', ), ), + const ExpandableHint(text: '中心要求密码、手里还没有口令时填写。'), if (_hint != null) ...[ const SizedBox(height: 8), Text(_hint!, style: const TextStyle(color: Color(0xFF9A3412))), diff --git a/client/lib/ui/expandable_hint.dart b/client/lib/ui/expandable_hint.dart new file mode 100644 index 0000000..c6c39fb --- /dev/null +++ b/client/lib/ui/expandable_hint.dart @@ -0,0 +1,90 @@ +// Copyright (C) 2026 言灸 +// SPDX-License-Identifier: AGPL-3.0-only + +import 'package:flutter/material.dart'; + +/// Helper or hint copy that stays one line until it actually overflows. +/// Text that fits is not a button. Text that would end in an ellipsis can be +/// tapped to show the rest, and tapped again to collapse. +class ExpandableHint extends StatefulWidget { + const ExpandableHint({super.key, required this.text}); + + final String text; + + @override + State createState() => _ExpandableHintState(); +} + +class _ExpandableHintState extends State { + var _expanded = false; + + @override + void didUpdateWidget(ExpandableHint oldWidget) { + super.didUpdateWidget(oldWidget); + if (oldWidget.text != widget.text) { + _expanded = false; + } + } + + @override + Widget build(BuildContext context) { + final theme = Theme.of(context); + final style = (theme.textTheme.bodySmall ?? const TextStyle(fontSize: 12)) + .copyWith(color: theme.colorScheme.onSurfaceVariant, height: 1.3); + return LayoutBuilder( + builder: (context, constraints) { + final overflows = _exceedsOneLine( + text: widget.text, + style: style, + maxWidth: constraints.maxWidth, + textScaler: MediaQuery.textScalerOf(context), + direction: Directionality.of(context), + ); + final shown = Text( + widget.text, + style: style, + maxLines: overflows && !_expanded ? 1 : null, + overflow: overflows && !_expanded + ? TextOverflow.ellipsis + : TextOverflow.clip, + ); + final padded = Padding( + padding: const EdgeInsets.fromLTRB(12, 6, 12, 0), + child: shown, + ); + if (!overflows) { + return padded; + } + return Semantics( + button: true, + hint: _expanded ? '点一下收起' : '点一下展开全文', + child: InkWell( + onTap: () => setState(() => _expanded = !_expanded), + child: padded, + ), + ); + }, + ); + } +} + +bool _exceedsOneLine({ + required String text, + required TextStyle style, + required double maxWidth, + required TextScaler textScaler, + required TextDirection direction, +}) { + if (!maxWidth.isFinite || maxWidth <= 0) { + return false; + } + final painter = TextPainter( + text: TextSpan(text: text, style: style), + maxLines: 1, + textDirection: direction, + textScaler: textScaler, + )..layout(maxWidth: maxWidth); + final exceeds = painter.didExceedMaxLines; + painter.dispose(); + return exceeds; +} diff --git a/client/lib/ui/history_page.dart b/client/lib/ui/history_page.dart index 6393072..fcd5018 100644 --- a/client/lib/ui/history_page.dart +++ b/client/lib/ui/history_page.dart @@ -4,11 +4,65 @@ import 'package:flutter/material.dart'; import '../content/release_history.dart'; +import '../update/apply_update.dart'; +import '../update/release_feed.dart'; +import '../update/update_check.dart'; import '../version.dart'; import 'quality_charts.dart'; -class HistoryPage extends StatelessWidget { - const HistoryPage({super.key}); +class HistoryPage extends StatefulWidget { + const HistoryPage({super.key, this.updateSource = UpdateSource.gitea}); + + final UpdateSource updateSource; + + @override + State createState() => _HistoryPageState(); +} + +class _HistoryPageState extends State { + var _entries = const []; + var _note = '正在读取发布说明…'; + var _showBundledNote = false; + + @override + void initState() { + super.initState(); + _load(); + } + + Future _load() async { + final cached = await readStoredReleaseHistory(); + if (!mounted) { + return; + } + if (cached != null) { + setState(() { + _entries = cached.entries; + _note = '正在向${updateSourceLabel(widget.updateSource)}核对发布说明…'; + _showBundledNote = false; + }); + } + try { + final result = await loadReleaseHistory(widget.updateSource); + if (!mounted) { + return; + } + setState(() { + _entries = result.entries; + _note = result.note; + _showBundledNote = result.origin == HistoryOrigin.bundled; + }); + } on Object { + if (!mounted) { + return; + } + setState(() { + _entries = releaseHistory; + _note = staleHistoryNote(rateLimited: false, hasCache: false); + _showBundledNote = true; + }); + } + } @override Widget build(BuildContext context) { @@ -39,12 +93,25 @@ class HistoryPage extends StatelessWidget { ), ), const SizedBox(height: 8), + if (_note.isNotEmpty) + Text( + _note, + style: const TextStyle(color: muted, height: 1.4), + ), + const SizedBox(height: 8), const Text( - releaseHistoryNote, + onlineHistoryLimitNote, style: TextStyle(color: muted, height: 1.4), ), + if (_showBundledNote) ...[ + const SizedBox(height: 8), + const Text( + releaseHistoryNote, + style: TextStyle(color: muted, height: 1.4), + ), + ], const SizedBox(height: 12), - for (final entry in releaseHistory) _entry(entry), + for (final entry in _entries) _entry(entry), ], ), ), @@ -54,6 +121,9 @@ class HistoryPage extends StatelessWidget { } Widget _entry(ReleaseEntry entry) { + final remote = SemVer.parse(entry.version); + final local = SemVer.parse(appVersion); + final newer = remote != null && local != null && remote.isNewerThan(local); return Card( margin: const EdgeInsets.only(bottom: 12), shape: RoundedRectangleBorder( @@ -69,6 +139,13 @@ class HistoryPage extends StatelessWidget { entry.title, style: const TextStyle(fontWeight: FontWeight.w700, color: ink), ), + if (newer) ...[ + const SizedBox(height: 6), + Text( + '比当前安装的 $appVersion 新', + style: const TextStyle(color: Color(0xFF9A3412), fontSize: 13), + ), + ], const SizedBox(height: 6), Text( entry.published == null diff --git a/client/lib/ui/home_page.dart b/client/lib/ui/home_page.dart index 4586005..08e34ba 100644 --- a/client/lib/ui/home_page.dart +++ b/client/lib/ui/home_page.dart @@ -16,7 +16,9 @@ import '../probe/remote_client.dart'; import '../storage/app_store.dart'; import '../storage/token_vault.dart'; import '../update/apply_update.dart'; +import '../update/update_check.dart'; import 'address_text.dart'; +import 'expandable_hint.dart'; import 'center_dialog.dart'; import 'format.dart'; import 'history_page.dart'; @@ -57,6 +59,7 @@ class _HomePageState extends State { var _allow4 = true; var _allow6 = true; var _autoUpdate = true; + var _updateSource = UpdateSource.gitea; var _centers = []; var _history = TargetHistory.empty; var _centerHint = ''; @@ -79,12 +82,17 @@ class _HomePageState extends State { Future _load() async { _vault = await openTokenVault(); - final loaded = await _store.load(); final history = await _store.loadHistory(); final echo = await _vault.read(echoTokenKey); if (!mounted) { return; } + // Read settings after the slower startup awaits, so a choice made while + // the vault was opening is not replaced by the older snapshot. + final loaded = await _store.load(); + if (!mounted) { + return; + } final config = loaded.config; setState(() { _remote = config.remote; @@ -103,6 +111,7 @@ class _HomePageState extends State { _allow4 = config.allowIPv4; _allow6 = config.allowIPv6; _autoUpdate = config.autoUpdate; + _updateSource = parseUpdateSource(config.updateSource); _httpVersion = config.httpVersion; _httpMethod = config.httpMethod; _httpResolve.text = config.httpResolve; @@ -177,6 +186,7 @@ class _HomePageState extends State { allowIPv4: _allow4, allowIPv6: _allow6, autoUpdate: _autoUpdate, + updateSource: updateSourceId(_updateSource), httpVersion: _httpVersion, httpResolve: _httpResolve.text.trim(), httpMethod: _httpMethod, @@ -286,7 +296,7 @@ class _HomePageState extends State { return; } final page = value == 'history' - ? const HistoryPage() + ? HistoryPage(updateSource: _updateSource) : const MetricGuidePage(); Navigator.of(context) .push(MaterialPageRoute(builder: (_) => page)); @@ -398,8 +408,9 @@ class _HomePageState extends State { _field( _echo, '目标回显口令', - '可选,只放进探测包,和节点口令不是同一个', + '可选', secret: true, + helper: '只放进探测包,和节点口令不是同一个。', ), ], if (profile.id == 'dns') ...[ @@ -410,7 +421,12 @@ class _HomePageState extends State { const SizedBox(height: 12), _field(_payload, '载荷(十六进制)', '例如 0102'), const SizedBox(height: 12), - _field(_expect, '响应需以此开头(十六进制,可空)', '不填则任意响应都算成功'), + _field( + _expect, + '响应开头(十六进制)', + '可空', + helper: '不填则任意响应都算成功。', + ), ], ], ), @@ -460,7 +476,8 @@ class _HomePageState extends State { TextButton( onPressed: () => Navigator.of(context).push( MaterialPageRoute( - builder: (_) => const HistoryPage(), + builder: (_) => + HistoryPage(updateSource: _updateSource), ), ), child: const Text('更新历史'), @@ -585,7 +602,12 @@ class _HomePageState extends State { : (value) => setState(() => _httpVersion = value ?? 'auto'), ), const SizedBox(height: 8), - _field(_httpResolve, '指定解析', '可选。Host 和 SNI 仍用上面的地址,连接改走这里的 IP 或主机名'), + _field( + _httpResolve, + '指定解析', + '可选', + helper: 'Host 和 SNI 仍用上面的地址,连接改走这里的 IP 或主机名。', + ), const SizedBox(height: 12), DropdownButtonFormField( key: ValueKey('http-method-$_httpMethod-$_formEpoch'), @@ -642,6 +664,7 @@ class _HomePageState extends State { allowIPv4: _allow4, allowIPv6: _allow6, autoUpdate: _autoUpdate, + updateSource: _updateSource, onAllowIPv4: (value) { setState(() => _allow4 = value); unawaited(_persist()); @@ -654,13 +677,17 @@ class _HomePageState extends State { setState(() => _autoUpdate = value); unawaited(_persist()); }, + onUpdateSource: (value) { + setState(() => _updateSource = value); + unawaited(_persist()); + }, ), ), ); } Future _launchUpdate() async { - final result = await checkForUpdate(); + final result = await checkForUpdate(preferred: _updateSource); final offer = result.offer; if (offer == null || !mounted || !_autoUpdate) { return; @@ -1262,11 +1289,10 @@ class _NodeDialogState extends State<_NodeDialog> { obscureText: true, decoration: InputDecoration( labelText: _editingId == null ? '节点口令(公开节点留空)' : '新口令(留空则保留)', - helperText: _editingId == null - ? null - : '留空则保留已保存的口令,不会显示原口令。', ), ), + if (_editingId != null) + const ExpandableHint(text: '留空则保留已保存的口令,不会显示原口令。'), if (_hint != null) ...[ const SizedBox(height: 8), Text(_hint!, style: const TextStyle(fontSize: 13)), @@ -1324,15 +1350,17 @@ Widget _field( Key? fieldKey, String? helper, }) { - return TextField( - key: fieldKey, - controller: controller, - obscureText: secret, - decoration: InputDecoration( - labelText: label, - hintText: hint, - helperText: helper, - ), + return Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + TextField( + key: fieldKey, + controller: controller, + obscureText: secret, + decoration: InputDecoration(labelText: label, hintText: hint), + ), + if (helper != null && helper.isNotEmpty) ExpandableHint(text: helper), + ], ); } diff --git a/client/lib/ui/settings_page.dart b/client/lib/ui/settings_page.dart index e40d4ae..9c7f641 100644 --- a/client/lib/ui/settings_page.dart +++ b/client/lib/ui/settings_page.dart @@ -15,17 +15,21 @@ class SettingsPage extends StatefulWidget { required this.allowIPv4, required this.allowIPv6, required this.autoUpdate, + required this.updateSource, required this.onAllowIPv4, required this.onAllowIPv6, required this.onAutoUpdate, + required this.onUpdateSource, }); final bool allowIPv4; final bool allowIPv6; final bool autoUpdate; + final UpdateSource updateSource; final ValueChanged onAllowIPv4; final ValueChanged onAllowIPv6; final ValueChanged onAutoUpdate; + final ValueChanged onUpdateSource; @override State createState() => _SettingsPageState(); @@ -35,6 +39,7 @@ class _SettingsPageState extends State { late bool _allow4; late bool _allow6; late bool _auto; + late UpdateSource _source; var _checking = false; String _message = ''; UpdateOffer? _offer; @@ -45,6 +50,7 @@ class _SettingsPageState extends State { _allow4 = widget.allowIPv4; _allow6 = widget.allowIPv6; _auto = widget.autoUpdate; + _source = widget.updateSource; } Future _check() async { @@ -53,7 +59,7 @@ class _SettingsPageState extends State { _message = ''; _offer = null; }); - final result = await checkForUpdate(); + final result = await checkForUpdate(preferred: _source); if (!mounted) { return; } @@ -94,11 +100,18 @@ class _SettingsPageState extends State { child: ConstrainedBox( constraints: const BoxConstraints(maxWidth: 760), child: ListView( - padding: EdgeInsets.fromLTRB(wide ? 24 : 12, 8, wide ? 24 : 12, 28), + padding: EdgeInsets.fromLTRB( + wide ? 24 : 12, + 8, + wide ? 24 : 12, + 28, + ), children: [ SwitchListTile( title: const Text('允许 IPv4'), - subtitle: const Text('关掉以后,解析结果里的 IPv4 不会用来发包。直接填写 IPv4 地址也会被拒绝。'), + subtitle: const Text( + '关掉以后,解析结果里的 IPv4 不会用来发包。直接填写 IPv4 地址也会被拒绝。', + ), value: _allow4, onChanged: (value) { setState(() => _allow4 = value); @@ -107,7 +120,9 @@ class _SettingsPageState extends State { ), SwitchListTile( title: const Text('允许 IPv6'), - subtitle: const Text('关掉以后,解析结果里的 IPv6 不会用来发包。直接填写 IPv6 地址也会被拒绝。'), + subtitle: const Text( + '关掉以后,解析结果里的 IPv6 不会用来发包。直接填写 IPv6 地址也会被拒绝。', + ), value: _allow6, onChanged: (value) { setState(() => _allow6 = value); @@ -118,7 +133,11 @@ class _SettingsPageState extends State { padding: EdgeInsets.fromLTRB(16, 0, 16, 8), child: Text( '两个都关掉时不能开始探测。远程节点会收到同样的选择。1.1.2 的节点还不会遵守这个开关,遇到这种情况会提示升级。', - style: TextStyle(color: Color(0xFF5C656B), fontSize: 13, height: 1.4), + style: TextStyle( + color: Color(0xFF5C656B), + fontSize: 13, + height: 1.4, + ), ), ), const Divider(), @@ -131,11 +150,53 @@ class _SettingsPageState extends State { widget.onAutoUpdate(value); }, ), + Padding( + padding: const EdgeInsets.fromLTRB(16, 4, 16, 8), + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + const Text('更新源'), + const SizedBox(height: 4), + const Text( + '默认是 YanJiu Git。这边的网络经常解析不到 github.com。检查和下载都先用这里选中的源,连不上再试另一个。', + style: TextStyle( + color: Color(0xFF5C656B), + fontSize: 13, + height: 1.4, + ), + ), + const SizedBox(height: 8), + SegmentedButton( + key: const Key('update-source'), + segments: const [ + ButtonSegment( + value: UpdateSource.gitea, + label: Text('YanJiu Git'), + ), + ButtonSegment( + value: UpdateSource.github, + label: Text('GitHub'), + ), + ], + selected: {_source}, + onSelectionChanged: (value) { + final next = value.first; + setState(() => _source = next); + widget.onUpdateSource(next); + }, + ), + ], + ), + ), Padding( padding: const EdgeInsets.fromLTRB(16, 0, 16, 8), child: Text( - '当前版本 $appVersion(构建 $appBuild)。1.1.2 没有自更新,从 1.1.2 升到 1.1.3 仍要手动安装。从这一版起才会自己检查。先试 GitHub,连不上再试言灸的 Git。\n\n要在没有新版本时试这个功能,可以把环境变量 NQ_UPDATE_GITHUB_API 指到一个同样格式的测试地址,NQ_UPDATE_GITEA_API 是备用。', - style: const TextStyle(color: Color(0xFF5C656B), fontSize: 13, height: 1.4), + '当前版本 $appVersion(构建 $appBuild)。1.1.2 没有自更新,从 1.1.2 升到 1.1.3 仍要手动安装。更新源默认是 YanJiu Git,也可以改成 GitHub。检查更新和下载都先用选中的源,连不上再试另一个,结果里会写明这次实际用的是哪一个。\n\n「更新历史」会读取所选源的发布列表,并在本机留一份。网络失败时用上次保存的列表,没有保存过再用安装包里的说明,并标明可能不是最新。已经发出的 1.1.2 和 1.1.3 安装包没有这份同步。\n\n要在没有新版本时试检查更新,可以把环境变量 NQ_UPDATE_GITHUB_API 指到一个同样格式的测试地址,NQ_UPDATE_GITEA_API 是另一个。', + style: const TextStyle( + color: Color(0xFF5C656B), + fontSize: 13, + height: 1.4, + ), ), ), if (Platform.isAndroid) @@ -143,7 +204,11 @@ class _SettingsPageState extends State { padding: EdgeInsets.fromLTRB(16, 0, 16, 8), child: Text( '在 Android 上安装时,系统会弹出安装确认。这一步不能跳过。', - style: TextStyle(color: Color(0xFF9A3412), fontSize: 13, height: 1.4), + style: TextStyle( + color: Color(0xFF9A3412), + fontSize: 13, + height: 1.4, + ), ), ), Padding( diff --git a/client/lib/update/apply_update.dart b/client/lib/update/apply_update.dart index c2f5f35..aa71520 100644 --- a/client/lib/update/apply_update.dart +++ b/client/lib/update/apply_update.dart @@ -1,13 +1,16 @@ // Copyright (C) 2026 言灸 // SPDX-License-Identifier: AGPL-3.0-only +import 'dart:convert'; import 'dart:ffi' show Abi; import 'dart:io'; import 'package:flutter/services.dart'; +import 'package:shared_preferences/shared_preferences.dart'; import '../version.dart'; import 'installer.dart'; +import 'release_feed.dart'; import 'update_check.dart'; class UpdateResult { @@ -19,31 +22,63 @@ class UpdateResult { const platformChannel = MethodChannel('dev.netquality/platform'); -Future checkForUpdate() async { +UpdateEndpoints endpointsFromEnvironment() { + return updateEndpoints( + githubApi: Platform.environment['NQ_UPDATE_GITHUB_API'], + giteaApi: Platform.environment['NQ_UPDATE_GITEA_API'], + ); +} + +Future readStoredReleaseHistory() async { + final prefs = await SharedPreferences.getInstance(); + return decodeReleaseCache(prefs.getString(releaseHistoryCacheKey)); +} + +Future loadReleaseHistory( + UpdateSource preferred, { + bool? allowNetwork, +}) async { + final prefs = await SharedPreferences.getInstance(); + return syncAndStore( + preferred: preferred, + endpoints: endpointsFromEnvironment(), + fetch: fetchReleaseText, + allowNetwork: + allowNetwork ?? Platform.environment['FLUTTER_TEST'] != 'true', + readCache: () async => prefs.getString(releaseHistoryCacheKey), + writeCache: (json) async { + await prefs.setString(releaseHistoryCacheKey, json); + }, + ); +} + +Future checkForUpdate({ + UpdateSource preferred = UpdateSource.gitea, +}) async { + final history = loadReleaseHistory(preferred); final arch = await _arch(); if (arch.isEmpty) { + await _finishHistory(history); return const UpdateResult(message: '认不出这台设备的系统或 CPU,没有下载安装包'); } - final endpoints = UpdateEndpoints( - github: Platform.environment['NQ_UPDATE_GITHUB_API'] ?? - UpdateEndpoints.githubDefault, - gitea: Platform.environment['NQ_UPDATE_GITEA_API'] ?? - UpdateEndpoints.giteaDefault, - ); final check = await findUpdate( current: appVersion, - endpoints: endpoints, + endpoints: endpointsFromEnvironment(), + preferred: preferred, os: _os(), arch: arch, - fetch: (url) => _getText(url), + fetch: fetchReleaseText, ); - if (check.offer == null) { - return UpdateResult(message: check.message); + await _finishHistory(history); + return UpdateResult(message: check.message, offer: check.offer); +} + +Future _finishHistory(Future history) async { + try { + await history; + } on Object { + // A failed history sync still leaves the update check usable. } - return UpdateResult( - message: '发现 ${check.offer!.version}。可以下载并覆盖安装。', - offer: check.offer, - ); } Future installOffer(UpdateOffer offer) async { @@ -155,7 +190,45 @@ Future _getText(Uri url) async { if (bytes == null) { return null; } - return String.fromCharCodes(bytes); + return utf8.decode(bytes, allowMalformed: true); +} + +/// Release JSON, not an installer. A 429, or a 403 that says the quota is +/// gone, is reported as a rate limit so the caller can say so in Chinese. +Future fetchReleaseText(Uri url) async { + final client = HttpClient(); + client.connectionTimeout = const Duration(seconds: 15); + try { + final request = await client.getUrl(url); + request.headers.set(HttpHeaders.userAgentHeader, 'netquality/$appVersion'); + request.headers.set(HttpHeaders.acceptHeader, 'application/json'); + final response = await request.close().timeout(const Duration(seconds: 20)); + final bytes = []; + await for (final chunk in response.timeout(const Duration(seconds: 20))) { + bytes.addAll(chunk); + } + final text = utf8.decode(bytes, allowMalformed: true); + if (isReleaseRateLimited( + status: response.statusCode, + rateLimitRemaining: response.headers.value('x-ratelimit-remaining'), + body: text, + )) { + throw UpdateFetchException( + rateLimited: true, + status: response.statusCode, + ); + } + if (response.statusCode < 200 || response.statusCode >= 300) { + return null; + } + return text; + } on UpdateFetchException { + rethrow; + } on Object { + return null; + } finally { + client.close(force: true); + } } Future?> _getBytes(Uri url) async { diff --git a/client/lib/update/release_feed.dart b/client/lib/update/release_feed.dart new file mode 100644 index 0000000..7da13e0 --- /dev/null +++ b/client/lib/update/release_feed.dart @@ -0,0 +1,558 @@ +// Copyright (C) 2026 言灸 +// SPDX-License-Identifier: AGPL-3.0-only + +import 'dart:convert'; + +import '../content/release_history.dart'; +import 'update_check.dart'; + +/// SharedPreferences key for the last release list that a source actually returned. +const releaseHistoryCacheKey = 'netquality.release-history.v1'; + +enum HistoryOrigin { remote, cache, bundled } + +class ReleaseCache { + const ReleaseCache({required this.source, required this.entries}); + + final String source; + final List entries; +} + +class ReleaseSync { + const ReleaseSync({ + required this.entries, + required this.note, + required this.origin, + this.cacheJson, + this.used, + }); + + final List entries; + final String note; + final HistoryOrigin origin; + + /// Non-null when [origin] is [HistoryOrigin.remote] and the list should be saved. + final String? cacheJson; + final UpdateSource? used; +} + +class ReleasePage { + const ReleasePage({required this.entries, required this.complete}); + + final List entries; + + /// False when this page was full and another page may exist. + final bool complete; +} + +/// Turns a `/releases/latest` URL into one page of the release list. +/// GitHub pages with `per_page`; Gitea pages with `limit`. A testing override +/// of the latest URL is reused, so the list follows `NQ_UPDATE_*_API`. +Uri releaseListUri( + String latestUrl, { + required UpdateSource source, + required int page, + required int pageSize, +}) { + final parsed = Uri.parse(latestUrl.trim()); + var path = parsed.path; + if (path.endsWith('/latest')) { + path = path.substring(0, path.length - '/latest'.length); + } + final params = Map.from(parsed.queryParameters); + if (source == UpdateSource.github) { + params['per_page'] = '$pageSize'; + params.remove('limit'); + } else { + params['limit'] = '$pageSize'; + params.remove('per_page'); + } + params['page'] = '$page'; + return parsed.replace(path: path, queryParameters: params); +} + +/// GitHub and Gitea both return `tag_name`, `name`, `body`, `published_at`, +/// `draft`, `prerelease`, and `assets[].browser_download_url`. A list page is +/// a JSON array. A single release object is accepted so a `/latest` body can +/// still be shown. An error object is not a page. +ReleasePage? parseReleasePage( + String body, { + required String sourceLabel, + required int pageSize, +}) { + Object? decoded; + try { + decoded = jsonDecode(body); + } on FormatException { + return null; + } + if (decoded is Map) { + if (decoded['tag_name'] is! String) { + return null; + } + final entry = _entryFromRelease( + Map.from(decoded), + sourceLabel: sourceLabel, + ); + return ReleasePage(entries: [?entry], complete: true); + } + if (decoded is! List) { + return null; + } + final entries = []; + for (final item in decoded) { + if (item is! Map) { + continue; + } + final entry = _entryFromRelease( + Map.from(item), + sourceLabel: sourceLabel, + ); + if (entry != null) { + entries.add(entry); + } + } + return ReleasePage(entries: entries, complete: decoded.length < pageSize); +} + +ReleaseEntry? _entryFromRelease( + Map json, { + required String sourceLabel, +}) { + if (json['draft'] == true) { + return null; + } + final tag = json['tag_name']; + if (tag is! String) { + return null; + } + final version = SemVer.parse(tag); + if (version == null) { + return null; + } + final versionText = '${version.major}.${version.minor}.${version.patch}'; + final name = json['name']; + final title = name is String && name.trim().isNotEmpty + ? name.trim() + : '网络质量探测 $versionText'; + final body = json['body'] is String ? json['body'] as String : ''; + final points = notesToPoints(body, title: title); + if (points.isEmpty) { + points.add('这次发布没有正文。'); + } + final pre = json['prerelease'] == true; + final published = _publishedDay(json['published_at']); + final tagText = tag.trim(); + return ReleaseEntry( + version: versionText, + tag: tagText, + title: title, + published: published, + source: '来自 $sourceLabel · 标签 $tagText${pre ? ' · 预发布' : ''}', + points: points, + ); +} + +String? _publishedDay(Object? raw) { + if (raw is! String || raw.length < 10) { + return null; + } + final day = raw.substring(0, 10); + if (!RegExp(r'^\d{4}-\d{2}-\d{2}$').hasMatch(day)) { + return null; + } + return day; +} + +/// Splits a release body into the short points the history page already shows. +/// Headings and bullet items each become one point. A title repeated as the +/// first heading is dropped. Versions that are not in the body are not added. +List notesToPoints(String body, {String title = ''}) { + final points = []; + final buffer = StringBuffer(); + void flush() { + final text = _plain(buffer.toString()); + buffer.clear(); + if (text.isNotEmpty) { + points.add(text); + } + } + + for (final raw in body.replaceAll('\r\n', '\n').split('\n')) { + final trimmed = raw.trim(); + if (trimmed.isEmpty) { + flush(); + continue; + } + if (trimmed.startsWith('```')) { + flush(); + continue; + } + final heading = RegExp(r'^#{1,6}\s+').firstMatch(trimmed); + if (heading != null) { + flush(); + final text = _plain(trimmed.substring(heading.end)); + if (text.isNotEmpty) { + points.add(text); + } + continue; + } + final bullet = RegExp(r'^[-*+]\s+').firstMatch(trimmed); + if (bullet != null) { + flush(); + final text = _plain(trimmed.substring(bullet.end)); + if (text.isNotEmpty) { + points.add(text); + } + continue; + } + if (buffer.isNotEmpty) { + buffer.write(' '); + } + buffer.write(trimmed); + } + flush(); + if (points.isNotEmpty && title.isNotEmpty && points.first == title) { + points.removeAt(0); + } + return points; +} + +String _plain(String input) { + var text = input.trim(); + text = text.replaceAllMapped(RegExp(r'\[([^\]]+)\]\(([^)]+)\)'), (match) { + final label = match.group(1)!.trim(); + final url = match.group(2)!.trim(); + if (label.isEmpty) { + return url; + } + if (url.isEmpty || url == label) { + return label; + } + return '$label($url)'; + }); + text = text.replaceAll('`', ''); + text = text.replaceAll(RegExp(r'\s+'), ' '); + return text.trim(); +} + +String encodeReleaseCache({ + required String source, + required List entries, +}) { + return jsonEncode({ + 'source': source, + 'entries': [for (final entry in entries) entry.toJson()], + }); +} + +ReleaseCache? decodeReleaseCache(String? raw) { + if (raw == null || raw.trim().isEmpty) { + return null; + } + try { + final decoded = jsonDecode(raw); + if (decoded is! Map) { + return null; + } + final source = decoded['source']; + final rawEntries = decoded['entries']; + if (source is! String || rawEntries is! List) { + return null; + } + final entries = []; + for (final item in rawEntries) { + if (item is! Map) { + continue; + } + final entry = ReleaseEntry.fromJson(Map.from(item)); + if (entry.version.isEmpty && entry.title.isEmpty) { + continue; + } + entries.add(entry); + } + return ReleaseCache(source: source, entries: entries); + } on FormatException { + return null; + } +} + +String freshHistoryNote({ + required String sourceLabel, + required bool fellBack, + required bool preferredRateLimited, + required bool incomplete, + required bool empty, +}) { + final head = !fellBack + ? '已从 $sourceLabel 同步。' + : preferredRateLimited + ? '所选更新源暂时限制了请求次数,这次改用了 $sourceLabel。' + : '所选更新源连不上,这次改用了 $sourceLabel。'; + final tail = empty + ? '这个更新源目前没有已发布的版本。' + : incomplete + ? '后面的页没有取完,可能不是全部。' + : '比当前安装更新的发布也会列在这里。'; + return '$head$tail'; +} + +String staleHistoryNote({ + required bool rateLimited, + required bool hasCache, + String? sourceLabel, +}) { + final reason = rateLimited ? '更新源暂时限制了请求次数' : '网络暂时连不上'; + if (!hasCache) { + return '$reason,也没有保存过在线列表。下面是安装包里的说明,可能不是最新。'; + } + final from = sourceLabel == null || sourceLabel.isEmpty + ? '' + : '从 $sourceLabel '; + return '$reason。下面是上次$from保存的列表,可能不是最新。'; +} + +String? cacheSourceLabel(String source) { + if (source == updateSourceGithub) { + return updateSourceLabel(UpdateSource.github); + } + if (source == updateSourceGitea) { + return updateSourceLabel(UpdateSource.gitea); + } + return null; +} + +/// Reads the chosen source's release list, then the other source if that +/// fails. A network failure keeps [cachedJson], or [bundled] when nothing +/// has been saved. Published releases newer than the installed app stay in +/// the list; versions that the payload does not contain are not added. +Future syncReleaseHistory({ + required UpdateSource preferred, + required UpdateEndpoints endpoints, + required Future Function(Uri url) fetch, + String? cachedJson, + List bundled = releaseHistory, + int pageLimit = 5, + int githubPageSize = 100, + int giteaPageSize = 50, +}) async { + final order = preferred == UpdateSource.github + ? const [UpdateSource.github, UpdateSource.gitea] + : const [UpdateSource.gitea, UpdateSource.github]; + var sawRate = false; + var preferredRate = false; + for (var i = 0; i < order.length; i++) { + final source = order[i]; + final pageSize = source == UpdateSource.github + ? githubPageSize + : giteaPageSize; + try { + final read = await _readSource( + latestUrl: endpoints.latestFor(source), + source: source, + fetch: fetch, + pageLimit: pageLimit, + pageSize: pageSize, + ); + if (read == null) { + continue; + } + final entries = _sortedUnique(read.entries); + return ReleaseSync( + entries: entries, + origin: HistoryOrigin.remote, + used: source, + cacheJson: encodeReleaseCache( + source: updateSourceId(source), + entries: entries, + ), + note: freshHistoryNote( + sourceLabel: updateSourceLabel(source), + fellBack: i > 0, + preferredRateLimited: i > 0 && preferredRate, + incomplete: read.incomplete, + empty: entries.isEmpty, + ), + ); + } on UpdateFetchException catch (error) { + if (error.rateLimited) { + sawRate = true; + if (i == 0) { + preferredRate = true; + } + } + } + } + return _offline( + cachedJson: cachedJson, + bundled: bundled, + rateLimited: sawRate, + ); +} + +class _SourceRead { + const _SourceRead({required this.entries, required this.incomplete}); + + final List entries; + final bool incomplete; +} + +Future<_SourceRead?> _readSource({ + required String latestUrl, + required UpdateSource source, + required Future Function(Uri url) fetch, + required int pageLimit, + required int pageSize, +}) async { + final entries = []; + final label = updateSourceLabel(source); + for (var page = 1; page <= pageLimit; page++) { + final uri = releaseListUri( + latestUrl, + source: source, + page: page, + pageSize: pageSize, + ); + String? body; + try { + body = await fetch(uri); + } on UpdateFetchException { + if (page == 1) { + rethrow; + } + return _SourceRead(entries: entries, incomplete: true); + } on Object { + if (page == 1) { + return null; + } + return _SourceRead(entries: entries, incomplete: true); + } + if (body == null) { + if (page == 1) { + return null; + } + return _SourceRead(entries: entries, incomplete: true); + } + final parsed = parseReleasePage( + body, + sourceLabel: label, + pageSize: pageSize, + ); + if (parsed == null) { + if (page == 1) { + return null; + } + return _SourceRead(entries: entries, incomplete: true); + } + entries.addAll(parsed.entries); + if (parsed.complete) { + return _SourceRead(entries: entries, incomplete: false); + } + if (page == pageLimit) { + return _SourceRead(entries: entries, incomplete: true); + } + } + return _SourceRead(entries: entries, incomplete: true); +} + +List _sortedUnique(List entries) { + final sorted = [...entries]; + sorted.sort((a, b) { + final av = SemVer.parse(a.version); + final bv = SemVer.parse(b.version); + if (av != null && bv != null) { + final compared = bv.compareTo(av); + if (compared != 0) { + return compared; + } + } + final published = (b.published ?? '').compareTo(a.published ?? ''); + if (published != 0) { + return published; + } + return (a.tag ?? '').compareTo(b.tag ?? ''); + }); + final seen = {}; + final unique = []; + for (final entry in sorted) { + final key = (entry.tag == null || entry.tag!.isEmpty) + ? entry.version + : entry.tag!; + if (key.isEmpty || !seen.add(key)) { + continue; + } + unique.add(entry); + } + return unique; +} + +ReleaseSync _offline({ + required String? cachedJson, + required List bundled, + required bool rateLimited, +}) { + final cache = decodeReleaseCache(cachedJson); + if (cache != null) { + return ReleaseSync( + entries: cache.entries, + origin: HistoryOrigin.cache, + note: staleHistoryNote( + rateLimited: rateLimited, + hasCache: true, + sourceLabel: cacheSourceLabel(cache.source), + ), + ); + } + return ReleaseSync( + entries: bundled, + origin: HistoryOrigin.bundled, + note: staleHistoryNote(rateLimited: rateLimited, hasCache: false), + ); +} + +/// Same sync as [syncReleaseHistory], plus reading and writing the local cache. +/// [allowNetwork] is false in widget tests so opening history does not call out. +Future syncAndStore({ + required UpdateSource preferred, + required UpdateEndpoints endpoints, + required Future Function(Uri url) fetch, + required Future Function() readCache, + required Future Function(String json) writeCache, + bool allowNetwork = true, + List bundled = releaseHistory, + int pageLimit = 5, + int githubPageSize = 100, + int giteaPageSize = 50, +}) async { + final cached = await readCache(); + if (!allowNetwork) { + final stored = decodeReleaseCache(cached); + if (stored != null) { + return ReleaseSync( + entries: stored.entries, + origin: HistoryOrigin.cache, + note: '下面是上次保存的列表。', + ); + } + return ReleaseSync( + entries: bundled, + origin: HistoryOrigin.bundled, + note: '', + ); + } + final result = await syncReleaseHistory( + preferred: preferred, + endpoints: endpoints, + fetch: fetch, + cachedJson: cached, + bundled: bundled, + pageLimit: pageLimit, + githubPageSize: githubPageSize, + giteaPageSize: giteaPageSize, + ); + final json = result.cacheJson; + if (json != null) { + await writeCache(json); + } + return result; +} diff --git a/client/lib/update/update_check.dart b/client/lib/update/update_check.dart index f68b1c3..5905667 100644 --- a/client/lib/update/update_check.dart +++ b/client/lib/update/update_check.dart @@ -3,6 +3,65 @@ import 'dart:convert'; +/// Where release metadata is downloaded from. YanJiu Git is the default +/// because github.com is often blocked by DNS pollution on the user's network. +enum UpdateSource { gitea, github } + +const updateSourceGitea = 'gitea'; +const updateSourceGithub = 'github'; + +UpdateSource parseUpdateSource(String? raw) => + raw == updateSourceGithub ? UpdateSource.github : UpdateSource.gitea; + +String updateSourceId(UpdateSource source) => + source == UpdateSource.github ? updateSourceGithub : updateSourceGitea; + +String updateSourceLabel(UpdateSource source) => + source == UpdateSource.github ? 'GitHub' : 'YanJiu Git'; + +/// Environment variables override the live release URLs. Empty values keep +/// the defaults, so a blank test variable does not point the client nowhere. +UpdateEndpoints updateEndpoints({String? githubApi, String? giteaApi}) { + return UpdateEndpoints( + github: githubApi == null || githubApi.trim().isEmpty + ? UpdateEndpoints.githubDefault + : githubApi.trim(), + gitea: giteaApi == null || giteaApi.trim().isEmpty + ? UpdateEndpoints.giteaDefault + : giteaApi.trim(), + ); +} + +/// 429, a spent quota header, or a 403 body that says the limit was hit. +bool isReleaseRateLimited({ + required int status, + String? rateLimitRemaining, + required String body, +}) { + if (status == 429) { + return true; + } + if (status != 403) { + return false; + } + if (rateLimitRemaining == '0') { + return true; + } + return body.toLowerCase().contains('rate limit'); +} + +/// The release API refused the request because the caller asked too often. +class UpdateFetchException implements Exception { + const UpdateFetchException({required this.rateLimited, this.status}); + + final bool rateLimited; + final int? status; + + @override + String toString() => + 'UpdateFetchException(rateLimited: $rateLimited, status: $status)'; +} + /// Numeric version. A leading v and a +build suffix are ignored. class SemVer implements Comparable { const SemVer(this.major, this.minor, this.patch); @@ -68,6 +127,9 @@ class UpdateEndpoints { final String github; final String gitea; + + String latestFor(UpdateSource source) => + source == UpdateSource.github ? github : gitea; } class UpdateOffer { @@ -87,11 +149,23 @@ class UpdateOffer { } class UpdateCheck { - const UpdateCheck({this.offer, required this.reachable, this.message = ''}); + const UpdateCheck({ + this.offer, + required this.reachable, + this.message = '', + this.used, + this.fellBack = false, + }); final UpdateOffer? offer; final bool reachable; final String message; + + /// The source that actually answered. Null when neither source could be used. + final UpdateSource? used; + + /// True when [used] is the spare source because the chosen one failed. + final bool fellBack; } /// Picks the client archive for this OS and CPU. Server packages are ignored. @@ -120,7 +194,8 @@ String? pickClientAsset( if (!archOk || !name.contains(wantOs)) { continue; } - if (wantOs == 'windows' && (name.endsWith('.zip') || name.endsWith('.exe'))) { + if (wantOs == 'windows' && + (name.endsWith('.zip') || name.endsWith('.exe'))) { return asset.name; } if (wantOs == 'linux' && @@ -182,7 +257,8 @@ UpdateCheck interpretRelease({ if (pickedName == null) { return UpdateCheck( reachable: true, - message: '发现 ${remote.major}.${remote.minor}.${remote.patch},但没有适合这台设备的安装包', + message: + '发现 ${remote.major}.${remote.minor}.${remote.patch},但没有适合这台设备的安装包', ); } final picked = assets.firstWhere((asset) => asset.name == pickedName); @@ -205,33 +281,140 @@ UpdateCheck interpretRelease({ ); } +enum _SourceFailure { down, rate } + +/// Asks [preferred] first. A source that answers, even with "already current", +/// is kept. The other source is used only when the chosen one cannot be read, +/// and the message names the source that actually answered. Future findUpdate({ required String current, required UpdateEndpoints endpoints, + required UpdateSource preferred, required Future Function(Uri url) fetch, required String os, required String arch, +}) async { + final order = preferred == UpdateSource.github + ? const [UpdateSource.github, UpdateSource.gitea] + : const [UpdateSource.gitea, UpdateSource.github]; + var sawRate = false; + var sawDown = false; + _SourceFailure? preferredFailure; + for (var i = 0; i < order.length; i++) { + final source = order[i]; + final outcome = await _readLatest( + url: endpoints.latestFor(source), + fetch: fetch, + current: current, + os: os, + arch: arch, + ); + final failure = outcome.failure; + if (failure == null) { + final check = outcome.check!; + final fellBack = i > 0; + return UpdateCheck( + reachable: true, + offer: check.offer, + used: source, + fellBack: fellBack, + message: _withSource( + check, + _sourceClause( + used: source, + fellBack: fellBack, + preferredFailure: preferredFailure, + ), + ), + ); + } + if (i == 0) { + preferredFailure = failure; + } + if (failure == _SourceFailure.rate) { + sawRate = true; + } else { + sawDown = true; + } + } + return UpdateCheck(reachable: false, message: _bothFailed(sawRate, sawDown)); +} + +class _LatestOutcome { + const _LatestOutcome.ok(this.check) : failure = null; + const _LatestOutcome.fail(this.failure) : check = null; + + final UpdateCheck? check; + final _SourceFailure? failure; +} + +Future<_LatestOutcome> _readLatest({ + required String url, + required Future Function(Uri url) fetch, + required String current, + required String os, + required String arch, }) async { String? body; try { - body = await fetch(Uri.parse(endpoints.github)); + body = await fetch(Uri.parse(url)); + } on UpdateFetchException catch (error) { + if (error.rateLimited) { + return const _LatestOutcome.fail(_SourceFailure.rate); + } + return const _LatestOutcome.fail(_SourceFailure.down); } on Object { - body = null; + return const _LatestOutcome.fail(_SourceFailure.down); } - var check = interpretRelease(current: current, body: body, os: os, arch: arch); + if (body == null) { + return const _LatestOutcome.fail(_SourceFailure.down); + } + final check = interpretRelease( + current: current, + body: body, + os: os, + arch: arch, + ); if (!check.reachable) { - try { - body = await fetch(Uri.parse(endpoints.gitea)); - } on Object { - body = null; - } - check = interpretRelease(current: current, body: body, os: os, arch: arch); - if (!check.reachable) { - return const UpdateCheck( - reachable: false, - message: 'GitHub 和备用源都连不上,没有检查到更新', - ); - } + return const _LatestOutcome.fail(_SourceFailure.down); } - return check; + return _LatestOutcome.ok(check); +} + +String _sourceClause({ + required UpdateSource used, + required bool fellBack, + required _SourceFailure? preferredFailure, +}) { + final usedLabel = updateSourceLabel(used); + if (!fellBack) { + return '这次用的是 $usedLabel'; + } + final preferredLabel = updateSourceLabel( + used == UpdateSource.github ? UpdateSource.gitea : UpdateSource.github, + ); + if (preferredFailure == _SourceFailure.rate) { + return '$preferredLabel 暂时限制了请求次数,这次用的是 $usedLabel'; + } + return '$preferredLabel 连不上,这次用的是 $usedLabel'; +} + +String _withSource(UpdateCheck check, String clause) { + if (check.offer != null) { + return '发现 ${check.offer!.version}。可以下载并覆盖安装。($clause)'; + } + if (check.message.isEmpty) { + return clause; + } + return '${check.message}($clause)'; +} + +String _bothFailed(bool sawRate, bool sawDown) { + if (sawRate && sawDown) { + return '所选更新源暂时限制了请求次数,另一个也连不上,没有检查到更新'; + } + if (sawRate) { + return 'YanJiu Git 和 GitHub 都暂时限制了请求次数,请稍后再试'; + } + return 'YanJiu Git 和 GitHub 都连不上,没有检查到更新'; } diff --git a/client/test/expandable_hint_test.dart b/client/test/expandable_hint_test.dart new file mode 100644 index 0000000..cbafa91 --- /dev/null +++ b/client/test/expandable_hint_test.dart @@ -0,0 +1,73 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:netquality/main.dart'; +import 'package:netquality/models/port_field.dart'; +import 'package:netquality/ui/expandable_hint.dart'; +import 'package:shared_preferences/shared_preferences.dart'; + +void main() { + testWidgets('short hint text is not a button', (tester) async { + await tester.pumpWidget( + const MaterialApp( + home: Scaffold(body: ExpandableHint(text: 'HTTP 默认 5000 毫秒')), + ), + ); + expect(find.byType(InkWell), findsNothing); + final text = tester.widget(find.text('HTTP 默认 5000 毫秒')); + expect(text.maxLines, isNull); + expect(text.overflow, TextOverflow.clip); + }); + + testWidgets('a long hint expands and collapses', (tester) async { + const long = + 'only the current port follows the previous default when it is empty or still that default'; + await tester.pumpWidget( + const MaterialApp( + home: Scaffold( + body: SizedBox(width: 160, child: ExpandableHint(text: long)), + ), + ), + ); + Text shown() => tester.widget(find.text(long)); + expect(shown().maxLines, 1); + expect(shown().overflow, TextOverflow.ellipsis); + expect(find.byType(InkWell), findsOneWidget); + + await tester.tap(find.text(long)); + await tester.pump(); + expect(shown().maxLines, isNull); + + await tester.tap(find.text(long)); + await tester.pump(); + expect(shown().maxLines, 1); + expect(shown().overflow, TextOverflow.ellipsis); + }); + + testWidgets('the port helper on a phone can be expanded', (tester) async { + SharedPreferences.setMockInitialValues({}); + tester.view.physicalSize = const Size(390, 844); + tester.view.devicePixelRatio = 1; + addTearDown(tester.view.resetPhysicalSize); + addTearDown(tester.view.resetDevicePixelRatio); + await tester.pumpWidget(const NetQualityApp()); + await tester.pumpAndSettle(); + + final hint = find.text(portHelperText); + await tester.ensureVisible(hint); + await tester.pumpAndSettle(); + Text shown() => tester.widget(hint); + expect(shown().maxLines, 1); + expect(shown().overflow, TextOverflow.ellipsis); + + await tester.tap(hint); + await tester.pumpAndSettle(); + expect(shown().maxLines, isNull); + expect(shown().overflow, TextOverflow.clip); + expect(find.textContaining('切换类型才会自动更换'), findsOneWidget); + + await tester.ensureVisible(hint); + await tester.tap(hint); + await tester.pumpAndSettle(); + expect(shown().maxLines, 1); + }); +} diff --git a/client/test/update_source_test.dart b/client/test/update_source_test.dart new file mode 100644 index 0000000..26385f1 --- /dev/null +++ b/client/test/update_source_test.dart @@ -0,0 +1,503 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:netquality/content/release_history.dart'; +import 'package:netquality/main.dart'; +import 'package:netquality/models/session_config.dart'; +import 'package:netquality/storage/app_store.dart'; +import 'package:netquality/update/release_feed.dart'; +import 'package:netquality/update/update_check.dart'; +import 'package:shared_preferences/shared_preferences.dart'; + +const _endpoints = UpdateEndpoints( + github: 'https://github.example/repos/yanjiu0721/netquality/releases/latest', + gitea: 'https://git.example/api/v1/repos/YanJiu/netquality/releases/latest', +); + +const _bundledOnly = ReleaseEntry( + version: '0.9.1', + title: '安装包里的说明', + source: 'bundle', + points: ['只在安装包里'], +); + +const _feed = ''' +[ + { + "tag_name": "v1.1.9", + "name": "网络质量探测 1.1.9", + "draft": false, + "prerelease": false, + "published_at": "2026-12-01T08:00:00Z", + "body": "# 网络质量探测 1.1.9\\n\\n## 在线历史\\n\\n- 可以读取比已安装版本更新的说明\\n\\n见 [发布页](https://example.test/r)。" + }, + { + "tag_name": "v1.1.3", + "name": "网络质量探测 1.1.3", + "published_at": "2026-11-21T21:51:01+08:00", + "body": "构建号 6。" + }, + { + "tag_name": "v1.2.0-rc.1", + "name": "网络质量探测 1.2.0 rc", + "prerelease": true, + "published_at": "2026-12-02T00:00:00Z", + "body": "预发布说明" + }, + { + "tag_name": "v9.9.9", + "name": "不要出现的草稿", + "draft": true, + "body": "秘密" + }, + { + "tag_name": "nightly", + "name": "不是版本号", + "body": "跳过" + } +] +'''; + +const _linuxAsset = ''' +{"tag_name":"v1.1.9","assets":[ + {"name":"netquality-client-1.1.9-linux-amd64.tar.gz","browser_download_url":"https://example.test/a.tar.gz"} +]} +'''; + +void main() { + test('the saved update source defaults to YanJiu Git', () { + expect(SessionConfig.defaults.updateSource, 'gitea'); + expect(parseUpdateSource(null), UpdateSource.gitea); + expect(parseUpdateSource('github'), UpdateSource.github); + expect(parseUpdateSource('GitHub'), UpdateSource.gitea); + final stored = SessionConfig.fromJson({ + ...SessionConfig.defaults.toJson(), + 'updateSource': 'github', + }); + expect(stored.updateSource, 'github'); + expect(stored.toJson()['updateSource'], 'github'); + final unknown = SessionConfig.fromJson({ + ...SessionConfig.defaults.toJson(), + 'updateSource': 'somewhere-else', + }); + expect(unknown.updateSource, 'gitea'); + final missing = SessionConfig.defaults.toJson()..remove('updateSource'); + expect(SessionConfig.fromJson(missing).updateSource, 'gitea'); + }); + + test('env overrides replace only a non-empty release URL', () { + expect(updateEndpoints().github, UpdateEndpoints.githubDefault); + expect(updateEndpoints().gitea, UpdateEndpoints.giteaDefault); + expect( + updateEndpoints(githubApi: ' ').github, + UpdateEndpoints.githubDefault, + ); + final overridden = updateEndpoints( + githubApi: ' https://example.test/latest ', + giteaApi: 'https://git.example/latest', + ); + expect(overridden.github, 'https://example.test/latest'); + expect(overridden.gitea, 'https://git.example/latest'); + }); + + test( + 'a chosen source that answers is named and the other is not called', + () async { + final hosts = []; + final check = await findUpdate( + current: '1.1.3', + preferred: UpdateSource.gitea, + endpoints: _endpoints, + os: 'linux', + arch: 'amd64', + fetch: (url) async { + hosts.add(url.host); + return _linuxAsset; + }, + ); + expect(hosts, ['git.example']); + expect(check.used, UpdateSource.gitea); + expect(check.fellBack, isFalse); + expect(check.offer?.version, '1.1.9'); + expect(check.offer?.assetUrl, 'https://example.test/a.tar.gz'); + expect(check.message, contains('这次用的是 YanJiu Git')); + expect(check.message, isNot(contains('改用'))); + }, + ); + + test( + 'an unreachable chosen source falls back and names the one that worked', + () async { + final check = await findUpdate( + current: '1.1.3', + preferred: UpdateSource.gitea, + endpoints: _endpoints, + os: 'linux', + arch: 'amd64', + fetch: (url) async => url.host == 'git.example' ? null : _linuxAsset, + ); + expect(check.used, UpdateSource.github); + expect(check.fellBack, isTrue); + expect(check.message, contains('YanJiu Git 连不上')); + expect(check.message, contains('这次用的是 GitHub')); + }, + ); + + test( + 'a rate limit falls back and the message says which source was used', + () async { + final check = await findUpdate( + current: '1.1.3', + preferred: UpdateSource.gitea, + endpoints: _endpoints, + os: 'linux', + arch: 'amd64', + fetch: (url) async { + if (url.host == 'git.example') { + throw const UpdateFetchException(rateLimited: true, status: 429); + } + return _linuxAsset; + }, + ); + expect(check.used, UpdateSource.github); + expect(check.message, contains('暂时限制了请求次数')); + expect(check.message, contains('这次用的是 GitHub')); + }, + ); + + test('both sources down, or both rate limited, stay unnamed', () async { + final down = await findUpdate( + current: '1.1.3', + preferred: UpdateSource.gitea, + endpoints: _endpoints, + os: 'linux', + arch: 'amd64', + fetch: (_) async => null, + ); + expect(down.reachable, isFalse); + expect(down.used, isNull); + expect(down.message, 'YanJiu Git 和 GitHub 都连不上,没有检查到更新'); + + final limited = await findUpdate( + current: '1.1.3', + preferred: UpdateSource.github, + endpoints: _endpoints, + os: 'linux', + arch: 'amd64', + fetch: (_) async { + throw const UpdateFetchException(rateLimited: true, status: 403); + }, + ); + expect(limited.message, contains('都暂时限制了请求次数')); + }); + + test( + 'rate-limit responses are recognized without treating every 403 as one', + () { + expect(isReleaseRateLimited(status: 429, body: ''), isTrue); + expect( + isReleaseRateLimited(status: 403, rateLimitRemaining: '0', body: 'no'), + isTrue, + ); + expect( + isReleaseRateLimited( + status: 403, + body: 'API rate limit exceeded for 1.2.3.4', + ), + isTrue, + ); + expect(isReleaseRateLimited(status: 403, body: 'forbidden'), isFalse); + expect(isReleaseRateLimited(status: 200, body: 'rate limit'), isFalse); + }, + ); + + test('list URLs follow the latest override and the forge page size', () { + final gitea = releaseListUri( + _endpoints.gitea, + source: UpdateSource.gitea, + page: 2, + pageSize: 50, + ); + expect(gitea.path, '/api/v1/repos/YanJiu/netquality/releases'); + expect(gitea.queryParameters['limit'], '50'); + expect(gitea.queryParameters['page'], '2'); + expect(gitea.queryParameters.containsKey('per_page'), isFalse); + + final github = releaseListUri( + _endpoints.github, + source: UpdateSource.github, + page: 1, + pageSize: 100, + ); + expect(github.path, '/repos/yanjiu0721/netquality/releases'); + expect(github.queryParameters['per_page'], '100'); + expect(github.queryParameters.containsKey('limit'), isFalse); + }); + + test('a release list keeps newer published notes and drops drafts', () async { + final result = await syncReleaseHistory( + preferred: UpdateSource.gitea, + endpoints: _endpoints, + bundled: const [_bundledOnly], + fetch: (url) async { + expect(url.host, 'git.example'); + return _feed; + }, + ); + expect(result.origin, HistoryOrigin.remote); + expect(result.used, UpdateSource.gitea); + expect(result.entries.map((entry) => entry.version), [ + '1.2.0', + '1.1.9', + '1.1.3', + ]); + expect(result.entries.map((entry) => entry.tag), [ + 'v1.2.0-rc.1', + 'v1.1.9', + 'v1.1.3', + ]); + final newest = result.entries[1]; + expect(newest.title, '网络质量探测 1.1.9'); + expect(newest.published, '2026-12-01'); + expect(newest.points, contains('可以读取比已安装版本更新的说明')); + expect(newest.points, contains('见 发布页(https://example.test/r)。')); + expect(newest.points, isNot(contains('网络质量探测 1.1.9'))); + expect(result.entries.first.source, contains('预发布')); + expect(result.entries.first.published, '2026-12-02'); + expect( + result.entries.map((entry) => entry.title), + isNot(contains('不要出现的草稿')), + ); + expect( + result.entries.map((entry) => entry.version), + isNot(contains('0.9.1')), + ); + expect( + result.entries.map((entry) => entry.version), + isNot(contains('1.1.0')), + ); + expect(result.note, contains('已从 YanJiu Git 同步')); + expect(result.note, contains('比当前安装更新的发布也会列在这里')); + final again = decodeReleaseCache(result.cacheJson); + expect(again?.source, 'gitea'); + expect(again?.entries.map((entry) => entry.version), [ + '1.2.0', + '1.1.9', + '1.1.3', + ]); + }); + + test('pages are followed, and a full last page says the list may be short', () async { + final pages = []; + final result = await syncReleaseHistory( + preferred: UpdateSource.github, + endpoints: _endpoints, + githubPageSize: 1, + fetch: (url) async { + expect(url.host, 'github.example'); + expect(url.queryParameters['per_page'], '1'); + expect(url.path, isNot(endsWith('/latest'))); + final page = int.parse(url.queryParameters['page']!); + pages.add(page); + if (page == 1) { + return '[{"tag_name":"v1.1.9","name":"新","published_at":"2026-12-01T00:00:00Z","body":"新说明"}]'; + } + if (page == 2) { + return '[{"tag_name":"v1.1.3","name":"旧","published_at":"2026-11-21T00:00:00Z","body":"旧说明"}]'; + } + return '[]'; + }, + ); + expect(pages, [1, 2, 3]); + expect(result.entries.map((entry) => entry.version), ['1.1.9', '1.1.3']); + + final capped = await syncReleaseHistory( + preferred: UpdateSource.gitea, + endpoints: _endpoints, + pageLimit: 1, + giteaPageSize: 1, + fetch: (_) async => '[{"tag_name":"v1.1.9","name":"新","body":"只有第一页"}]', + ); + expect(capped.entries, hasLength(1)); + expect(capped.note, contains('没有取完')); + }); + + test( + 'history uses the spare source when the chosen one cannot be read', + () async { + final result = await syncReleaseHistory( + preferred: UpdateSource.gitea, + endpoints: _endpoints, + bundled: const [_bundledOnly], + fetch: (url) async { + if (url.host == 'git.example') { + throw const UpdateFetchException(rateLimited: true, status: 429); + } + return _feed; + }, + ); + expect(result.used, UpdateSource.github); + expect(result.note, contains('暂时限制了请求次数')); + expect(result.note, contains('这次改用了 GitHub')); + expect(result.entries.first.version, '1.2.0'); + expect(result.entries.any((entry) => entry.version == '0.9.1'), isFalse); + }, + ); + + test( + 'a failed sync keeps the cache, then the bundled notes, and says so', + () async { + String? stored; + final fresh = await syncAndStore( + preferred: UpdateSource.gitea, + endpoints: _endpoints, + readCache: () async => null, + writeCache: (json) async => stored = json, + fetch: (url) async => url.host == 'git.example' ? _feed : null, + ); + expect(fresh.origin, HistoryOrigin.remote); + expect(stored, isNotNull); + + final cached = await syncReleaseHistory( + preferred: UpdateSource.gitea, + endpoints: _endpoints, + cachedJson: stored, + bundled: const [_bundledOnly], + fetch: (_) async => null, + ); + expect(cached.origin, HistoryOrigin.cache); + expect(cached.entries.first.version, '1.2.0'); + expect(cached.note, contains('可能不是最新')); + expect(cached.note, contains('上次从 YanJiu Git 保存的列表')); + expect(cached.entries.any((entry) => entry.version == '0.9.1'), isFalse); + + final bundled = await syncReleaseHistory( + preferred: UpdateSource.github, + endpoints: _endpoints, + cachedJson: '{', + bundled: const [_bundledOnly], + fetch: (_) async => null, + ); + expect(bundled.origin, HistoryOrigin.bundled); + expect(bundled.entries, [_bundledOnly]); + expect(bundled.note, contains('没有保存过在线列表')); + expect(bundled.note, contains('安装包里的说明')); + expect(bundled.note, contains('可能不是最新')); + + final limited = await syncReleaseHistory( + preferred: UpdateSource.gitea, + endpoints: _endpoints, + cachedJson: null, + bundled: const [_bundledOnly], + fetch: (_) async { + throw const UpdateFetchException(rateLimited: true, status: 429); + }, + ); + expect(limited.origin, HistoryOrigin.bundled); + expect(limited.note, contains('暂时限制了请求次数')); + expect(limited.note, contains('可能不是最新')); + }, + ); + + test( + 'an empty published list is kept and does not invent bundled versions', + () async { + final result = await syncReleaseHistory( + preferred: UpdateSource.gitea, + endpoints: _endpoints, + bundled: const [_bundledOnly], + fetch: (_) async => '[]', + ); + expect(result.origin, HistoryOrigin.remote); + expect(result.entries, isEmpty); + expect(result.note, contains('没有已发布的版本')); + expect(result.cacheJson, isNotNull); + }, + ); + + testWidgets('settings defaults to YanJiu Git and remembers GitHub', ( + tester, + ) async { + SharedPreferences.setMockInitialValues({}); + tester.view.physicalSize = const Size(900, 1600); + tester.view.devicePixelRatio = 1; + addTearDown(tester.view.resetPhysicalSize); + addTearDown(tester.view.resetDevicePixelRatio); + await tester.pumpWidget(const NetQualityApp()); + await tester.pumpAndSettle(); + + await _openSettings(tester); + expect(_selectedSource(tester), {UpdateSource.gitea}); + expect(find.textContaining('先试 GitHub'), findsNothing); + expect(find.textContaining('先问 GitHub'), findsNothing); + expect(find.textContaining('结果里会写明这次实际用的是哪一个'), findsOneWidget); + + await tester.tap( + find.descendant( + of: find.byKey(const Key('update-source')), + matching: find.text('GitHub'), + ), + ); + await tester.pumpAndSettle(); + expect(_selectedSource(tester), {UpdateSource.github}); + + final prefs = await SharedPreferences.getInstance(); + expect( + prefs.getString('netquality.settings.v2'), + contains('"updateSource":"github"'), + ); + final loaded = await AppStore().load(); + expect(loaded.config.updateSource, 'github'); + expect(parseUpdateSource(loaded.config.updateSource), UpdateSource.github); + }); + + testWidgets('history shows a cached release newer than this install', ( + tester, + ) async { + final cache = encodeReleaseCache( + source: 'gitea', + entries: const [ + ReleaseEntry( + version: '9.9.9', + tag: 'v9.9.9', + title: '网络质量探测 9.9.9', + source: '来自 YanJiu Git · 标签 v9.9.9', + published: '2026-12-01', + points: ['比已安装的版本新'], + ), + ], + ); + SharedPreferences.setMockInitialValues({releaseHistoryCacheKey: cache}); + tester.view.physicalSize = const Size(900, 1400); + tester.view.devicePixelRatio = 1; + addTearDown(tester.view.resetPhysicalSize); + addTearDown(tester.view.resetDevicePixelRatio); + await tester.pumpWidget(const NetQualityApp()); + await tester.pumpAndSettle(); + + await tester.tap(find.byType(PopupMenuButton)); + await tester.pumpAndSettle(); + await tester.tap(find.text('更新历史')); + await tester.pumpAndSettle(); + + expect(find.text('网络质量探测 9.9.9'), findsOneWidget); + expect(find.text('比当前安装的 1.1.3 新'), findsOneWidget); + expect(find.text('网络质量探测 1.1.1'), findsNothing); + expect(find.textContaining('已经发布的 1.1.2 和 1.1.3'), findsOneWidget); + expect(find.textContaining('可能不是最新'), findsNothing); + }); +} + +Set _selectedSource(WidgetTester tester) { + return tester + .widget>( + find.byKey(const Key('update-source')), + ) + .selected; +} + +Future _openSettings(WidgetTester tester) async { + await tester.tap(find.byType(PopupMenuButton)); + await tester.pumpAndSettle(); + await tester.tap(find.text('设置')); + await tester.pumpAndSettle(); +} diff --git a/client/test/v113_test.dart b/client/test/v113_test.dart index f36a885..b1cc98a 100644 --- a/client/test/v113_test.dart +++ b/client/test/v113_test.dart @@ -50,6 +50,7 @@ void main() { test('github failure falls through to the spare source', () async { final check = await findUpdate( current: '1.1.3', + preferred: UpdateSource.github, endpoints: const UpdateEndpoints( github: 'https://github.invalid/latest', gitea: 'https://git.invalid/latest', @@ -68,6 +69,10 @@ void main() { }, ); expect(check.offer?.version, '1.1.9'); + expect(check.used, UpdateSource.gitea); + expect(check.fellBack, isTrue); + expect(check.message, contains('GitHub')); + expect(check.message, contains('YanJiu Git')); }); test('history keeps the newest identical target and can delete or clear', () { From 1178263601a294739a5340e159e64a93aa2cfc3a Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Fri, 27 Nov 2026 07:46:36 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=E8=AE=A9=E6=A1=8C=E9=9D=A2=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E8=AE=A4=E5=87=BA=E7=8E=B0=E6=9C=89=E7=9A=84=20x64=20?= =?UTF-8?q?=E5=AE=89=E8=A3=85=E5=8C=85=EF=BC=8C=E5=B9=B6=E6=8A=8A=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E5=8D=87=E5=88=B0=201.1.4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 已发布的桌面压缩包是 linux-x64 和 windows-x64。更新器现在把单独的 x64 当成 amd64,并继续接受 amd64、x86_64 和 aarch64。带 server 或 reflector 的包仍然跳过。 版本名 1.1.4,构建号 7。署名仍是言灸。说明里写上更新源、在线更新历史、可展开提示、HTTP 网址目标和这次的文件名修复。没有打标签,也没有发布。 Co-authored-by: yanjiu0721 --- README.md | 6 +- client/README.md | 2 +- client/lib/content/release_history.dart | 21 +++++- client/lib/ui/settings_page.dart | 2 +- client/lib/update/update_check.dart | 33 ++++++++-- client/lib/version.dart | 4 +- client/packaging/README-linux.md | 2 +- client/pubspec.yaml | 2 +- client/test/address_display_test.dart | 6 +- client/test/update_source_test.dart | 2 +- client/test/v113_test.dart | 86 +++++++++++++++++++++++++ docs/release-notes/1.1.4.md | 52 +++++++++++++++ docs/server-linux.md | 2 +- server/README.md | 2 +- server/selection.go | 2 +- 15 files changed, 200 insertions(+), 24 deletions(-) create mode 100644 docs/release-notes/1.1.4.md diff --git a/README.md b/README.md index 9eb9e46..4e039ff 100644 --- a/README.md +++ b/README.md @@ -104,9 +104,9 @@ cd server && go test -race ./... cd client && flutter analyze && flutter test ``` -Android 安装包是按 CPU 分开的 release 包,使用调试证书,只适合测试安装,不是应用商店签名。当前版本名 `1.1.3`,构建号 `6`。应用标识没有改。1.1.3 以及以后的版本必须用仓库里的 [client/android/keystore/debug.keystore](client/android/keystore/debug.keystore) 签名,这样后一版才能覆盖安装。1.1.2 的证书不同,升到 1.1.3 要先卸载。 +Android 安装包是按 CPU 分开的 release 包,使用调试证书,只适合测试安装,不是应用商店签名。当前版本名 `1.1.4`,构建号 `7`。应用标识没有改。1.1.3 以及以后的版本必须用仓库里的 [client/android/keystore/debug.keystore](client/android/keystore/debug.keystore) 签名,这样后一版才能覆盖安装。1.1.2 的证书不同,升到 1.1.3 要先卸载。 -从 1.1.3 起,客户端可以检查更新,设置里可以关掉,也可以选择更新源。默认先问 YanJiu Git(`https://git.yanjiu.ltd/YanJiu/netquality/releases`),连不上再问 GitHub Releases。结果里会写明这次实际用的是哪一个。1.1.2 没有这个功能,所以 1.1.2 升到 1.1.3 仍然要自己安装。已经发布的 1.1.2 和 1.1.3 安装包也没有在线更新历史。Windows 和 Linux 会把新文件写回当前安装目录。Android 会弹出系统安装确认,这一步不能跳过。没有真正的新版本时,可以用环境变量 `NQ_UPDATE_GITHUB_API` 和 `NQ_UPDATE_GITEA_API` 指向一份同样格式的测试响应。 +从 1.1.3 起,客户端可以检查更新,设置里可以关掉。从 1.1.4 起可以选择更新源,默认先问 YanJiu Git(`https://git.yanjiu.ltd/YanJiu/netquality/releases`),连不上再问 GitHub Releases。结果里会写明这次实际用的是哪一个。桌面安装包的文件名是 `linux-x64` 和 `windows-x64`,更新器也认以前的 `amd64`、`x86_64`、`aarch64`。1.1.2 没有自更新。1.1.3 的桌面更新器认不出 `x64`,所以 1.1.2 和 1.1.3 升到 1.1.4 仍然要自己安装。已经发布的 1.1.2 和 1.1.3 安装包也没有在线更新历史。Windows 和 Linux 会把新文件写回当前安装目录。Android 会弹出系统安装确认,这一步不能跳过。没有真正的新版本时,可以用环境变量 `NQ_UPDATE_GITHUB_API` 和 `NQ_UPDATE_GITEA_API` 指向一份同样格式的测试响应。 中心也是这个 Go 程序。示例配置在 [server/example-center](server/example-center),里面的口令都是占位。本机可以这样看目录: @@ -118,7 +118,7 @@ go build -o netquality-reflector . 客户端点「一键添加服务器」,中心地址填 `http://127.0.0.1:8443`,账号 `lab`,口令 `example-token`。这只适合本机确认功能。真正给别人用时,控制端口要走 HTTPS。 -这一版的说明在 [docs/release-notes/1.1.3.md](docs/release-notes/1.1.3.md)。 +这一版的说明在 [docs/release-notes/1.1.4.md](docs/release-notes/1.1.4.md)。 ## 许可 diff --git a/client/README.md b/client/README.md index edeeca9..34e815b 100644 --- a/client/README.md +++ b/client/README.md @@ -7,4 +7,4 @@ flutter pub get flutter run -d linux ``` -默认用本机去测 `127.0.0.1` 的合作反射 TCP `19090`。合作反射 UDP 默认 `19091`。先在 `../server` 里启动反射服务,再点「开始探测」。要让另一台机器代测时,把来源改成「远程节点」。当前版本是 1.1.3。HTTP 的目标是完整网址,或只写主机名(按 http、端口 80),不再单独填端口,超时默认 5000 毫秒。本机 HTTP 探测需要旁边有 `netquality-reflector`,或设置 `NQ_PROBE_HELPER`;找不到或启动不了时会立刻说明,并建议改用远程节点。Android 安装包不包含这个程序。指标怎么读、这一版改了什么,在应用里的「指标说明」和「更新历史」。 +默认用本机去测 `127.0.0.1` 的合作反射 TCP `19090`。合作反射 UDP 默认 `19091`。先在 `../server` 里启动反射服务,再点「开始探测」。要让另一台机器代测时,把来源改成「远程节点」。当前版本是 1.1.4。HTTP 的目标是完整网址,或只写主机名(按 http、端口 80),不再单独填端口,超时默认 5000 毫秒。本机 HTTP 探测需要旁边有 `netquality-reflector`,或设置 `NQ_PROBE_HELPER`;找不到或启动不了时会立刻说明,并建议改用远程节点。Android 安装包不包含这个程序。指标怎么读、这一版改了什么,在应用里的「指标说明」和「更新历史」。 diff --git a/client/lib/content/release_history.dart b/client/lib/content/release_history.dart index 7f69597..ce85e2c 100644 --- a/client/lib/content/release_history.dart +++ b/client/lib/content/release_history.dart @@ -56,10 +56,24 @@ class ReleaseEntry { } const releaseHistory = [ + ReleaseEntry( + version: '1.1.4', + title: '网络质量探测 1.1.4', + source: + '仓库 docs/release-notes/1.1.4.md。署名言灸。这一版的 Git 标签要等发布时才有,这里写的是即将发布的内容。', + points: [ + '设置里可以选择更新源,默认是 YanJiu Git,也可以改成 GitHub。检查和下载都先用选中的源,连不上再试另一个,结果里会写明这次实际用的是哪一个。', + '「更新历史」会读取所选源的发布列表,包括比当前安装更新的版本,并在本机留一份。网络失败时用上次保存的列表,没有保存过再用安装包里的说明,并标明可能不是最新。已经发出的 1.1.2 和 1.1.3 没有这份同步。', + '表单里被省略号截断的提示可以点开看全文,再点一次收回。本来就显示得下的短句不用点。', + 'HTTP 目标填完整网址,或只写主机名、IP。只写主机名时按 http 和端口 80,不再单独填端口。超时默认 5000 毫秒。本机找不到探测引擎时会立刻说明,并建议改用远程节点。', + '桌面自更新认得已经发布的 linux-x64、windows-x64 文件名,也仍然接受 amd64、x86_64、aarch64。名字里带 server 或 reflector 的包不会被选中。1.1.3 的桌面更新器认不出 x64,升到 1.1.4 仍要手动安装。', + ], + ), ReleaseEntry( version: '1.1.3', title: '网络质量探测 1.1.3', - source: '仓库 docs/release-notes/1.1.3.md。这一版的 Git 标签要等发布时才有,这里写的是即将发布的内容。', + published: '2026-11-21', + source: 'Git 标签 v1.1.3,以及 GitHub Release「网络质量探测 1.1.3」(发布于 2026-11-21)。', points: [ '可以自动检查更新,也能在设置里关掉。先问 GitHub,连不上再用备用 Git。1.1.2 没有这个功能,升到 1.1.3 仍要手动安装。从这一版起,新版本才会自己下载并覆盖安装。', 'Windows 和 Linux 覆盖进现有安装目录。设置、已保存的节点、口令和探测历史仍在应用自己的数据目录里,不会被安装包清掉。', @@ -72,7 +86,8 @@ const releaseHistory = [ ReleaseEntry( version: '1.1.2', title: '网络质量探测 1.1.2', - source: '仓库 docs/release-notes/1.1.2.md。这一版的 Git 标签要等发布时才有,这里写的是即将发布的内容。', + published: '2026-11-20', + source: 'Git 标签 v1.1.2,以及 GitHub Release「网络质量探测 1.1.2」(发布于 2026-11-20)。', points: [ '可以修改已有远程节点的名称、控制地址和口令。节点编号和当前选择保持不变。口令留空表示不改,界面不显示已经保存的口令。', '端口框标明当前类型的默认端口。合作反射 TCP 是 19090,UDP 是 19091。只有端口仍是上一种类型的默认值,或端口是空的,切换类型才会自动更换。', @@ -100,7 +115,7 @@ const releaseHistory = [ ]; const releaseHistoryNote = - '仓库里目前公开的版本标签只有 v1.1.1。1.1.1 的发布说明提到过更早的发包行为,但没有单独的标签或 Release,所以这里不写成另一个版本。'; + '仓库里公开的版本标签有 v1.1.1、v1.1.2 和 v1.1.3。1.1.4 的标签要等发布时才有。1.1.1 的发布说明提到过更早的发包行为,但没有单独的标签或 Release,所以这里不写成另一个版本。'; /// Already shipped installers cannot grow this screen. The sentence stays /// visible so the app does not imply that 1.1.2 or 1.1.3 already sync notes. diff --git a/client/lib/ui/settings_page.dart b/client/lib/ui/settings_page.dart index 9c7f641..8f1a326 100644 --- a/client/lib/ui/settings_page.dart +++ b/client/lib/ui/settings_page.dart @@ -191,7 +191,7 @@ class _SettingsPageState extends State { Padding( padding: const EdgeInsets.fromLTRB(16, 0, 16, 8), child: Text( - '当前版本 $appVersion(构建 $appBuild)。1.1.2 没有自更新,从 1.1.2 升到 1.1.3 仍要手动安装。更新源默认是 YanJiu Git,也可以改成 GitHub。检查更新和下载都先用选中的源,连不上再试另一个,结果里会写明这次实际用的是哪一个。\n\n「更新历史」会读取所选源的发布列表,并在本机留一份。网络失败时用上次保存的列表,没有保存过再用安装包里的说明,并标明可能不是最新。已经发出的 1.1.2 和 1.1.3 安装包没有这份同步。\n\n要在没有新版本时试检查更新,可以把环境变量 NQ_UPDATE_GITHUB_API 指到一个同样格式的测试地址,NQ_UPDATE_GITEA_API 是另一个。', + '当前版本 $appVersion(构建 $appBuild)。1.1.2 没有自更新,从 1.1.2 升级仍要手动安装。1.1.3 的桌面更新器认不出已经发布的 linux-x64、windows-x64 文件名,所以从 1.1.3 升到 1.1.4 仍要手动安装。这一版两种名字都认,也仍然接受 amd64、x86_64 和 aarch64。带 server 或 reflector 的包不会被选中。更新源默认是 YanJiu Git,也可以改成 GitHub。检查更新和下载都先用选中的源,连不上再试另一个,结果里会写明这次实际用的是哪一个。\n\n「更新历史」会读取所选源的发布列表,并在本机留一份。网络失败时用上次保存的列表,没有保存过再用安装包里的说明,并标明可能不是最新。已经发出的 1.1.2 和 1.1.3 安装包没有这份同步。\n\n要在没有新版本时试检查更新,可以把环境变量 NQ_UPDATE_GITHUB_API 指到一个同样格式的测试地址,NQ_UPDATE_GITEA_API 是另一个。', style: const TextStyle( color: Color(0xFF5C656B), fontSize: 13, diff --git a/client/lib/update/update_check.dart b/client/lib/update/update_check.dart index 5905667..8912ba7 100644 --- a/client/lib/update/update_check.dart +++ b/client/lib/update/update_check.dart @@ -168,7 +168,32 @@ class UpdateCheck { final bool fellBack; } -/// Picks the client archive for this OS and CPU. Server packages are ignored. +/// A bare `x64` token, as in `linux-x64`. `x86_64` does not contain this. +final _bareX64 = RegExp(r'(^|[^a-z0-9])x64([^a-z0-9]|$)'); + +/// Published desktop archives use `linux-x64` and `windows-x64`. Older +/// names used `amd64`, `x86_64`, or `aarch64`. Those still match. +bool _desktopArchMatches(String name, String wantArch) { + if (name.contains(wantArch)) { + return true; + } + switch (wantArch) { + case 'amd64': + case 'x86_64': + case 'x64': + return name.contains('amd64') || + name.contains('x86_64') || + _bareX64.hasMatch(name); + case 'arm64': + case 'aarch64': + return name.contains('arm64') || name.contains('aarch64'); + default: + return false; + } +} + +/// Picks the client archive for this OS and CPU. Server and reflector +/// packages are ignored. String? pickClientAsset( List assets, { required String os, @@ -187,11 +212,7 @@ String? pickClientAsset( } continue; } - final archOk = - name.contains(wantArch) || - (wantArch == 'amd64' && name.contains('x86_64')) || - (wantArch == 'arm64' && name.contains('aarch64')); - if (!archOk || !name.contains(wantOs)) { + if (!_desktopArchMatches(name, wantArch) || !name.contains(wantOs)) { continue; } if (wantOs == 'windows' && diff --git a/client/lib/version.dart b/client/lib/version.dart index 0ed71d7..e001598 100644 --- a/client/lib/version.dart +++ b/client/lib/version.dart @@ -1,7 +1,7 @@ // Copyright (C) 2026 言灸 // SPDX-License-Identifier: AGPL-3.0-only -const appVersion = '1.1.3'; -const appBuild = 6; +const appVersion = '1.1.4'; +const appBuild = 7; const appAttribution = '言灸'; const appLicense = 'AGPL-3.0-only'; diff --git a/client/packaging/README-linux.md b/client/packaging/README-linux.md index 2d3f3f4..219042b 100644 --- a/client/packaging/README-linux.md +++ b/client/packaging/README-linux.md @@ -1,6 +1,6 @@ # 网络质量探测 · Linux 桌面客户端 -这是 1.1.3 的 Linux 64 位桌面程序,解压后可以直接运行。不需要再安装 Flutter。HTTP 探测还需要同一目录里的 `netquality-reflector`。找不到或启动不了时,程序会立刻提示改用远程节点,不会把这次记成全部失败。 +这是 1.1.4 的 Linux 64 位桌面程序,解压后可以直接运行。不需要再安装 Flutter。HTTP 探测还需要同一目录里的 `netquality-reflector`。找不到或启动不了时,程序会立刻提示改用远程节点,不会把这次记成全部失败。 ## 先安装系统库 diff --git a/client/pubspec.yaml b/client/pubspec.yaml index 5880fdb..bd98ec4 100644 --- a/client/pubspec.yaml +++ b/client/pubspec.yaml @@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # In Windows, build-name is used as the major, minor, and patch parts # of the product and file versions while build-number is used as the build suffix. -version: 1.1.3+6 +version: 1.1.4+7 environment: sdk: ^3.13.7 diff --git a/client/test/address_display_test.dart b/client/test/address_display_test.dart index 416b821..721bd88 100644 --- a/client/test/address_display_test.dart +++ b/client/test/address_display_test.dart @@ -84,10 +84,12 @@ void main() { }); test('history only lists the real tag and this version', () { - expect(appVersion, '1.1.3'); - expect(appBuild, 6); + expect(appVersion, '1.1.4'); + expect(appBuild, 7); expect(appAttribution, '言灸'); + expect(releaseHistory.first.source, contains('言灸')); expect(releaseHistory.map((entry) => entry.version), [ + '1.1.4', '1.1.3', '1.1.2', '1.1.1', diff --git a/client/test/update_source_test.dart b/client/test/update_source_test.dart index 26385f1..80b8064 100644 --- a/client/test/update_source_test.dart +++ b/client/test/update_source_test.dart @@ -480,7 +480,7 @@ void main() { await tester.pumpAndSettle(); expect(find.text('网络质量探测 9.9.9'), findsOneWidget); - expect(find.text('比当前安装的 1.1.3 新'), findsOneWidget); + expect(find.text('比当前安装的 1.1.4 新'), findsOneWidget); expect(find.text('网络质量探测 1.1.1'), findsNothing); expect(find.textContaining('已经发布的 1.1.2 和 1.1.3'), findsOneWidget); expect(find.textContaining('可能不是最新'), findsNothing); diff --git a/client/test/v113_test.dart b/client/test/v113_test.dart index b1cc98a..3fe7c97 100644 --- a/client/test/v113_test.dart +++ b/client/test/v113_test.dart @@ -47,6 +47,92 @@ void main() { expect(check.offer?.checksumName, 'SHA256SUMS'); }); + test('published x64 desktop names match, and server or reflector packages do not', () { + const published = [ + ReleaseFile(name: 'netquality-1.1.3-arm64-v8a.apk', url: 'a1'), + ReleaseFile(name: 'netquality-1.1.3-armeabi-v7a.apk', url: 'a2'), + ReleaseFile(name: 'netquality-1.1.3-linux-x64.tar.gz', url: 'linux'), + ReleaseFile(name: 'netquality-1.1.3-release-notes.txt', url: 'notes'), + ReleaseFile(name: 'netquality-1.1.3-SHA256SUMS.txt', url: 'sum'), + ReleaseFile(name: 'netquality-1.1.3-windows-x64.zip', url: 'win'), + ReleaseFile(name: 'netquality-1.1.3-x86_64.apk', url: 'a3'), + ReleaseFile(name: 'netquality-server-1.1.3-linux-amd64.tar.gz', url: 's1'), + ReleaseFile(name: 'netquality-server-1.1.3-linux-arm64.tar.gz', url: 's2'), + ReleaseFile(name: 'netquality-server-1.1.3-windows-amd64.zip', url: 's3'), + ReleaseFile(name: 'netquality-reflector-1.1.3-linux-x64.tar.gz', url: 'r'), + ]; + expect( + pickClientAsset(published, os: 'linux', arch: 'amd64'), + 'netquality-1.1.3-linux-x64.tar.gz', + ); + expect( + pickClientAsset(published, os: 'windows', arch: 'amd64'), + 'netquality-1.1.3-windows-x64.zip', + ); + expect( + pickClientAsset(published, os: 'android', arch: 'arm64-v8a'), + 'netquality-1.1.3-arm64-v8a.apk', + ); + expect( + pickClientAsset(published, os: 'android', arch: 'armeabi-v7a'), + 'netquality-1.1.3-armeabi-v7a.apk', + ); + expect( + pickClientAsset(published, os: 'android', arch: 'x86_64'), + 'netquality-1.1.3-x86_64.apk', + ); + expect( + pickClientAsset(const [ + ReleaseFile(name: 'netquality-server-1.1.3-linux-amd64.tar.gz', url: 's'), + ReleaseFile(name: 'netquality-reflector-1.1.3-linux-x64.tar.gz', url: 'r'), + ReleaseFile(name: 'netquality-server-1.1.3-windows-amd64.zip', url: 's'), + ], os: 'linux', arch: 'amd64'), + isNull, + ); + expect( + pickClientAsset(const [ + ReleaseFile(name: 'netquality-client-1.1.4-linux-x86_64.tar.gz', url: 'c'), + ], os: 'linux', arch: 'amd64'), + 'netquality-client-1.1.4-linux-x86_64.tar.gz', + ); + expect( + pickClientAsset(const [ + ReleaseFile(name: 'netquality-client-1.1.4-linux-aarch64.tar.gz', url: 'c'), + ], os: 'linux', arch: 'arm64'), + 'netquality-client-1.1.4-linux-aarch64.tar.gz', + ); + expect( + pickClientAsset(const [ + ReleaseFile(name: 'netquality-client-1.1.4-windows-amd64.zip', url: 'c'), + ], os: 'windows', arch: 'x64'), + 'netquality-client-1.1.4-windows-amd64.zip', + ); + expect( + pickClientAsset(const [ + ReleaseFile(name: 'netquality-1.1.4-linux-box64.tar.gz', url: 'no'), + ], os: 'linux', arch: 'amd64'), + isNull, + ); + + final check = interpretRelease( + current: '1.1.3', + os: 'linux', + arch: 'amd64', + body: ''' +{ + "tag_name": "v1.1.4", + "assets": [ + {"name": "netquality-server-1.1.4-linux-amd64.tar.gz", "browser_download_url": "https://example.test/server.tar.gz"}, + {"name": "netquality-1.1.4-linux-x64.tar.gz", "browser_download_url": "https://example.test/linux.tar.gz"}, + {"name": "netquality-1.1.4-windows-x64.zip", "browser_download_url": "https://example.test/windows.zip"} + ] +} +''', + ); + expect(check.offer?.assetName, 'netquality-1.1.4-linux-x64.tar.gz'); + expect(check.message, isNot(contains('没有适合这台设备的安装包'))); + }); + test('github failure falls through to the spare source', () async { final check = await findUpdate( current: '1.1.3', diff --git a/docs/release-notes/1.1.4.md b/docs/release-notes/1.1.4.md new file mode 100644 index 0000000..122b1a5 --- /dev/null +++ b/docs/release-notes/1.1.4.md @@ -0,0 +1,52 @@ +# 网络质量探测 1.1.4 + +版本名 `1.1.4`,构建号 `7`。署名:言灸。许可:GNU Affero General Public License v3.0(AGPL-3.0-only)。 + +应用标识和签名没有改。1.1.3 以及以后的安装包沿用仓库里的同一把调试证书,新的安装包会覆盖 1.1.3,不用先卸载。1.1.2 的证书不同,从 1.1.2 升级仍要先卸载。 + +这一版还没有打 Git 标签,也还没有发布安装包。下面是准备发布的说明。 + +## 更新源 + +设置里可以选择更新源:「YanJiu Git」或「GitHub」。默认是 YanJiu Git,因为这边的网络经常解析不到 github.com。检查更新和下载安装都先用选中的源。选中的源连不上,或暂时限制了请求次数时,会自动试另一个,结果里会写明这次实际用的是哪一个。 + +环境变量 `NQ_UPDATE_GITHUB_API` 和 `NQ_UPDATE_GITEA_API` 仍然可以指向一份同样格式的测试响应。 + +1.1.2 没有自更新,升级仍要自己安装。 + +## 更新历史 + +「更新历史」会向所选更新源读取发布列表,不只看最新一条。已经发布的版本都会列出来,包括比当前安装更新的版本。草稿和不是版本号的标签不会出现。 + +成功同步后会在本机留一份。网络失败时用上次保存的列表;没有保存过就用安装包里的说明,并标明这份列表可能不是最新。 + +已经发布的 1.1.2 和 1.1.3 安装包没有这份同步。那些版本不会自己看到以后的发布说明,需要先安装包含这个功能的版本。 + +## 被截断的说明 + +表单里放不下一行的提示,末尾会显示省略号。点一下展开全文,再点一下收回。本来就能显示完的短句不用点。 + +## HTTP 目标 + +HTTP 探测的目标是完整网址,或只写主机名、IP。完整网址沿用其中的协议、端口和路径。只写主机名或 IP 时按 http,端口 80,不再单独填端口。超时默认 5000 毫秒。 + +本机找不到或启动不了 `netquality-reflector` 时会立刻说明原因,并建议改用远程节点,不会把这次记成全部失败。Android 安装包不包含这个程序。 + +## 桌面安装包文件名 + +已经发布的桌面压缩包文件名是: + +- `netquality-1.1.3-linux-x64.tar.gz` +- `netquality-1.1.3-windows-x64.zip` + +1.1.3 的更新器只在名字里找 `amd64` 或 `x86_64`,所以桌面端会提示没有适合这台设备的安装包。1.1.3 升到 1.1.4 仍要手动安装。从这一版起,`linux-x64` 和 `windows-x64` 会被认成当前机器的 64 位包。以前的 `amd64`、`x86_64`、`aarch64` 也仍然接受。 + +名字里带 `server` 或 `reflector` 的包继续跳过,不会被客户端下载。Android 的 `arm64-v8a`、`armeabi-v7a`、`x86_64` 本来就能对上。 + +这一版准备发布的客户端文件名: + +- `netquality-1.1.4-windows-x64.zip` +- `netquality-1.1.4-linux-x64.tar.gz` +- `netquality-1.1.4-arm64-v8a.apk` +- `netquality-1.1.4-armeabi-v7a.apk` +- `netquality-1.1.4-x86_64.apk` diff --git a/docs/server-linux.md b/docs/server-linux.md index ce8a80f..5fca1d3 100644 --- a/docs/server-linux.md +++ b/docs/server-linux.md @@ -63,7 +63,7 @@ ss -lunp | grep 19091 ```bash sudo mkdir -p /opt/netquality -sudo tar -C /opt/netquality --strip-components=1 -xzf netquality-server-1.1.3-linux-amd64.tar.gz +sudo tar -C /opt/netquality --strip-components=1 -xzf netquality-server-1.1.4-linux-amd64.tar.gz sudo cp /opt/netquality/netquality.service /etc/systemd/system/netquality.service sudo systemctl daemon-reload sudo systemctl enable --now netquality diff --git a/server/README.md b/server/README.md index 8c28c5e..066c053 100644 --- a/server/README.md +++ b/server/README.md @@ -111,7 +111,7 @@ sudo firewall-cmd --reload ```bash sudo mkdir -p /opt/netquality -sudo tar -C /opt/netquality --strip-components=1 -xzf netquality-server-1.1.3-linux-amd64.tar.gz +sudo tar -C /opt/netquality --strip-components=1 -xzf netquality-server-1.1.4-linux-amd64.tar.gz sudo chmod 755 /opt/netquality/netquality-reflector sudo cp /opt/netquality/netquality.service /etc/systemd/system/netquality.service sudo systemctl daemon-reload diff --git a/server/selection.go b/server/selection.go index 55a1feb..062cd81 100644 --- a/server/selection.go +++ b/server/selection.go @@ -13,7 +13,7 @@ import ( "time" ) -const appVersion = "1.1.3" +const appVersion = "1.1.4" // dialState is shared by the job runner and the prober. Both hold a copy of // jobSpec, so the mutable address choice has to live behind a pointer.