mirror of
https://github.com/2dust/v2rayN.git
synced 2025-07-03 05:22:10 +00:00
Refactor
This commit is contained in:
parent
1ac7661593
commit
b0c5f74edb
6 changed files with 50 additions and 50 deletions
|
@ -1180,7 +1180,7 @@ namespace v2rayN.Handler
|
|||
var fileName = Utils.GetTempPath($"{Utils.GetGUID(false)}.yaml");
|
||||
File.WriteAllText(fileName, clipboardData);
|
||||
|
||||
profileItem.coreType = ECoreType.clash;
|
||||
profileItem.coreType = ECoreType.mihomo;
|
||||
profileItem.address = fileName;
|
||||
profileItem.remarks = "clash_custom";
|
||||
}
|
||||
|
|
|
@ -119,6 +119,7 @@ namespace v2rayN.Handler
|
|||
|
||||
case ECoreType.clash:
|
||||
case ECoreType.clash_meta:
|
||||
case ECoreType.mihomo:
|
||||
//remove the original
|
||||
var indexPort = fileContent.FindIndex(t => t.Contains("port:"));
|
||||
if (indexPort >= 0)
|
||||
|
|
|
@ -6,7 +6,6 @@ namespace v2rayN.Handler
|
|||
{
|
||||
internal class CoreConfigSingbox
|
||||
{
|
||||
private string SampleClient = Global.SingboxSampleClient;
|
||||
private Config _config;
|
||||
|
||||
public CoreConfigSingbox(Config config)
|
||||
|
@ -28,7 +27,7 @@ namespace v2rayN.Handler
|
|||
|
||||
msg = ResUI.InitialConfiguration;
|
||||
|
||||
string result = Utils.GetEmbedText(SampleClient);
|
||||
string result = Utils.GetEmbedText(Global.SingboxSampleClient);
|
||||
if (Utils.IsNullOrEmpty(result))
|
||||
{
|
||||
msg = ResUI.FailedGetDefaultConfiguration;
|
||||
|
@ -42,17 +41,17 @@ namespace v2rayN.Handler
|
|||
return -1;
|
||||
}
|
||||
|
||||
log(singboxConfig);
|
||||
GenLog(singboxConfig);
|
||||
|
||||
inbound(singboxConfig);
|
||||
GenInbounds(singboxConfig);
|
||||
|
||||
outbound(node, singboxConfig);
|
||||
GenOutbounds(node, singboxConfig);
|
||||
|
||||
routing(singboxConfig);
|
||||
GenRouting(singboxConfig);
|
||||
|
||||
dns(node, singboxConfig);
|
||||
GenDns(node, singboxConfig);
|
||||
|
||||
statistic(singboxConfig);
|
||||
GenStatistic(singboxConfig);
|
||||
|
||||
msg = string.Format(ResUI.SuccessfulConfiguration, "");
|
||||
}
|
||||
|
@ -65,7 +64,7 @@ namespace v2rayN.Handler
|
|||
return 0;
|
||||
}
|
||||
|
||||
private int log(SingboxConfig singboxConfig)
|
||||
private int GenLog(SingboxConfig singboxConfig)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -103,7 +102,7 @@ namespace v2rayN.Handler
|
|||
|
||||
#region inbound private
|
||||
|
||||
private int inbound(SingboxConfig singboxConfig)
|
||||
private int GenInbounds(SingboxConfig singboxConfig)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -203,7 +202,7 @@ namespace v2rayN.Handler
|
|||
|
||||
#region outbound private
|
||||
|
||||
private int outbound(ProfileItem node, SingboxConfig singboxConfig)
|
||||
private int GenOutbounds(ProfileItem node, SingboxConfig singboxConfig)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -235,7 +234,7 @@ namespace v2rayN.Handler
|
|||
outbound.security = Global.DefaultSecurity;
|
||||
}
|
||||
|
||||
outboundMux(node, outbound);
|
||||
GenOutboundMux(node, outbound);
|
||||
}
|
||||
else if (node.configType == EConfigType.Shadowsocks)
|
||||
{
|
||||
|
@ -244,7 +243,7 @@ namespace v2rayN.Handler
|
|||
outbound.method = LazyConfig.Instance.GetShadowsocksSecuritys(node).Contains(node.security) ? node.security : "none";
|
||||
outbound.password = node.id;
|
||||
|
||||
outboundMux(node, outbound);
|
||||
GenOutboundMux(node, outbound);
|
||||
}
|
||||
else if (node.configType == EConfigType.Socks)
|
||||
{
|
||||
|
@ -268,7 +267,7 @@ namespace v2rayN.Handler
|
|||
|
||||
if (Utils.IsNullOrEmpty(node.flow))
|
||||
{
|
||||
outboundMux(node, outbound);
|
||||
GenOutboundMux(node, outbound);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -281,7 +280,7 @@ namespace v2rayN.Handler
|
|||
|
||||
outbound.password = node.id;
|
||||
|
||||
outboundMux(node, outbound);
|
||||
GenOutboundMux(node, outbound);
|
||||
}
|
||||
else if (node.configType == EConfigType.Hysteria2)
|
||||
{
|
||||
|
@ -292,7 +291,7 @@ namespace v2rayN.Handler
|
|||
outbound.up_mbps = _config.hysteriaItem.up_mbps > 0 ? _config.hysteriaItem.up_mbps : null;
|
||||
outbound.down_mbps = _config.hysteriaItem.down_mbps > 0 ? _config.hysteriaItem.down_mbps : null;
|
||||
|
||||
outboundMux(node, outbound);
|
||||
GenOutboundMux(node, outbound);
|
||||
}
|
||||
else if (node.configType == EConfigType.Tuic)
|
||||
{
|
||||
|
@ -302,12 +301,12 @@ namespace v2rayN.Handler
|
|||
outbound.password = node.security;
|
||||
outbound.congestion_control = node.headerType;
|
||||
|
||||
outboundMux(node, outbound);
|
||||
GenOutboundMux(node, outbound);
|
||||
}
|
||||
|
||||
outboundTls(node, outbound);
|
||||
GenOutboundTls(node, outbound);
|
||||
|
||||
outboundTransport(node, outbound);
|
||||
GenOutboundTransport(node, outbound);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -316,7 +315,7 @@ namespace v2rayN.Handler
|
|||
return 0;
|
||||
}
|
||||
|
||||
private int outboundMux(ProfileItem node, Outbound4Sbox outbound)
|
||||
private int GenOutboundMux(ProfileItem node, Outbound4Sbox outbound)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -341,7 +340,7 @@ namespace v2rayN.Handler
|
|||
return 0;
|
||||
}
|
||||
|
||||
private int outboundTls(ProfileItem node, Outbound4Sbox outbound)
|
||||
private int GenOutboundTls(ProfileItem node, Outbound4Sbox outbound)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -391,7 +390,7 @@ namespace v2rayN.Handler
|
|||
return 0;
|
||||
}
|
||||
|
||||
private int outboundTransport(ProfileItem node, Outbound4Sbox outbound)
|
||||
private int GenOutboundTransport(ProfileItem node, Outbound4Sbox outbound)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -447,7 +446,7 @@ namespace v2rayN.Handler
|
|||
|
||||
#region routing rule private
|
||||
|
||||
private int routing(SingboxConfig singboxConfig)
|
||||
private int GenRouting(SingboxConfig singboxConfig)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -458,7 +457,7 @@ namespace v2rayN.Handler
|
|||
var tunRules = Utils.FromJson<List<Rule4Sbox>>(Utils.GetEmbedText(Global.TunSingboxRulesFileName));
|
||||
singboxConfig.route.rules.AddRange(tunRules);
|
||||
|
||||
routingDirectExe(out List<string> lstDnsExe, out List<string> lstDirectExe);
|
||||
GenRoutingDirectExe(out List<string> lstDnsExe, out List<string> lstDirectExe);
|
||||
singboxConfig.route.rules.Add(new()
|
||||
{
|
||||
port = new() { 53 },
|
||||
|
@ -483,7 +482,7 @@ namespace v2rayN.Handler
|
|||
{
|
||||
if (item.enabled)
|
||||
{
|
||||
routingUserRule(item, singboxConfig.route.rules);
|
||||
GenRoutingUserRule(item, singboxConfig.route.rules);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -496,7 +495,7 @@ namespace v2rayN.Handler
|
|||
var rules = Utils.FromJson<List<RulesItem>>(lockedItem.ruleSet);
|
||||
foreach (var item in rules!)
|
||||
{
|
||||
routingUserRule(item, singboxConfig.route.rules);
|
||||
GenRoutingUserRule(item, singboxConfig.route.rules);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -508,7 +507,7 @@ namespace v2rayN.Handler
|
|||
return 0;
|
||||
}
|
||||
|
||||
private void routingDirectExe(out List<string> lstDnsExe, out List<string> lstDirectExe)
|
||||
private void GenRoutingDirectExe(out List<string> lstDnsExe, out List<string> lstDirectExe)
|
||||
{
|
||||
lstDnsExe = new();
|
||||
lstDirectExe = new();
|
||||
|
@ -534,7 +533,7 @@ namespace v2rayN.Handler
|
|||
}
|
||||
}
|
||||
|
||||
private int routingUserRule(RulesItem item, List<Rule4Sbox> rules)
|
||||
private int GenRoutingUserRule(RulesItem item, List<Rule4Sbox> rules)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -575,7 +574,7 @@ namespace v2rayN.Handler
|
|||
{
|
||||
foreach (var it in item.domain)
|
||||
{
|
||||
parseV2Domain(it, rule);
|
||||
ParseV2Domain(it, rule);
|
||||
}
|
||||
rules.Add(rule);
|
||||
hasDomainIp = true;
|
||||
|
@ -585,7 +584,7 @@ namespace v2rayN.Handler
|
|||
{
|
||||
foreach (var it in item.ip)
|
||||
{
|
||||
parseV2Address(it, rule2);
|
||||
ParseV2Address(it, rule2);
|
||||
}
|
||||
rules.Add(rule2);
|
||||
hasDomainIp = true;
|
||||
|
@ -610,7 +609,7 @@ namespace v2rayN.Handler
|
|||
return 0;
|
||||
}
|
||||
|
||||
private void parseV2Domain(string domain, Rule4Sbox rule)
|
||||
private void ParseV2Domain(string domain, Rule4Sbox rule)
|
||||
{
|
||||
if (domain.StartsWith("ext:") || domain.StartsWith("ext-domain:"))
|
||||
{
|
||||
|
@ -650,7 +649,7 @@ namespace v2rayN.Handler
|
|||
}
|
||||
}
|
||||
|
||||
private void parseV2Address(string address, Rule4Sbox rule)
|
||||
private void ParseV2Address(string address, Rule4Sbox rule)
|
||||
{
|
||||
if (address.StartsWith("ext:") || address.StartsWith("ext-ip:"))
|
||||
{
|
||||
|
@ -676,7 +675,7 @@ namespace v2rayN.Handler
|
|||
|
||||
#region dns private
|
||||
|
||||
private int dns(ProfileItem node, SingboxConfig singboxConfig)
|
||||
private int GenDns(ProfileItem node, SingboxConfig singboxConfig)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -734,7 +733,7 @@ namespace v2rayN.Handler
|
|||
|
||||
#endregion dns private
|
||||
|
||||
private int statistic(SingboxConfig singboxConfig)
|
||||
private int GenStatistic(SingboxConfig singboxConfig)
|
||||
{
|
||||
if (_config.guiItem.enableStatistics)
|
||||
{
|
||||
|
|
|
@ -148,7 +148,7 @@ namespace v2rayN.ViewModels
|
|||
//CheckUpdate
|
||||
public ReactiveCommand<Unit, Unit> CheckUpdateNCmd { get; }
|
||||
|
||||
public ReactiveCommand<Unit, Unit> CheckUpdateV2flyCoreCmd { get; }
|
||||
//public ReactiveCommand<Unit, Unit> CheckUpdateV2flyCoreCmd { get; }
|
||||
|
||||
//public ReactiveCommand<Unit, Unit> CheckUpdateSagerNetCoreCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> CheckUpdateXrayCoreCmd { get; }
|
||||
|
@ -509,10 +509,10 @@ namespace v2rayN.ViewModels
|
|||
{
|
||||
CheckUpdateN();
|
||||
});
|
||||
CheckUpdateV2flyCoreCmd = ReactiveCommand.Create(() =>
|
||||
{
|
||||
CheckUpdateCore(ECoreType.v2fly_v5);
|
||||
});
|
||||
//CheckUpdateV2flyCoreCmd = ReactiveCommand.Create(() =>
|
||||
//{
|
||||
// CheckUpdateCore(ECoreType.v2fly_v5);
|
||||
//});
|
||||
//CheckUpdateSagerNetCoreCmd = ReactiveCommand.Create(() =>
|
||||
//{
|
||||
// CheckUpdateCore(ECoreType.SagerNet);
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
<reactiveui:ReactiveWindow
|
||||
x:Class="v2rayN.Views.MainWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
xmlns:reactiveui="http://reactiveui.net"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:tb="clr-namespace:H.NotifyIcon;assembly=H.NotifyIcon.Wpf"
|
||||
xmlns:base="clr-namespace:v2rayN.Base"
|
||||
xmlns:conv="clr-namespace:v2rayN.Converters"
|
||||
xmlns:resx="clr-namespace:v2rayN.Resx"
|
||||
xmlns:vms="clr-namespace:v2rayN.ViewModels"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:v2rayN.Views"
|
||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:reactiveui="http://reactiveui.net"
|
||||
xmlns:resx="clr-namespace:v2rayN.Resx"
|
||||
xmlns:tb="clr-namespace:H.NotifyIcon;assembly=H.NotifyIcon.Wpf"
|
||||
xmlns:vms="clr-namespace:v2rayN.ViewModels"
|
||||
Title="v2rayN"
|
||||
Width="900"
|
||||
Height="700"
|
||||
|
@ -216,11 +216,11 @@
|
|||
x:Name="menuCheckUpdateN"
|
||||
Height="{StaticResource MenuItemHeight}"
|
||||
Header="V2rayN" />
|
||||
<MenuItem
|
||||
<!--<MenuItem
|
||||
x:Name="menuCheckUpdateV2flyCore"
|
||||
Height="{StaticResource MenuItemHeight}"
|
||||
Header="V2fly v5 Core" />
|
||||
<!--<MenuItem
|
||||
<MenuItem
|
||||
x:Name="menuCheckUpdateSagerNetCore"
|
||||
Height="{StaticResource MenuItemHeight}"
|
||||
Header="SagerNet Core" />-->
|
||||
|
|
|
@ -140,7 +140,7 @@ namespace v2rayN.Views
|
|||
|
||||
//checkupdate
|
||||
this.BindCommand(ViewModel, vm => vm.CheckUpdateNCmd, v => v.menuCheckUpdateN).DisposeWith(disposables);
|
||||
this.BindCommand(ViewModel, vm => vm.CheckUpdateV2flyCoreCmd, v => v.menuCheckUpdateV2flyCore).DisposeWith(disposables);
|
||||
//this.BindCommand(ViewModel, vm => vm.CheckUpdateV2flyCoreCmd, v => v.menuCheckUpdateV2flyCore).DisposeWith(disposables);
|
||||
//this.BindCommand(ViewModel, vm => vm.CheckUpdateSagerNetCoreCmd, v => v.menuCheckUpdateSagerNetCore).DisposeWith(disposables);
|
||||
this.BindCommand(ViewModel, vm => vm.CheckUpdateXrayCoreCmd, v => v.menuCheckUpdateXrayCore).DisposeWith(disposables);
|
||||
//this.BindCommand(ViewModel, vm => vm.CheckUpdateClashCoreCmd, v => v.menuCheckUpdateClashCore).DisposeWith(disposables);
|
||||
|
|
Loading…
Reference in a new issue