mirror of https://github.com/2dust/v2rayN
parent
71bf9b4887
commit
b77cc3c33b
|
@ -62,7 +62,7 @@ namespace v2rayN
|
|||
//Under Win10
|
||||
if (Environment.OSVersion.Version.Major < 10)
|
||||
{
|
||||
Environment.SetEnvironmentVariable("DOTNET_EnableWriteXorExecute", "0", EnvironmentVariableTarget.Process);
|
||||
Environment.SetEnvironmentVariable("DOTNET_EnableWriteXorExecute", "0", EnvironmentVariableTarget.User);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ namespace v2rayN
|
|||
/// </summary>
|
||||
/// <param name="lst"></param>
|
||||
/// <returns></returns>
|
||||
public static string List2String(List<string> lst, bool wrap = false)
|
||||
public static string List2String(List<string>? lst, bool wrap = false)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
|
@ -174,6 +174,7 @@ namespace v2rayN
|
|||
public static readonly List<string> LogLevels = new() { "debug", "info", "warning", "error", "none" };
|
||||
public static readonly List<string> InboundTags = new() { "socks", "http", "socks2", "http2" };
|
||||
public static readonly List<string> RuleProtocols = new() { "http", "tls", "bittorrent" };
|
||||
public static readonly List<string> RuleNetworks = new() { "", "tcp", "udp", "tcp,udp" };
|
||||
public static readonly List<string> destOverrideProtocols = ["http", "tls", "quic", "fakedns", "fakedns+others"];
|
||||
public static readonly List<string> TunMtus = new() { "1280", "1408", "1500", "9000" };
|
||||
public static readonly List<string> TunStacks = new() { "gvisor", "system" };
|
||||
|
|
|
@ -552,7 +552,7 @@ namespace v2rayN.Handler.CoreConfig
|
|||
singboxConfig.route.rules.Add(new()
|
||||
{
|
||||
port = [53],
|
||||
network = "udp",
|
||||
network = ["udp"],
|
||||
outbound = dnsOutbound
|
||||
});
|
||||
}
|
||||
|
@ -668,6 +668,10 @@ namespace v2rayN.Handler.CoreConfig
|
|||
rule.port = new List<int> { Utils.ToInt(item.port) };
|
||||
}
|
||||
}
|
||||
if (!Utils.IsNullOrEmpty(item.network))
|
||||
{
|
||||
rule.network = Utils.String2List(item.network);
|
||||
}
|
||||
if (item.protocol?.Count > 0)
|
||||
{
|
||||
rule.protocol = item.protocol;
|
||||
|
|
|
@ -220,39 +220,43 @@ namespace v2rayN.Handler.CoreConfig
|
|||
return 0;
|
||||
}
|
||||
|
||||
private int GenRoutingUserRule(RulesItem4Ray? rules, V2rayConfig v2rayConfig)
|
||||
private int GenRoutingUserRule(RulesItem4Ray? rule, V2rayConfig v2rayConfig)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (rules == null)
|
||||
if (rule == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (Utils.IsNullOrEmpty(rules.port))
|
||||
if (Utils.IsNullOrEmpty(rule.port))
|
||||
{
|
||||
rules.port = null;
|
||||
rule.port = null;
|
||||
}
|
||||
if (rules.domain?.Count == 0)
|
||||
if (Utils.IsNullOrEmpty(rule.network))
|
||||
{
|
||||
rules.domain = null;
|
||||
rule.network = null;
|
||||
}
|
||||
if (rules.ip?.Count == 0)
|
||||
if (rule.domain?.Count == 0)
|
||||
{
|
||||
rules.ip = null;
|
||||
rule.domain = null;
|
||||
}
|
||||
if (rules.protocol?.Count == 0)
|
||||
if (rule.ip?.Count == 0)
|
||||
{
|
||||
rules.protocol = null;
|
||||
rule.ip = null;
|
||||
}
|
||||
if (rules.inboundTag?.Count == 0)
|
||||
if (rule.protocol?.Count == 0)
|
||||
{
|
||||
rules.inboundTag = null;
|
||||
rule.protocol = null;
|
||||
}
|
||||
if (rule.inboundTag?.Count == 0)
|
||||
{
|
||||
rule.inboundTag = null;
|
||||
}
|
||||
|
||||
var hasDomainIp = false;
|
||||
if (rules.domain?.Count > 0)
|
||||
if (rule.domain?.Count > 0)
|
||||
{
|
||||
var it = JsonUtils.DeepCopy(rules);
|
||||
var it = JsonUtils.DeepCopy(rule);
|
||||
it.ip = null;
|
||||
it.type = "field";
|
||||
for (int k = it.domain.Count - 1; k >= 0; k--)
|
||||
|
@ -266,9 +270,9 @@ namespace v2rayN.Handler.CoreConfig
|
|||
v2rayConfig.routing.rules.Add(it);
|
||||
hasDomainIp = true;
|
||||
}
|
||||
if (rules.ip?.Count > 0)
|
||||
if (rule.ip?.Count > 0)
|
||||
{
|
||||
var it = JsonUtils.DeepCopy(rules);
|
||||
var it = JsonUtils.DeepCopy(rule);
|
||||
it.domain = null;
|
||||
it.type = "field";
|
||||
v2rayConfig.routing.rules.Add(it);
|
||||
|
@ -276,12 +280,12 @@ namespace v2rayN.Handler.CoreConfig
|
|||
}
|
||||
if (!hasDomainIp)
|
||||
{
|
||||
if (!Utils.IsNullOrEmpty(rules.port)
|
||||
|| rules.protocol?.Count > 0
|
||||
|| rules.inboundTag?.Count > 0
|
||||
if (!Utils.IsNullOrEmpty(rule.port)
|
||||
|| rule.protocol?.Count > 0
|
||||
|| rule.inboundTag?.Count > 0
|
||||
)
|
||||
{
|
||||
var it = JsonUtils.DeepCopy(rules);
|
||||
var it = JsonUtils.DeepCopy(rule);
|
||||
it.type = "field";
|
||||
v2rayConfig.routing.rules.Add(it);
|
||||
}
|
||||
|
|
|
@ -4,21 +4,22 @@
|
|||
public class RulesItem
|
||||
{
|
||||
public string id { get; set; }
|
||||
public string type { get; set; }
|
||||
public string? type { get; set; }
|
||||
|
||||
public string port { get; set; }
|
||||
public string? port { get; set; }
|
||||
public string? network { get; set; }
|
||||
|
||||
public List<string> inboundTag { get; set; }
|
||||
public List<string>? inboundTag { get; set; }
|
||||
|
||||
public string outboundTag { get; set; }
|
||||
public string? outboundTag { get; set; }
|
||||
|
||||
public List<string> ip { get; set; }
|
||||
public List<string>? ip { get; set; }
|
||||
|
||||
public List<string> domain { get; set; }
|
||||
public List<string>? domain { get; set; }
|
||||
|
||||
public List<string> protocol { get; set; }
|
||||
public List<string>? protocol { get; set; }
|
||||
|
||||
public List<string> process { get; set; }
|
||||
public List<string>? process { get; set; }
|
||||
|
||||
public bool enabled { get; set; } = true;
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
public List<string>? protocol { get; set; }
|
||||
public string? type { get; set; }
|
||||
public string? mode { get; set; }
|
||||
public string? network { get; set; }
|
||||
public List<string>? network { get; set; }
|
||||
public bool? ip_is_private { get; set; }
|
||||
public List<int>? port { get; set; }
|
||||
public List<string>? port_range { get; set; }
|
||||
|
|
|
@ -394,6 +394,7 @@ namespace v2rayN.Models
|
|||
public string? type { get; set; }
|
||||
|
||||
public string? port { get; set; }
|
||||
public string? network { get; set; }
|
||||
|
||||
public List<string>? inboundTag { get; set; }
|
||||
|
||||
|
|
|
@ -130,6 +130,7 @@ namespace v2rayN.ViewModels
|
|||
id = item.id,
|
||||
outboundTag = item.outboundTag,
|
||||
port = item.port,
|
||||
network = item.network,
|
||||
protocols = Utils.List2String(item.protocol),
|
||||
inboundTags = Utils.List2String(item.inboundTag),
|
||||
domains = Utils.List2String(item.domain),
|
||||
|
|
|
@ -125,16 +125,32 @@
|
|||
Margin="4"
|
||||
VerticalAlignment="Center"
|
||||
Style="{StaticResource ToolbarTextBlock}"
|
||||
Text="network" />
|
||||
<ComboBox
|
||||
x:Name="cmbNetwork"
|
||||
Grid.Row="4"
|
||||
Grid.Column="1"
|
||||
Width="200"
|
||||
Margin="4"
|
||||
MaxDropDownHeight="1000"
|
||||
Style="{StaticResource DefComboBox}" />
|
||||
|
||||
<TextBlock
|
||||
Grid.Row="5"
|
||||
Grid.Column="0"
|
||||
Margin="4"
|
||||
VerticalAlignment="Center"
|
||||
Style="{StaticResource ToolbarTextBlock}"
|
||||
Text="enabled" />
|
||||
<ToggleButton
|
||||
x:Name="togEnabled"
|
||||
Grid.Row="4"
|
||||
Grid.Row="5"
|
||||
Grid.Column="1"
|
||||
Margin="4"
|
||||
HorizontalAlignment="Left" />
|
||||
|
||||
<TextBlock
|
||||
Grid.Row="4"
|
||||
Grid.Row="5"
|
||||
Grid.Column="2"
|
||||
Margin="4"
|
||||
HorizontalAlignment="Left"
|
||||
|
|
|
@ -39,6 +39,10 @@ namespace v2rayN.Views
|
|||
{
|
||||
clbInboundTag.Items.Add(it);
|
||||
});
|
||||
Global.RuleNetworks.ForEach(it =>
|
||||
{
|
||||
cmbNetwork.Items.Add(it);
|
||||
});
|
||||
|
||||
if (!rulesItem.id.IsNullOrEmpty())
|
||||
{
|
||||
|
@ -56,6 +60,7 @@ namespace v2rayN.Views
|
|||
{
|
||||
this.Bind(ViewModel, vm => vm.SelectedSource.outboundTag, v => v.cmbOutboundTag.Text).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.SelectedSource.port, v => v.txtPort.Text).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.SelectedSource.network, v => v.cmbNetwork.Text).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.SelectedSource.enabled, v => v.togEnabled.IsChecked).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.Domain, v => v.txtDomain.Text).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.IP, v => v.txtIP.Text).DisposeWith(disposables);
|
||||
|
|
|
@ -302,7 +302,7 @@
|
|||
</DataGrid.ContextMenu>
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn
|
||||
Width="120"
|
||||
Width="110"
|
||||
Binding="{Binding outboundTag}"
|
||||
Header="outboundTag" />
|
||||
<DataGridTextColumn
|
||||
|
@ -310,7 +310,7 @@
|
|||
Binding="{Binding port}"
|
||||
Header="port" />
|
||||
<DataGridTextColumn
|
||||
Width="100"
|
||||
Width="80"
|
||||
Binding="{Binding protocols}"
|
||||
Header="protocol" />
|
||||
<DataGridTextColumn
|
||||
|
@ -318,11 +318,15 @@
|
|||
Binding="{Binding inboundTags}"
|
||||
Header="inboundTag" />
|
||||
<DataGridTextColumn
|
||||
Width="220"
|
||||
Width="90"
|
||||
Binding="{Binding network}"
|
||||
Header="network" />
|
||||
<DataGridTextColumn
|
||||
Width="190"
|
||||
Binding="{Binding domains}"
|
||||
Header="domain" />
|
||||
<DataGridTextColumn
|
||||
Width="220"
|
||||
Width="190"
|
||||
Binding="{Binding ips}"
|
||||
Header="ip" />
|
||||
<DataGridTextColumn
|
||||
|
|
Loading…
Reference in New Issue