This commit is contained in:
2dust 2023-12-23 17:49:39 +08:00
parent 1ac7661593
commit b0c5f74edb
6 changed files with 50 additions and 50 deletions

View file

@ -1180,7 +1180,7 @@ namespace v2rayN.Handler
var fileName = Utils.GetTempPath($"{Utils.GetGUID(false)}.yaml"); var fileName = Utils.GetTempPath($"{Utils.GetGUID(false)}.yaml");
File.WriteAllText(fileName, clipboardData); File.WriteAllText(fileName, clipboardData);
profileItem.coreType = ECoreType.clash; profileItem.coreType = ECoreType.mihomo;
profileItem.address = fileName; profileItem.address = fileName;
profileItem.remarks = "clash_custom"; profileItem.remarks = "clash_custom";
} }

View file

@ -119,6 +119,7 @@ namespace v2rayN.Handler
case ECoreType.clash: case ECoreType.clash:
case ECoreType.clash_meta: case ECoreType.clash_meta:
case ECoreType.mihomo:
//remove the original //remove the original
var indexPort = fileContent.FindIndex(t => t.Contains("port:")); var indexPort = fileContent.FindIndex(t => t.Contains("port:"));
if (indexPort >= 0) if (indexPort >= 0)

View file

@ -6,7 +6,6 @@ namespace v2rayN.Handler
{ {
internal class CoreConfigSingbox internal class CoreConfigSingbox
{ {
private string SampleClient = Global.SingboxSampleClient;
private Config _config; private Config _config;
public CoreConfigSingbox(Config config) public CoreConfigSingbox(Config config)
@ -28,7 +27,7 @@ namespace v2rayN.Handler
msg = ResUI.InitialConfiguration; msg = ResUI.InitialConfiguration;
string result = Utils.GetEmbedText(SampleClient); string result = Utils.GetEmbedText(Global.SingboxSampleClient);
if (Utils.IsNullOrEmpty(result)) if (Utils.IsNullOrEmpty(result))
{ {
msg = ResUI.FailedGetDefaultConfiguration; msg = ResUI.FailedGetDefaultConfiguration;
@ -42,17 +41,17 @@ namespace v2rayN.Handler
return -1; 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, ""); msg = string.Format(ResUI.SuccessfulConfiguration, "");
} }
@ -65,7 +64,7 @@ namespace v2rayN.Handler
return 0; return 0;
} }
private int log(SingboxConfig singboxConfig) private int GenLog(SingboxConfig singboxConfig)
{ {
try try
{ {
@ -103,7 +102,7 @@ namespace v2rayN.Handler
#region inbound private #region inbound private
private int inbound(SingboxConfig singboxConfig) private int GenInbounds(SingboxConfig singboxConfig)
{ {
try try
{ {
@ -203,7 +202,7 @@ namespace v2rayN.Handler
#region outbound private #region outbound private
private int outbound(ProfileItem node, SingboxConfig singboxConfig) private int GenOutbounds(ProfileItem node, SingboxConfig singboxConfig)
{ {
try try
{ {
@ -235,7 +234,7 @@ namespace v2rayN.Handler
outbound.security = Global.DefaultSecurity; outbound.security = Global.DefaultSecurity;
} }
outboundMux(node, outbound); GenOutboundMux(node, outbound);
} }
else if (node.configType == EConfigType.Shadowsocks) 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.method = LazyConfig.Instance.GetShadowsocksSecuritys(node).Contains(node.security) ? node.security : "none";
outbound.password = node.id; outbound.password = node.id;
outboundMux(node, outbound); GenOutboundMux(node, outbound);
} }
else if (node.configType == EConfigType.Socks) else if (node.configType == EConfigType.Socks)
{ {
@ -268,7 +267,7 @@ namespace v2rayN.Handler
if (Utils.IsNullOrEmpty(node.flow)) if (Utils.IsNullOrEmpty(node.flow))
{ {
outboundMux(node, outbound); GenOutboundMux(node, outbound);
} }
else else
{ {
@ -281,7 +280,7 @@ namespace v2rayN.Handler
outbound.password = node.id; outbound.password = node.id;
outboundMux(node, outbound); GenOutboundMux(node, outbound);
} }
else if (node.configType == EConfigType.Hysteria2) 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.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; 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) else if (node.configType == EConfigType.Tuic)
{ {
@ -302,12 +301,12 @@ namespace v2rayN.Handler
outbound.password = node.security; outbound.password = node.security;
outbound.congestion_control = node.headerType; 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) catch (Exception ex)
{ {
@ -316,7 +315,7 @@ namespace v2rayN.Handler
return 0; return 0;
} }
private int outboundMux(ProfileItem node, Outbound4Sbox outbound) private int GenOutboundMux(ProfileItem node, Outbound4Sbox outbound)
{ {
try try
{ {
@ -341,7 +340,7 @@ namespace v2rayN.Handler
return 0; return 0;
} }
private int outboundTls(ProfileItem node, Outbound4Sbox outbound) private int GenOutboundTls(ProfileItem node, Outbound4Sbox outbound)
{ {
try try
{ {
@ -391,7 +390,7 @@ namespace v2rayN.Handler
return 0; return 0;
} }
private int outboundTransport(ProfileItem node, Outbound4Sbox outbound) private int GenOutboundTransport(ProfileItem node, Outbound4Sbox outbound)
{ {
try try
{ {
@ -447,7 +446,7 @@ namespace v2rayN.Handler
#region routing rule private #region routing rule private
private int routing(SingboxConfig singboxConfig) private int GenRouting(SingboxConfig singboxConfig)
{ {
try try
{ {
@ -458,7 +457,7 @@ namespace v2rayN.Handler
var tunRules = Utils.FromJson<List<Rule4Sbox>>(Utils.GetEmbedText(Global.TunSingboxRulesFileName)); var tunRules = Utils.FromJson<List<Rule4Sbox>>(Utils.GetEmbedText(Global.TunSingboxRulesFileName));
singboxConfig.route.rules.AddRange(tunRules); 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() singboxConfig.route.rules.Add(new()
{ {
port = new() { 53 }, port = new() { 53 },
@ -483,7 +482,7 @@ namespace v2rayN.Handler
{ {
if (item.enabled) 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); var rules = Utils.FromJson<List<RulesItem>>(lockedItem.ruleSet);
foreach (var item in rules!) foreach (var item in rules!)
{ {
routingUserRule(item, singboxConfig.route.rules); GenRoutingUserRule(item, singboxConfig.route.rules);
} }
} }
} }
@ -508,7 +507,7 @@ namespace v2rayN.Handler
return 0; 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(); lstDnsExe = new();
lstDirectExe = 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 try
{ {
@ -575,7 +574,7 @@ namespace v2rayN.Handler
{ {
foreach (var it in item.domain) foreach (var it in item.domain)
{ {
parseV2Domain(it, rule); ParseV2Domain(it, rule);
} }
rules.Add(rule); rules.Add(rule);
hasDomainIp = true; hasDomainIp = true;
@ -585,7 +584,7 @@ namespace v2rayN.Handler
{ {
foreach (var it in item.ip) foreach (var it in item.ip)
{ {
parseV2Address(it, rule2); ParseV2Address(it, rule2);
} }
rules.Add(rule2); rules.Add(rule2);
hasDomainIp = true; hasDomainIp = true;
@ -610,7 +609,7 @@ namespace v2rayN.Handler
return 0; return 0;
} }
private void parseV2Domain(string domain, Rule4Sbox rule) private void ParseV2Domain(string domain, Rule4Sbox rule)
{ {
if (domain.StartsWith("ext:") || domain.StartsWith("ext-domain:")) 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:")) if (address.StartsWith("ext:") || address.StartsWith("ext-ip:"))
{ {
@ -676,7 +675,7 @@ namespace v2rayN.Handler
#region dns private #region dns private
private int dns(ProfileItem node, SingboxConfig singboxConfig) private int GenDns(ProfileItem node, SingboxConfig singboxConfig)
{ {
try try
{ {
@ -734,7 +733,7 @@ namespace v2rayN.Handler
#endregion dns private #endregion dns private
private int statistic(SingboxConfig singboxConfig) private int GenStatistic(SingboxConfig singboxConfig)
{ {
if (_config.guiItem.enableStatistics) if (_config.guiItem.enableStatistics)
{ {

View file

@ -148,7 +148,7 @@ namespace v2rayN.ViewModels
//CheckUpdate //CheckUpdate
public ReactiveCommand<Unit, Unit> CheckUpdateNCmd { get; } 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> CheckUpdateSagerNetCoreCmd { get; }
public ReactiveCommand<Unit, Unit> CheckUpdateXrayCoreCmd { get; } public ReactiveCommand<Unit, Unit> CheckUpdateXrayCoreCmd { get; }
@ -509,10 +509,10 @@ namespace v2rayN.ViewModels
{ {
CheckUpdateN(); CheckUpdateN();
}); });
CheckUpdateV2flyCoreCmd = ReactiveCommand.Create(() => //CheckUpdateV2flyCoreCmd = ReactiveCommand.Create(() =>
{ //{
CheckUpdateCore(ECoreType.v2fly_v5); // CheckUpdateCore(ECoreType.v2fly_v5);
}); //});
//CheckUpdateSagerNetCoreCmd = ReactiveCommand.Create(() => //CheckUpdateSagerNetCoreCmd = ReactiveCommand.Create(() =>
//{ //{
// CheckUpdateCore(ECoreType.SagerNet); // CheckUpdateCore(ECoreType.SagerNet);

View file

@ -1,17 +1,17 @@
<reactiveui:ReactiveWindow <reactiveui:ReactiveWindow
x:Class="v2rayN.Views.MainWindow" x:Class="v2rayN.Views.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 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: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:base="clr-namespace:v2rayN.Base"
xmlns:conv="clr-namespace:v2rayN.Converters" xmlns:conv="clr-namespace:v2rayN.Converters"
xmlns:resx="clr-namespace:v2rayN.Resx" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:vms="clr-namespace:v2rayN.ViewModels"
xmlns:local="clr-namespace:v2rayN.Views" 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" Title="v2rayN"
Width="900" Width="900"
Height="700" Height="700"
@ -216,11 +216,11 @@
x:Name="menuCheckUpdateN" x:Name="menuCheckUpdateN"
Height="{StaticResource MenuItemHeight}" Height="{StaticResource MenuItemHeight}"
Header="V2rayN" /> Header="V2rayN" />
<MenuItem <!--<MenuItem
x:Name="menuCheckUpdateV2flyCore" x:Name="menuCheckUpdateV2flyCore"
Height="{StaticResource MenuItemHeight}" Height="{StaticResource MenuItemHeight}"
Header="V2fly v5 Core" /> Header="V2fly v5 Core" />
<!--<MenuItem <MenuItem
x:Name="menuCheckUpdateSagerNetCore" x:Name="menuCheckUpdateSagerNetCore"
Height="{StaticResource MenuItemHeight}" Height="{StaticResource MenuItemHeight}"
Header="SagerNet Core" />--> Header="SagerNet Core" />-->

View file

@ -140,7 +140,7 @@ namespace v2rayN.Views
//checkupdate //checkupdate
this.BindCommand(ViewModel, vm => vm.CheckUpdateNCmd, v => v.menuCheckUpdateN).DisposeWith(disposables); 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.CheckUpdateSagerNetCoreCmd, v => v.menuCheckUpdateSagerNetCore).DisposeWith(disposables);
this.BindCommand(ViewModel, vm => vm.CheckUpdateXrayCoreCmd, v => v.menuCheckUpdateXrayCore).DisposeWith(disposables); this.BindCommand(ViewModel, vm => vm.CheckUpdateXrayCoreCmd, v => v.menuCheckUpdateXrayCore).DisposeWith(disposables);
//this.BindCommand(ViewModel, vm => vm.CheckUpdateClashCoreCmd, v => v.menuCheckUpdateClashCore).DisposeWith(disposables); //this.BindCommand(ViewModel, vm => vm.CheckUpdateClashCoreCmd, v => v.menuCheckUpdateClashCore).DisposeWith(disposables);