Files
netquality/client/lib/models/port_field.dart
T
yanjiu0721 8cdc0f436f 网络质量探测 1.1.3:自更新、HTTP/3 与中心节点
版本名 1.1.3,构建号 6。应用标识和签名未改。包含自动更新、覆盖安装、目标历史、IPv4/IPv6 开关、HTTP(含 HTTP/3)以及中心服务端一键添加节点。
2026-11-21 19:43:23 +08:00

44 lines
1.3 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// Copyright (C) 2026 言灸
// SPDX-License-Identifier: AGPL-3.0-only
import 'probe_profile.dart';
/// Keeps a port the user typed. An empty field or a value that is still the
/// previous profile's default follows the newly selected profile.
String portAfterProfileChange({
required String current,
required int previousDefault,
required int nextDefault,
}) {
final trimmed = current.trim();
if (trimmed.isEmpty || int.tryParse(trimmed) == previousDefault) {
return '$nextDefault';
}
return current;
}
String portHint(ProbeProfile profile) {
switch (profile.id) {
case 'nq-tcp':
return '合作反射 TCP 默认 19090';
case 'nq-udp':
return '合作反射 UDP 默认 19091';
case 'http':
return 'HTTP 默认 443(https)或 80(http)';
default:
return '${profile.label} 默认 ${profile.port}';
}
}
/// Default port for an HTTP target. A full http:// URL uses 80. Anything else uses 443.
int httpDefaultPort(String target) {
final text = target.trim().toLowerCase();
if (text.startsWith('http://')) {
return 80;
}
return 443;
}
const portHelperText =
'合作反射 TCP 默认 19090,UDP 默认 19091。只有当前端口仍是上一种类型的默认值或为空时,切换类型才会自动更换。';