mirror of
https://github.com/2dust/v2rayN.git
synced 2025-10-13 11:59:13 +00:00
Compare commits
3 commits
228a1b17bf
...
77dbea9b6d
Author | SHA1 | Date | |
---|---|---|---|
![]() |
77dbea9b6d | ||
![]() |
c53d9c118a | ||
![]() |
64c7fea2bc |
13 changed files with 33 additions and 68 deletions
|
@ -12,8 +12,8 @@
|
|||
<PackageVersion Include="Avalonia.ReactiveUI" Version="11.3.7" />
|
||||
<PackageVersion Include="CliWrap" Version="3.9.0" />
|
||||
<PackageVersion Include="Downloader" Version="4.0.3" />
|
||||
<PackageVersion Include="H.NotifyIcon.Wpf" Version="2.3.0" />
|
||||
<PackageVersion Include="MaterialDesignThemes" Version="5.2.1" />
|
||||
<PackageVersion Include="H.NotifyIcon.Wpf" Version="2.3.1" />
|
||||
<PackageVersion Include="MaterialDesignThemes" Version="5.3.0" />
|
||||
<PackageVersion Include="MessageBox.Avalonia" Version="3.2.0" />
|
||||
<PackageVersion Include="QRCoder" Version="1.6.0" />
|
||||
<PackageVersion Include="ReactiveUI" Version="20.4.1" />
|
||||
|
|
8
v2rayN/ServiceLib/Enums/ERuleType.cs
Normal file
8
v2rayN/ServiceLib/Enums/ERuleType.cs
Normal file
|
@ -0,0 +1,8 @@
|
|||
namespace ServiceLib.Enums;
|
||||
|
||||
public enum ERuleType
|
||||
{
|
||||
ALL = 0,
|
||||
Routing = 1,
|
||||
DNS = 2,
|
||||
}
|
|
@ -88,8 +88,6 @@ public class Global
|
|||
public const string SingboxFinalResolverTag = "final_resolver";
|
||||
public const string SingboxHostsDNSTag = "hosts_dns";
|
||||
public const string SingboxFakeDNSTag = "fake_dns";
|
||||
public const string RoutingRuleType = "Routing";
|
||||
public const string DNSRuleType = "DNS";
|
||||
|
||||
public static readonly List<string> IEProxyProtocols =
|
||||
[
|
||||
|
@ -482,12 +480,6 @@ public class Global
|
|||
"tcp,udp"
|
||||
];
|
||||
|
||||
public static readonly List<string> RuleTypes =
|
||||
[
|
||||
RoutingRuleType,
|
||||
DNSRuleType
|
||||
];
|
||||
|
||||
public static readonly List<string> destOverrideProtocols =
|
||||
[
|
||||
"http",
|
||||
|
|
|
@ -15,5 +15,5 @@ public class RulesItem
|
|||
public List<string>? Process { get; set; }
|
||||
public bool Enabled { get; set; } = true;
|
||||
public string? Remarks { get; set; }
|
||||
public List<string>? RuleTypes { get; set; }
|
||||
public ERuleType? RuleType { get; set; }
|
||||
}
|
||||
|
|
|
@ -253,7 +253,7 @@ public partial class CoreConfigSingboxService
|
|||
continue;
|
||||
}
|
||||
|
||||
if ((item.RuleTypes?.Count ?? 0) > 0 && !item.RuleTypes.Contains(Global.DNSRuleType))
|
||||
if (item.RuleType == ERuleType.Routing)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -141,7 +141,7 @@ public partial class CoreConfigSingboxService
|
|||
continue;
|
||||
}
|
||||
|
||||
if ((item1.RuleTypes?.Count ?? 0) > 0 && !item1.RuleTypes.Contains(Global.RoutingRuleType))
|
||||
if (item1.RuleType == ERuleType.DNS)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -142,7 +142,7 @@ public partial class CoreConfigV2rayService
|
|||
continue;
|
||||
}
|
||||
|
||||
if ((item.RuleTypes?.Count ?? 0) > 0 && !item.RuleTypes.Contains(Global.DNSRuleType))
|
||||
if (item.RuleType == ERuleType.Routing)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ public partial class CoreConfigV2rayService
|
|||
continue;
|
||||
}
|
||||
|
||||
if ((item.RuleTypes?.Count ?? 0) > 0 && !item.RuleTypes.Contains(Global.RoutingRuleType))
|
||||
if (item.RuleType == ERuleType.DNS)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -21,7 +21,8 @@ public class RoutingRuleDetailsViewModel : MyReactiveObject
|
|||
[Reactive]
|
||||
public string Process { get; set; }
|
||||
|
||||
public IList<string> Types { get; set; }
|
||||
[Reactive]
|
||||
public string? RuleType { get; set; }
|
||||
|
||||
[Reactive]
|
||||
public bool AutoSort { get; set; }
|
||||
|
@ -53,11 +54,7 @@ public class RoutingRuleDetailsViewModel : MyReactiveObject
|
|||
Domain = Utils.List2String(SelectedSource.Domain, true);
|
||||
IP = Utils.List2String(SelectedSource.Ip, true);
|
||||
Process = Utils.List2String(SelectedSource.Process, true);
|
||||
Types = SelectedSource.RuleTypes?.ToList();
|
||||
if (Types == null || Types.Count == 0)
|
||||
{
|
||||
Types = Global.RuleTypes;
|
||||
}
|
||||
RuleType = SelectedSource.RuleType?.ToString();
|
||||
}
|
||||
|
||||
private async Task SaveRulesAsync()
|
||||
|
@ -80,7 +77,7 @@ public class RoutingRuleDetailsViewModel : MyReactiveObject
|
|||
}
|
||||
SelectedSource.Protocol = ProtocolItems?.ToList();
|
||||
SelectedSource.InboundTag = InboundTagItems?.ToList();
|
||||
SelectedSource.RuleTypes = Types?.ToList();
|
||||
SelectedSource.RuleType = RuleType.IsNullOrEmpty() ? null : (ERuleType)Enum.Parse(typeof(ERuleType), RuleType);
|
||||
|
||||
var hasRule = SelectedSource.Domain?.Count > 0
|
||||
|| SelectedSource.Ip?.Count > 0
|
||||
|
|
|
@ -44,12 +44,12 @@
|
|||
Margin="{StaticResource Margin4}"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Center" />
|
||||
<ListBox
|
||||
x:Name="clbRuleTypes"
|
||||
<ComboBox
|
||||
x:Name="cmbRuleType"
|
||||
Width="300"
|
||||
Margin="{StaticResource Margin4}"
|
||||
HorizontalAlignment="Left"
|
||||
SelectionMode="Multiple,Toggle"
|
||||
Theme="{DynamicResource CardCheckGroupListBox}" />
|
||||
MaxDropDownHeight="1000" />
|
||||
|
||||
</StackPanel>
|
||||
|
||||
<TextBlock
|
||||
|
|
|
@ -28,16 +28,7 @@ public partial class RoutingRuleDetailsWindow : WindowBase<RoutingRuleDetailsVie
|
|||
clbProtocol.ItemsSource = Global.RuleProtocols;
|
||||
clbInboundTag.ItemsSource = Global.InboundTags;
|
||||
cmbNetwork.ItemsSource = Global.RuleNetworks;
|
||||
|
||||
clbRuleTypes.SelectionChanged += ClbRuleTypes_SelectionChanged;
|
||||
clbRuleTypes.ItemsSource = Global.RuleTypes;
|
||||
if (ViewModel.Types != null)
|
||||
{
|
||||
foreach (var it in ViewModel.Types)
|
||||
{
|
||||
clbRuleTypes.SelectedItems.Add(it);
|
||||
}
|
||||
}
|
||||
cmbRuleType.ItemsSource = Utils.GetEnumNames<ERuleType>();
|
||||
|
||||
if (!rulesItem.Id.IsNullOrEmpty())
|
||||
{
|
||||
|
@ -63,6 +54,7 @@ public partial class RoutingRuleDetailsWindow : WindowBase<RoutingRuleDetailsVie
|
|||
this.Bind(ViewModel, vm => vm.IP, v => v.txtIP.Text).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.Process, v => v.txtProcess.Text).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.AutoSort, v => v.chkAutoSort.IsChecked).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.RuleType, v => v.cmbRuleType.SelectedValue).DisposeWith(disposables);
|
||||
|
||||
this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables);
|
||||
});
|
||||
|
@ -119,12 +111,4 @@ public partial class RoutingRuleDetailsWindow : WindowBase<RoutingRuleDetailsVie
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ClbRuleTypes_SelectionChanged(object? sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
if (ViewModel != null)
|
||||
{
|
||||
ViewModel.Types = clbRuleTypes.SelectedItems.Cast<string>().ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,12 +60,12 @@
|
|||
Margin="{StaticResource Margin4}"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Center" />
|
||||
<ListBox
|
||||
x:Name="clbRuleTypes"
|
||||
<ComboBox
|
||||
x:Name="cmbRuleType"
|
||||
Width="200"
|
||||
Margin="{StaticResource Margin4}"
|
||||
HorizontalAlignment="Left"
|
||||
FontSize="{DynamicResource StdFontSize}"
|
||||
Style="{StaticResource MaterialDesignFilterChipPrimaryListBox}" />
|
||||
MaxDropDownHeight="1000"
|
||||
Style="{StaticResource DefComboBox}" />
|
||||
</StackPanel>
|
||||
|
||||
<TextBlock
|
||||
|
|
|
@ -21,16 +21,7 @@ public partial class RoutingRuleDetailsWindow
|
|||
clbProtocol.ItemsSource = Global.RuleProtocols;
|
||||
clbInboundTag.ItemsSource = Global.InboundTags;
|
||||
cmbNetwork.ItemsSource = Global.RuleNetworks;
|
||||
|
||||
clbRuleTypes.SelectionChanged += ClbRuleTypes_SelectionChanged;
|
||||
clbRuleTypes.ItemsSource = Global.RuleTypes;
|
||||
if (ViewModel.Types != null)
|
||||
{
|
||||
foreach (var it in ViewModel.Types)
|
||||
{
|
||||
clbRuleTypes.SelectedItems.Add(it);
|
||||
}
|
||||
}
|
||||
cmbRuleType.ItemsSource = Utils.GetEnumNames<ERuleType>();
|
||||
|
||||
if (!rulesItem.Id.IsNullOrEmpty())
|
||||
{
|
||||
|
@ -55,6 +46,7 @@ public partial class RoutingRuleDetailsWindow
|
|||
this.Bind(ViewModel, vm => vm.IP, v => v.txtIP.Text).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.Process, v => v.txtProcess.Text).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.AutoSort, v => v.chkAutoSort.IsChecked).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.RuleType, v => v.cmbRuleType.Text).DisposeWith(disposables);
|
||||
|
||||
this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables);
|
||||
});
|
||||
|
@ -111,12 +103,4 @@ public partial class RoutingRuleDetailsWindow
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ClbRuleTypes_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
|
||||
{
|
||||
if (ViewModel != null)
|
||||
{
|
||||
ViewModel.Types = clbRuleTypes.SelectedItems.Cast<string>().ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue