feat: support custom bypass rules and mesh routing policies
This commit is contained in:
@@ -336,7 +336,7 @@ class _ProxyPanelState extends State<ProxyPanel> {
|
||||
: (v) => change(() => p.mode = v!),
|
||||
),
|
||||
if (p.mode == 'bypass_cn' && p.feature != 'mesh')
|
||||
const Text('中国大陆 IP 和普通私网直连,其余通过代理。首次使用会下载分流规则。'),
|
||||
const Text('优先执行自定义分流规则,其余中国大陆 IP 和普通私网直连,其他流量通过代理。首次使用会下载分流规则。'),
|
||||
Text(
|
||||
widget.entry == 'application'
|
||||
? '应用内代理:需要在使用它的软件中设置 SOCKS5 127.0.0.1:10818。'
|
||||
@@ -475,7 +475,7 @@ class _ProxyPanelState extends State<ProxyPanel> {
|
||||
subtitle: const Text('网络入口、DNS 与分流规则'),
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(18),
|
||||
padding: const EdgeInsets.fromLTRB(18, 20, 18, 24),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
@@ -502,62 +502,107 @@ class _ProxyPanelState extends State<ProxyPanel> {
|
||||
? null
|
||||
: (v) => widget.entryChanged(v!),
|
||||
),
|
||||
const SizedBox(height: 18),
|
||||
const SizedBox(height: 16),
|
||||
const Text('修改连接设置后,重连使其生效。'),
|
||||
const SizedBox(height: 18),
|
||||
const Divider(height: 48),
|
||||
Text('分流规则', style: Theme.of(context).textTheme.titleSmall),
|
||||
const SizedBox(height: 12),
|
||||
const Text(
|
||||
'受管理规则:有效组网地址 → 组网;已失效的已知组网地址 → 拒绝;随后才应用普通规则与默认出口。',
|
||||
),
|
||||
DropdownButtonFormField<String>(
|
||||
isExpanded: true,
|
||||
initialValue: p.defaultAction,
|
||||
decoration: const InputDecoration(labelText: '规则模式默认出口'),
|
||||
items: const [
|
||||
DropdownMenuItem(value: 'proxy', child: Text('所选代理')),
|
||||
DropdownMenuItem(value: 'direct', child: Text('直连')),
|
||||
DropdownMenuItem(value: 'reject', child: Text('拒绝')),
|
||||
],
|
||||
onChanged:
|
||||
disabled || p.mode != 'rule' || p.feature == 'mesh'
|
||||
? null
|
||||
: (v) => change(() => p.defaultAction = v!),
|
||||
'组网地址优先走组网;已失效的已知组网地址拒绝访问。',
|
||||
style: TextStyle(height: 1.5),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
if (p.mode == 'rule' && p.feature != 'mesh') ...[
|
||||
DropdownButtonFormField<String>(
|
||||
isExpanded: true,
|
||||
initialValue: p.defaultAction,
|
||||
decoration: const InputDecoration(
|
||||
labelText: '规则模式默认出口',
|
||||
),
|
||||
items: const [
|
||||
DropdownMenuItem(value: 'proxy', child: Text('代理')),
|
||||
DropdownMenuItem(value: 'direct', child: Text('直连')),
|
||||
DropdownMenuItem(value: 'mesh', child: Text('组网')),
|
||||
DropdownMenuItem(value: 'reject', child: Text('拒绝')),
|
||||
],
|
||||
onChanged: disabled
|
||||
? null
|
||||
: (v) => change(() => p.defaultAction = v!),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
],
|
||||
if (p.mode == 'bypass_cn' && p.feature != 'mesh') ...[
|
||||
const Text(
|
||||
'自定义规则优先,其余私网及中国大陆 IP 直连,其他流量走代理。',
|
||||
style: TextStyle(height: 1.5),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
],
|
||||
Text(
|
||||
'${p.rules.length} 条普通规则 · ${p.mode == 'rule' && p.feature != 'mesh' ? '规则模式执行' : '已暂停'}',
|
||||
'${p.rules.length} 条普通规则 · '
|
||||
'${p.ruleSets.where((set) => set['enabled'] == true).length} 个启用规则集 · '
|
||||
'${{'rule', 'bypass_cn'}.contains(p.mode) && p.feature != 'mesh' ? '按顺序执行' : '已暂停'}',
|
||||
),
|
||||
OutlinedButton(
|
||||
onPressed: disabled
|
||||
? null
|
||||
: () => Navigator.push<void>(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (_) => RulesPage(
|
||||
profile: p,
|
||||
changed: widget.changed,
|
||||
const SizedBox(height: 12),
|
||||
Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: OutlinedButton(
|
||||
onPressed: disabled
|
||||
? null
|
||||
: () => Navigator.push<void>(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (_) => RulesPage(
|
||||
profile: p,
|
||||
changed: widget.changed,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
child: const Text('编辑普通规则'),
|
||||
child: const Text('编辑普通规则'),
|
||||
),
|
||||
),
|
||||
const Divider(height: 48),
|
||||
Text(
|
||||
'启动 DNS:${p.dnsServer} · 直连 DNS:${p.directDnsServer.isEmpty ? '启动 DNS' : p.directDnsServer} · 代理 DNS:${p.effectiveProxyDns}',
|
||||
'DNS 设置',
|
||||
style: Theme.of(context).textTheme.titleSmall,
|
||||
),
|
||||
OutlinedButton(
|
||||
onPressed: disabled
|
||||
? null
|
||||
: () => Navigator.push<void>(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (_) => DnsPage(
|
||||
profile: p,
|
||||
changed: widget.changed,
|
||||
const SizedBox(height: 12),
|
||||
Text(
|
||||
'启动 DNS:${p.dnsServer}',
|
||||
style: const TextStyle(height: 1.5),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
'直连 DNS:${p.directDnsServer.isEmpty ? '启动 DNS' : p.directDnsServer}',
|
||||
style: const TextStyle(height: 1.5),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
'代理 DNS:${p.effectiveProxyDns}',
|
||||
style: const TextStyle(height: 1.5),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: OutlinedButton(
|
||||
onPressed: disabled
|
||||
? null
|
||||
: () => Navigator.push<void>(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (_) => DnsPage(
|
||||
profile: p,
|
||||
changed: widget.changed,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
child: const Text('编辑 DNS'),
|
||||
child: const Text('编辑 DNS'),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
'FakeIP:${p.fakeIP ? '开启' : '关闭'} · 组网域名自动排除,解析失败无公共 DNS 回退。',
|
||||
style: const TextStyle(height: 1.5),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user