Fix VPN internet connectivity and simplify client setup
Initialize Android physical interfaces and preserve macOS scoped routes. Add redacted diagnostics, default DNS, ordered auto-save, simplified controls, scanner rotation settings, and native regression coverage. Restore vendored build sources and document validation and stability checks.
This commit is contained in:
@@ -183,7 +183,9 @@ ImportPreview importProxyNodes(String input, {String source = 'manual'}) {
|
||||
'server_port': parsed.port,
|
||||
'method': Uri.decodeComponent(auth.substring(0, split)),
|
||||
'password': Uri.decodeComponent(auth.substring(split + 1)),
|
||||
'tag': uri.fragment.isEmpty ? 'Shadowsocks' : uri.fragment,
|
||||
'tag': uri.fragment.isEmpty
|
||||
? 'Shadowsocks'
|
||||
: Uri.decodeComponent(uri.fragment),
|
||||
});
|
||||
continue;
|
||||
}
|
||||
@@ -202,7 +204,7 @@ ImportPreview importProxyNodes(String input, {String source = 'manual'}) {
|
||||
: {'vless', 'trojan'}.contains(kind)
|
||||
? 443
|
||||
: 1080,
|
||||
'tag': uri.fragment.isEmpty ? kind : uri.fragment,
|
||||
'tag': uri.fragment.isEmpty ? kind : Uri.decodeComponent(uri.fragment),
|
||||
};
|
||||
final user = Uri.decodeComponent(uri.userInfo);
|
||||
if (kind == 'vless') {
|
||||
@@ -280,6 +282,7 @@ ImportPreview importProxyNodes(String input, {String source = 'manual'}) {
|
||||
}
|
||||
|
||||
class ProxyProfile {
|
||||
static const defaultProxyDns = 'https://cloudflare-dns.com/dns-query';
|
||||
List<ProxyNode> nodes = [];
|
||||
List<Map<String, dynamic>> rules = [];
|
||||
List<Map<String, dynamic>> meshDns = [];
|
||||
@@ -295,7 +298,16 @@ class ProxyProfile {
|
||||
mode = 'rule',
|
||||
defaultAction = 'proxy',
|
||||
dnsServer = '1.1.1.1',
|
||||
proxyDnsServer = '';
|
||||
proxyDnsServer = defaultProxyDns;
|
||||
String get effectiveProxyDns =>
|
||||
proxyDnsServer.trim().isEmpty ? defaultProxyDns : proxyDnsServer.trim();
|
||||
|
||||
void addNodes(Iterable<ProxyNode> incoming) {
|
||||
final firstImport = nodes.isEmpty && selectedId == null;
|
||||
nodes.addAll(incoming);
|
||||
if (firstImport && nodes.length == 1) selectedId = nodes.single.id;
|
||||
}
|
||||
|
||||
String get modeLabel => switch (mode) {
|
||||
'bypass_cn' => '绕过中国大陆',
|
||||
'global' => '全局代理',
|
||||
@@ -305,8 +317,8 @@ class ProxyProfile {
|
||||
void validateConnection() {
|
||||
if (feature != 'mesh' &&
|
||||
mode != 'direct' &&
|
||||
proxyDnsServer.trim().isEmpty) {
|
||||
throw StateError('请在 DNS 设置中填写代理 DNS;防泄露模式不会自动选择解析服务或回退到直连 DNS');
|
||||
!nodes.any((node) => node.id == selectedId)) {
|
||||
throw const FormatException('请先添加代理节点,并点击节点左侧的选择出口按钮');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -319,7 +331,7 @@ class ProxyProfile {
|
||||
'rules': rules,
|
||||
'dns_protection': true,
|
||||
'dns_server': dnsServer,
|
||||
'proxy_dns_server': proxyDnsServer,
|
||||
'proxy_dns_server': effectiveProxyDns,
|
||||
'direct_dns_server': directDnsServer,
|
||||
'rule_sets': ruleSets,
|
||||
'mesh_dns': feature == 'proxy' ? [] : meshDns,
|
||||
@@ -358,7 +370,10 @@ class ProxyProfile {
|
||||
p.mode = r['mode'] as String;
|
||||
p.defaultAction = r['default_action'] as String;
|
||||
p.dnsServer = r['dns_server'] as String;
|
||||
p.proxyDnsServer = r['proxy_dns_server'] as String? ?? '';
|
||||
final resolver = r['proxy_dns_server'] as String?;
|
||||
p.proxyDnsServer = resolver == null || resolver.trim().isEmpty
|
||||
? defaultProxyDns
|
||||
: resolver;
|
||||
p.rules = List<Map<String, dynamic>>.from(
|
||||
(r['rules'] as List).map((v) => Map<String, dynamic>.from(v)),
|
||||
);
|
||||
@@ -415,6 +430,7 @@ void replaceSubscription(
|
||||
ImportPreview preview,
|
||||
DateTime now,
|
||||
) {
|
||||
final firstImport = profile.nodes.isEmpty && profile.selectedId == null;
|
||||
if (preview.nodes.isEmpty) throw const FormatException('订阅没有可用节点,保留原配置');
|
||||
final old = profile.nodes.where((n) => n.source == source).toList();
|
||||
final next = preview.nodes.map((n) {
|
||||
@@ -429,6 +445,9 @@ void replaceSubscription(
|
||||
);
|
||||
}).toList();
|
||||
profile.nodes = [...profile.nodes.where((n) => n.source != source), ...next];
|
||||
if (firstImport && profile.nodes.length == 1) {
|
||||
profile.selectedId = profile.nodes.single.id;
|
||||
}
|
||||
if (old.any((n) => n.id == profile.selectedId) &&
|
||||
!next.any((n) => n.id == profile.selectedId))
|
||||
profile.selectedId = null;
|
||||
|
||||
Reference in New Issue
Block a user