Skip to content

Commit 3971318

Browse files
committed
Improved UI for routing rules
1 parent 5fbeb4b commit 3971318

14 files changed

+193
-91
lines changed

v2rayN/ServiceLib/Models/RulesItem.cs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,15 @@ public class RulesItem
55
{
66
public string id { get; set; }
77
public string? type { get; set; }
8-
98
public string? port { get; set; }
109
public string? network { get; set; }
11-
1210
public List<string>? inboundTag { get; set; }
13-
1411
public string? outboundTag { get; set; }
15-
1612
public List<string>? ip { get; set; }
17-
1813
public List<string>? domain { get; set; }
19-
2014
public List<string>? protocol { get; set; }
21-
2215
public List<string>? process { get; set; }
23-
2416
public bool enabled { get; set; } = true;
17+
public string? remarks { get; set; }
2518
}
2619
}

v2rayN/ServiceLib/Models/RulesItemModel.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,8 @@
44
public class RulesItemModel : RulesItem
55
{
66
public string inboundTags { get; set; }
7-
87
public string ips { get; set; }
9-
108
public string domains { get; set; }
11-
129
public string protocols { get; set; }
1310
}
1411
}

v2rayN/ServiceLib/Sample/custom_routing_black

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,56 @@
11
[
22
{
3+
"remarks": "绕过bittorrent",
34
"outboundTag": "direct",
45
"protocol": [
56
"bittorrent"
67
]
78
},
89
{
10+
"remarks": "Google cn",
11+
"outboundTag": "proxy",
12+
"domain": [
13+
"domain:googleapis.cn",
14+
"domain:gstatic.com"
15+
]
16+
},
17+
{
18+
"remarks": "阻断udp443",
919
"outboundTag": "block",
1020
"port": "443",
1121
"network": "udp"
1222
},
1323
{
24+
"remarks": "阻断广告",
1425
"outboundTag": "block",
1526
"domain": [
1627
"geosite:category-ads-all"
1728
]
1829
},
1930
{
31+
"remarks": "绕过局域网IP",
32+
"outboundTag": "direct",
33+
"ip": [
34+
"geoip:private"
35+
]
36+
},
37+
{
38+
"remarks": "绕过局域网域名",
39+
"outboundTag": "direct",
40+
"domain": [
41+
"geosite:private"
42+
]
43+
},
44+
{
45+
"remarks": "代理GFW",
2046
"outboundTag": "proxy",
21-
2247
"domain": [
2348
"geosite:gfw",
2449
"geosite:greatfire"
2550
]
2651
},
2752
{
53+
"remarks": "代理Google等",
2854
"outboundTag": "proxy",
2955
"ip": [
3056
"1.0.0.1",
@@ -40,6 +66,7 @@
4066
]
4167
},
4268
{
69+
"remarks": "最终直连",
4370
"port": "0-65535",
4471
"outboundTag": "direct"
4572
}

v2rayN/ServiceLib/Sample/custom_routing_global

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,33 @@
11
[
22
{
3+
"remarks": "阻断udp443",
34
"outboundTag": "block",
45
"port": "443",
56
"network": "udp"
67
},
78
{
9+
"remarks": "阻断广告",
10+
"outboundTag": "block",
11+
"domain": [
12+
"geosite:category-ads-all"
13+
]
14+
},
15+
{
16+
"remarks": "绕过局域网IP",
17+
"outboundTag": "direct",
18+
"ip": [
19+
"geoip:private"
20+
]
21+
},
22+
{
23+
"remarks": "绕过局域网域名",
24+
"outboundTag": "direct",
25+
"domain": [
26+
"geosite:private"
27+
]
28+
},
29+
{
30+
"remarks": "最终代理",
831
"port": "0-65535",
932
"outboundTag": "proxy"
1033
}

v2rayN/ServiceLib/Sample/custom_routing_white

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,41 @@
11
[
22
{
3-
"outboundTag": "direct",
3+
"remarks": "Google cn",
4+
"outboundTag": "proxy",
45
"domain": [
5-
"domain:example-example.com",
6-
"domain:example-example2.com"
6+
"domain:googleapis.cn",
7+
"domain:gstatic.com"
78
]
89
},
910
{
11+
"remarks": "阻断udp443",
1012
"outboundTag": "block",
1113
"port": "443",
1214
"network": "udp"
1315
},
1416
{
17+
"remarks": "阻断广告",
1518
"outboundTag": "block",
1619
"domain": [
1720
"geosite:category-ads-all"
1821
]
1922
},
2023
{
24+
"remarks": "绕过局域网IP",
25+
"outboundTag": "direct",
26+
"ip": [
27+
"geoip:private"
28+
]
29+
},
30+
{
31+
"remarks": "绕过局域网域名",
32+
"outboundTag": "direct",
33+
"domain": [
34+
"geosite:private"
35+
]
36+
},
37+
{
38+
"remarks": "绕过中国域名",
2139
"outboundTag": "direct",
2240
"domain": [
2341
"domain:dns.alidns.com",
@@ -30,6 +48,7 @@
3048
]
3149
},
3250
{
51+
"remarks": "绕过中国IP",
3352
"outboundTag": "direct",
3453
"ip": [
3554
"223.5.5.5/32",
@@ -51,11 +70,11 @@
5170
"218.30.118.6/32",
5271
"123.125.81.6/32",
5372
"140.207.198.6/32",
54-
"geoip:private",
5573
"geoip:cn"
5674
]
5775
},
5876
{
77+
"remarks": "最终代理",
5978
"port": "0-65535",
6079
"outboundTag": "proxy"
6180
}

v2rayN/ServiceLib/ViewModels/RoutingRuleSettingViewModel.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ public void RefreshRulesItems()
124124
domains = Utils.List2String(item.domain),
125125
ips = Utils.List2String(item.ip),
126126
enabled = item.enabled,
127+
remarks = item.remarks,
127128
};
128129
_rulesItems.Add(it);
129130
}

v2rayN/v2rayN.Desktop/Views/RoutingRuleDetailsWindow.axaml

Lines changed: 49 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -33,36 +33,56 @@
3333
Grid.Column="0"
3434
VerticalAlignment="Center"
3535
Classes="Margin8"
36+
Text="{x:Static resx:ResUI.LvRemarks}" />
37+
<TextBox
38+
x:Name="txtRemarks"
39+
Grid.Row="0"
40+
Grid.Column="1"
41+
Width="200"
42+
HorizontalAlignment="Left"
43+
Classes="Margin8" />
44+
<ToggleSwitch
45+
x:Name="togEnabled"
46+
Grid.Row="0"
47+
Grid.Column="2"
48+
HorizontalAlignment="Left"
49+
Classes="Margin8" />
50+
51+
<TextBlock
52+
Grid.Row="1"
53+
Grid.Column="0"
54+
VerticalAlignment="Center"
55+
Classes="Margin8"
3656
Text="outboundTag" />
3757
<ComboBox
3858
x:Name="cmbOutboundTag"
39-
Grid.Row="0"
59+
Grid.Row="1"
4060
Grid.Column="1"
4161
Width="200"
4262
Classes="Margin8"
4363
MaxDropDownHeight="1000" />
4464
<TextBlock
45-
Grid.Row="0"
65+
Grid.Row="1"
4666
Grid.Column="2"
4767
HorizontalAlignment="Left"
4868
Classes="Margin8"
4969
Text="{x:Static resx:ResUI.TbRuleMatchingTips}" />
5070

5171
<TextBlock
52-
Grid.Row="1"
72+
Grid.Row="2"
5373
Grid.Column="0"
5474
VerticalAlignment="Center"
5575
Classes="Margin8"
5676
Text="port" />
5777
<TextBox
5878
x:Name="txtPort"
59-
Grid.Row="1"
79+
Grid.Row="2"
6080
Grid.Column="1"
6181
Width="200"
6282
HorizontalAlignment="Left"
6383
Classes="Margin8" />
6484
<TextBlock
65-
Grid.Row="1"
85+
Grid.Row="2"
6686
Grid.Column="2"
6787
VerticalAlignment="Center"
6888
Classes="Margin8">
@@ -72,61 +92,47 @@
7292
</TextBlock>
7393

7494
<TextBlock
75-
Grid.Row="2"
95+
Grid.Row="3"
7696
Grid.Column="0"
7797
VerticalAlignment="Center"
7898
Classes="Margin8"
7999
Text="protocol" />
80100
<ListBox
81101
x:Name="clbProtocol"
82-
Grid.Row="2"
102+
Grid.Row="3"
83103
Grid.Column="1"
84104
HorizontalAlignment="Left"
85105
Classes="Margin8"
86106
SelectionMode="Multiple"
87107
Theme="{DynamicResource PureCardRadioGroupListBox}" />
88108

89109
<TextBlock
90-
Grid.Row="3"
110+
Grid.Row="4"
91111
Grid.Column="0"
92112
VerticalAlignment="Center"
93113
Classes="Margin8"
94114
Text="inboundTag" />
95115
<ListBox
96116
x:Name="clbInboundTag"
97-
Grid.Row="3"
117+
Grid.Row="4"
98118
Grid.Column="1"
99119
Classes="Margin8"
100120
SelectionMode="Multiple"
101121
Theme="{DynamicResource PureCardRadioGroupListBox}" />
102122

103123
<TextBlock
104-
Grid.Row="4"
124+
Grid.Row="5"
105125
Grid.Column="0"
106126
VerticalAlignment="Center"
107127
Classes="Margin8"
108128
Text="network" />
109129
<ComboBox
110130
x:Name="cmbNetwork"
111-
Grid.Row="4"
131+
Grid.Row="5"
112132
Grid.Column="1"
113133
Width="200"
114134
Classes="Margin8"
115135
MaxDropDownHeight="1000" />
116-
117-
<TextBlock
118-
Grid.Row="5"
119-
Grid.Column="0"
120-
VerticalAlignment="Center"
121-
Classes="Margin8"
122-
Text="enabled" />
123-
<ToggleSwitch
124-
x:Name="togEnabled"
125-
Grid.Row="5"
126-
Grid.Column="1"
127-
HorizontalAlignment="Left"
128-
Classes="Margin8" />
129-
130136
<TextBlock
131137
Grid.Row="5"
132138
Grid.Column="2"
@@ -169,25 +175,40 @@
169175
<ColumnDefinition Width="10" />
170176
<ColumnDefinition Width="1*" />
171177
</Grid.ColumnDefinitions>
172-
<HeaderedContentControl Grid.Column="0" Header="{x:Static resx:ResUI.TbRoutingRuleDomain}">
178+
<HeaderedContentControl
179+
Grid.Column="0"
180+
BorderBrush="Gray"
181+
BorderThickness="1"
182+
Header="{x:Static resx:ResUI.TbRoutingRuleDomain}">
173183
<TextBox
174184
Name="txtDomain"
185+
VerticalAlignment="Stretch"
175186
Classes="TextArea"
176187
MinLines="10"
177188
TextWrapping="Wrap" />
178189
</HeaderedContentControl>
179190
<GridSplitter Grid.Column="1" HorizontalAlignment="Stretch" />
180-
<HeaderedContentControl Grid.Column="2" Header="{x:Static resx:ResUI.TbRoutingRuleIP}">
191+
<HeaderedContentControl
192+
Grid.Column="2"
193+
BorderBrush="Gray"
194+
BorderThickness="1"
195+
Header="{x:Static resx:ResUI.TbRoutingRuleIP}">
181196
<TextBox
182197
Name="txtIP"
198+
VerticalAlignment="Stretch"
183199
Classes="TextArea"
184200
MinLines="10"
185201
TextWrapping="Wrap" />
186202
</HeaderedContentControl>
187203
<GridSplitter Grid.Column="3" HorizontalAlignment="Stretch" />
188-
<HeaderedContentControl Grid.Column="4" Header="{x:Static resx:ResUI.TbRoutingRuleProcess}">
204+
<HeaderedContentControl
205+
Grid.Column="4"
206+
BorderBrush="Gray"
207+
BorderThickness="1"
208+
Header="{x:Static resx:ResUI.TbRoutingRuleProcess}">
189209
<TextBox
190210
Name="txtProcess"
211+
VerticalAlignment="Stretch"
191212
Classes="TextArea"
192213
MinLines="10"
193214
TextWrapping="Wrap" />

v2rayN/v2rayN.Desktop/Views/RoutingRuleDetailsWindow.axaml.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public RoutingRuleDetailsWindow(RulesItem rulesItem)
5353

5454
this.WhenActivated(disposables =>
5555
{
56+
this.Bind(ViewModel, vm => vm.SelectedSource.remarks, v => v.txtRemarks.Text).DisposeWith(disposables);
5657
this.Bind(ViewModel, vm => vm.SelectedSource.outboundTag, v => v.cmbOutboundTag.SelectedValue).DisposeWith(disposables);
5758
this.Bind(ViewModel, vm => vm.SelectedSource.port, v => v.txtPort.Text).DisposeWith(disposables);
5859
this.Bind(ViewModel, vm => vm.SelectedSource.network, v => v.cmbNetwork.SelectedValue).DisposeWith(disposables);

0 commit comments

Comments
 (0)