mirror of
https://github.com/2dust/v2rayN.git
synced 2026-04-16 12:35:46 +00:00
Merge branch '2dust:master' into master
This commit is contained in:
commit
facc50e63e
15 changed files with 109 additions and 54 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
<Project>
|
<Project>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Version>7.19.2</Version>
|
<Version>7.19.3</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
|
|
|
||||||
|
|
@ -227,7 +227,7 @@ public class CoreConfigContextBuilder
|
||||||
{
|
{
|
||||||
var result = NodeValidatorResult.Empty();
|
var result = NodeValidatorResult.Empty();
|
||||||
|
|
||||||
if (node.Subid.IsNullOrEmpty())
|
if (node.Subid.IsNullOrEmpty() || node.ConfigType == EConfigType.Custom)
|
||||||
{
|
{
|
||||||
return (null, result);
|
return (null, result);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,9 @@ public class NodeValidator
|
||||||
{
|
{
|
||||||
var transportError = ValidateSingboxTransport(item.ConfigType, net);
|
var transportError = ValidateSingboxTransport(item.ConfigType, net);
|
||||||
if (transportError != null)
|
if (transportError != null)
|
||||||
|
{
|
||||||
v.Error(transportError);
|
v.Error(transportError);
|
||||||
|
}
|
||||||
|
|
||||||
if (!Global.SingboxSupportConfigType.Contains(item.ConfigType))
|
if (!Global.SingboxSupportConfigType.Contains(item.ConfigType))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -723,8 +723,6 @@ public static class ConfigHandler
|
||||||
profileItem.SetProtocolExtra(profileItem.GetProtocolExtra() with
|
profileItem.SetProtocolExtra(profileItem.GetProtocolExtra() with
|
||||||
{
|
{
|
||||||
SalamanderPass = profileItem.GetProtocolExtra().SalamanderPass?.TrimEx(),
|
SalamanderPass = profileItem.GetProtocolExtra().SalamanderPass?.TrimEx(),
|
||||||
UpMbps = profileItem.GetProtocolExtra().UpMbps is null or < 0 ? config.HysteriaItem.UpMbps : profileItem.GetProtocolExtra().UpMbps,
|
|
||||||
DownMbps = profileItem.GetProtocolExtra().DownMbps is null or < 0 ? config.HysteriaItem.DownMbps : profileItem.GetProtocolExtra().DownMbps,
|
|
||||||
HopInterval = profileItem.GetProtocolExtra().HopInterval?.TrimEx(),
|
HopInterval = profileItem.GetProtocolExtra().HopInterval?.TrimEx(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -1042,8 +1040,8 @@ public static class ConfigHandler
|
||||||
|
|
||||||
if (profileItem.StreamSecurity.IsNotEmpty())
|
if (profileItem.StreamSecurity.IsNotEmpty())
|
||||||
{
|
{
|
||||||
if (profileItem.StreamSecurity != Global.StreamSecurity
|
if (profileItem.StreamSecurity is not Global.StreamSecurity
|
||||||
&& profileItem.StreamSecurity != Global.StreamSecurityReality)
|
and not Global.StreamSecurityReality)
|
||||||
{
|
{
|
||||||
profileItem.StreamSecurity = string.Empty;
|
profileItem.StreamSecurity = string.Empty;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,6 @@ public class ServerTestItem
|
||||||
public bool AllowTest { get; set; }
|
public bool AllowTest { get; set; }
|
||||||
public bool NeedAutoFillRemarks { get; set; }
|
public bool NeedAutoFillRemarks { get; set; }
|
||||||
public int QueueNum { get; set; }
|
public int QueueNum { get; set; }
|
||||||
public required ProfileItem Profile { get; set; }
|
public ProfileItem Profile { get; set; }
|
||||||
public ECoreType CoreType { get; set; }
|
public ECoreType CoreType { get; set; }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -360,6 +360,7 @@ public class TlsSettings4Ray
|
||||||
public bool? disableSystemRoot { get; set; }
|
public bool? disableSystemRoot { get; set; }
|
||||||
public string? echConfigList { get; set; }
|
public string? echConfigList { get; set; }
|
||||||
public string? echForceQuery { get; set; }
|
public string? echForceQuery { get; set; }
|
||||||
|
public Sockopt4Ray? echSockopt { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class CertificateSettings4Ray
|
public class CertificateSettings4Ray
|
||||||
|
|
|
||||||
|
|
@ -243,7 +243,6 @@ public partial class CoreConfigSingboxService
|
||||||
if (Utils.IsIpv6(predefined))
|
if (Utils.IsIpv6(predefined))
|
||||||
{
|
{
|
||||||
rule.answer = new List<string> { $"*. IN AAAA {predefined}" };
|
rule.answer = new List<string> { $"*. IN AAAA {predefined}" };
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -316,16 +316,24 @@ public partial class CoreConfigV2rayService(CoreConfigContext context)
|
||||||
SsMethod = Global.None,
|
SsMethod = Global.None,
|
||||||
});
|
});
|
||||||
|
|
||||||
foreach (var outbound in _coreConfig.outbounds.Where(outbound => outbound.streamSettings?.sockopt?.dialerProxy?.IsNullOrEmpty() ?? true))
|
foreach (var outbound in _coreConfig.outbounds
|
||||||
|
.Where(o => o.streamSettings?.sockopt?.dialerProxy?.IsNullOrEmpty() ?? true))
|
||||||
{
|
{
|
||||||
outbound.streamSettings ??= new StreamSettings4Ray();
|
outbound.streamSettings ??= new();
|
||||||
outbound.streamSettings.sockopt ??= new Sockopt4Ray();
|
outbound.streamSettings.sockopt ??= new();
|
||||||
outbound.streamSettings.sockopt.dialerProxy = "tun-project-ss";
|
outbound.streamSettings.sockopt.dialerProxy = "tun-protect-ss";
|
||||||
|
}
|
||||||
|
// ech protected
|
||||||
|
foreach (var outbound in _coreConfig.outbounds
|
||||||
|
.Where(outbound => outbound.streamSettings?.tlsSettings?.echConfigList?.IsNullOrEmpty() == false))
|
||||||
|
{
|
||||||
|
outbound.streamSettings!.tlsSettings!.echSockopt ??= new();
|
||||||
|
outbound.streamSettings.tlsSettings.echSockopt.dialerProxy = "tun-protect-ss";
|
||||||
}
|
}
|
||||||
_coreConfig.outbounds.Add(new CoreConfigV2rayService(context with
|
_coreConfig.outbounds.Add(new CoreConfigV2rayService(context with
|
||||||
{
|
{
|
||||||
Node = protectNode,
|
Node = protectNode,
|
||||||
}).BuildProxyOutbound("tun-project-ss"));
|
}).BuildProxyOutbound("tun-protect-ss"));
|
||||||
|
|
||||||
_coreConfig.routing.rules ??= [];
|
_coreConfig.routing.rules ??= [];
|
||||||
var hasBalancer = _coreConfig.routing.balancers is { Count: > 0 };
|
var hasBalancer = _coreConfig.routing.balancers is { Count: > 0 };
|
||||||
|
|
|
||||||
|
|
@ -363,44 +363,36 @@ public class UpdateService(Config config, Func<bool, string, Task> updateFunc)
|
||||||
var geoipFiles = new List<string>();
|
var geoipFiles = new List<string>();
|
||||||
var geoSiteFiles = new List<string>();
|
var geoSiteFiles = new List<string>();
|
||||||
|
|
||||||
//Collect used files list
|
// Collect from routing rules
|
||||||
var routingItems = await AppManager.Instance.RoutingItems();
|
var routingItems = await AppManager.Instance.RoutingItems();
|
||||||
foreach (var routing in routingItems)
|
foreach (var routing in routingItems)
|
||||||
{
|
{
|
||||||
var rules = JsonUtils.Deserialize<List<RulesItem>>(routing.RuleSet);
|
var rules = JsonUtils.Deserialize<List<RulesItem>>(routing.RuleSet);
|
||||||
foreach (var item in rules ?? [])
|
foreach (var item in rules ?? [])
|
||||||
{
|
{
|
||||||
foreach (var ip in item.Ip ?? [])
|
AddPrefixedItems(item.Ip, "geoip:", geoipFiles);
|
||||||
{
|
AddPrefixedItems(item.Domain, "geosite:", geoSiteFiles);
|
||||||
var prefix = "geoip:";
|
|
||||||
if (ip.StartsWith(prefix))
|
|
||||||
{
|
|
||||||
geoipFiles.Add(ip.Substring(prefix.Length));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var domain in item.Domain ?? [])
|
|
||||||
{
|
|
||||||
var prefix = "geosite:";
|
|
||||||
if (domain.StartsWith(prefix))
|
|
||||||
{
|
|
||||||
geoSiteFiles.Add(domain.Substring(prefix.Length));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//append dns items TODO
|
// Collect from DNS configuration
|
||||||
geoSiteFiles.Add("google");
|
var dnsItem = await AppManager.Instance.GetDNSItem(ECoreType.sing_box);
|
||||||
geoSiteFiles.Add("cn");
|
if (dnsItem != null)
|
||||||
geoSiteFiles.Add("geolocation-cn");
|
{
|
||||||
geoSiteFiles.Add("category-ads-all");
|
ExtractDnsRuleSets(dnsItem.NormalDNS, geoipFiles, geoSiteFiles);
|
||||||
|
ExtractDnsRuleSets(dnsItem.TunDNS, geoipFiles, geoSiteFiles);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Append default items
|
||||||
|
geoSiteFiles.AddRange(["google", "cn", "geolocation-cn", "category-ads-all"]);
|
||||||
|
|
||||||
|
// Download files
|
||||||
var path = Utils.GetBinPath("srss");
|
var path = Utils.GetBinPath("srss");
|
||||||
if (!Directory.Exists(path))
|
if (!Directory.Exists(path))
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory(path);
|
Directory.CreateDirectory(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var item in geoipFiles.Distinct())
|
foreach (var item in geoipFiles.Distinct())
|
||||||
{
|
{
|
||||||
await UpdateSrsFile("geoip", item);
|
await UpdateSrsFile("geoip", item);
|
||||||
|
|
@ -412,6 +404,63 @@ public class UpdateService(Config config, Func<bool, string, Task> updateFunc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void AddPrefixedItems(List<string>? items, string prefix, List<string> output)
|
||||||
|
{
|
||||||
|
if (items == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var item in items)
|
||||||
|
{
|
||||||
|
if (item.StartsWith(prefix))
|
||||||
|
{
|
||||||
|
output.Add(item.Substring(prefix.Length));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ExtractDnsRuleSets(string? dnsJson, List<string> geoipFiles, List<string> geoSiteFiles)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(dnsJson))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var dns = JsonUtils.Deserialize<Dns4Sbox>(dnsJson);
|
||||||
|
if (dns?.rules != null)
|
||||||
|
{
|
||||||
|
foreach (var rule in dns.rules)
|
||||||
|
{
|
||||||
|
ExtractSrsRuleSets(rule, geoipFiles, geoSiteFiles);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ExtractSrsRuleSets(Rule4Sbox? rule, List<string> geoipFiles, List<string> geoSiteFiles)
|
||||||
|
{
|
||||||
|
if (rule == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
AddPrefixedItems(rule.rule_set, "geosite-", geoSiteFiles);
|
||||||
|
AddPrefixedItems(rule.rule_set, "geoip-", geoipFiles);
|
||||||
|
|
||||||
|
// Handle nested rules recursively
|
||||||
|
if (rule.rules != null)
|
||||||
|
{
|
||||||
|
foreach (var nestedRule in rule.rules)
|
||||||
|
{
|
||||||
|
ExtractSrsRuleSets(nestedRule, geoipFiles, geoSiteFiles);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private async Task UpdateSrsFile(string type, string srsName)
|
private async Task UpdateSrsFile(string type, string srsName)
|
||||||
{
|
{
|
||||||
var srsUrl = string.IsNullOrEmpty(_config.ConstItem.SrsSourceUrl)
|
var srsUrl = string.IsNullOrEmpty(_config.ConstItem.SrsSourceUrl)
|
||||||
|
|
|
||||||
|
|
@ -27,10 +27,10 @@ public class AddServerViewModel : MyReactiveObject
|
||||||
public string Ports { get; set; }
|
public string Ports { get; set; }
|
||||||
|
|
||||||
[Reactive]
|
[Reactive]
|
||||||
public int UpMbps { get; set; }
|
public int? UpMbps { get; set; }
|
||||||
|
|
||||||
[Reactive]
|
[Reactive]
|
||||||
public int DownMbps { get; set; }
|
public int? DownMbps { get; set; }
|
||||||
|
|
||||||
[Reactive]
|
[Reactive]
|
||||||
public string HopInterval { get; set; }
|
public string HopInterval { get; set; }
|
||||||
|
|
@ -113,8 +113,8 @@ public class AddServerViewModel : MyReactiveObject
|
||||||
AlterId = int.TryParse(protocolExtra?.AlterId, out var result) ? result : 0;
|
AlterId = int.TryParse(protocolExtra?.AlterId, out var result) ? result : 0;
|
||||||
Flow = protocolExtra?.Flow ?? string.Empty;
|
Flow = protocolExtra?.Flow ?? string.Empty;
|
||||||
SalamanderPass = protocolExtra?.SalamanderPass ?? string.Empty;
|
SalamanderPass = protocolExtra?.SalamanderPass ?? string.Empty;
|
||||||
UpMbps = protocolExtra?.UpMbps ?? _config.HysteriaItem.UpMbps;
|
UpMbps = protocolExtra?.UpMbps;
|
||||||
DownMbps = protocolExtra?.DownMbps ?? _config.HysteriaItem.DownMbps;
|
DownMbps = protocolExtra?.DownMbps;
|
||||||
HopInterval = protocolExtra?.HopInterval.IsNullOrEmpty() ?? true ? Global.Hysteria2DefaultHopInt.ToString() : protocolExtra.HopInterval;
|
HopInterval = protocolExtra?.HopInterval.IsNullOrEmpty() ?? true ? Global.Hysteria2DefaultHopInt.ToString() : protocolExtra.HopInterval;
|
||||||
VmessSecurity = protocolExtra?.VmessSecurity?.IsNullOrEmpty() == false ? protocolExtra.VmessSecurity : Global.DefaultSecurity;
|
VmessSecurity = protocolExtra?.VmessSecurity?.IsNullOrEmpty() == false ? protocolExtra.VmessSecurity : Global.DefaultSecurity;
|
||||||
VlessEncryption = protocolExtra?.VlessEncryption.IsNullOrEmpty() == false ? protocolExtra.VlessEncryption : Global.None;
|
VlessEncryption = protocolExtra?.VlessEncryption.IsNullOrEmpty() == false ? protocolExtra.VlessEncryption : Global.None;
|
||||||
|
|
@ -169,8 +169,8 @@ public class AddServerViewModel : MyReactiveObject
|
||||||
AlterId = AlterId > 0 ? AlterId.ToString() : null,
|
AlterId = AlterId > 0 ? AlterId.ToString() : null,
|
||||||
Flow = Flow.NullIfEmpty(),
|
Flow = Flow.NullIfEmpty(),
|
||||||
SalamanderPass = SalamanderPass.NullIfEmpty(),
|
SalamanderPass = SalamanderPass.NullIfEmpty(),
|
||||||
UpMbps = UpMbps >= 0 ? UpMbps : null,
|
UpMbps = UpMbps,
|
||||||
DownMbps = DownMbps >= 0 ? DownMbps : null,
|
DownMbps = DownMbps,
|
||||||
HopInterval = HopInterval.NullIfEmpty(),
|
HopInterval = HopInterval.NullIfEmpty(),
|
||||||
VmessSecurity = VmessSecurity.NullIfEmpty(),
|
VmessSecurity = VmessSecurity.NullIfEmpty(),
|
||||||
VlessEncryption = VlessEncryption.NullIfEmpty(),
|
VlessEncryption = VlessEncryption.NullIfEmpty(),
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,8 @@ public class OptionSettingViewModel : MyReactiveObject
|
||||||
[Reactive] public string defUserAgent { get; set; }
|
[Reactive] public string defUserAgent { get; set; }
|
||||||
[Reactive] public string mux4SboxProtocol { get; set; }
|
[Reactive] public string mux4SboxProtocol { get; set; }
|
||||||
[Reactive] public bool enableCacheFile4Sbox { get; set; }
|
[Reactive] public bool enableCacheFile4Sbox { get; set; }
|
||||||
[Reactive] public int hyUpMbps { get; set; }
|
[Reactive] public int? hyUpMbps { get; set; }
|
||||||
[Reactive] public int hyDownMbps { get; set; }
|
[Reactive] public int? hyDownMbps { get; set; }
|
||||||
[Reactive] public bool enableFragment { get; set; }
|
[Reactive] public bool enableFragment { get; set; }
|
||||||
|
|
||||||
#endregion Core
|
#endregion Core
|
||||||
|
|
@ -336,8 +336,8 @@ public class OptionSettingViewModel : MyReactiveObject
|
||||||
_config.CoreBasicItem.DefUserAgent = defUserAgent;
|
_config.CoreBasicItem.DefUserAgent = defUserAgent;
|
||||||
_config.Mux4SboxItem.Protocol = mux4SboxProtocol;
|
_config.Mux4SboxItem.Protocol = mux4SboxProtocol;
|
||||||
_config.CoreBasicItem.EnableCacheFile4Sbox = enableCacheFile4Sbox;
|
_config.CoreBasicItem.EnableCacheFile4Sbox = enableCacheFile4Sbox;
|
||||||
_config.HysteriaItem.UpMbps = hyUpMbps;
|
_config.HysteriaItem.UpMbps = hyUpMbps ?? 0;
|
||||||
_config.HysteriaItem.DownMbps = hyDownMbps;
|
_config.HysteriaItem.DownMbps = hyDownMbps ?? 0;
|
||||||
_config.CoreBasicItem.EnableFragment = enableFragment;
|
_config.CoreBasicItem.EnableFragment = enableFragment;
|
||||||
|
|
||||||
_config.GuiItem.AutoRun = AutoRun;
|
_config.GuiItem.AutoRun = AutoRun;
|
||||||
|
|
|
||||||
|
|
@ -97,8 +97,7 @@ public partial class ProfilesSelectWindow
|
||||||
|
|
||||||
private void LstProfiles_ColumnHeader_Click(object sender, RoutedEventArgs e)
|
private void LstProfiles_ColumnHeader_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
var colHeader = sender as DataGridColumnHeader;
|
if (sender is not DataGridColumnHeader colHeader || colHeader.TabIndex < 0 || colHeader.Column == null)
|
||||||
if (colHeader == null || colHeader.TabIndex < 0 || colHeader.Column == null)
|
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -233,8 +233,7 @@ public partial class ProfilesView
|
||||||
|
|
||||||
private void LstProfiles_ColumnHeader_Click(object sender, RoutedEventArgs e)
|
private void LstProfiles_ColumnHeader_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
var colHeader = sender as DataGridColumnHeader;
|
if (sender is not DataGridColumnHeader colHeader || colHeader.TabIndex < 0 || colHeader.Column == null)
|
||||||
if (colHeader == null || colHeader.TabIndex < 0 || colHeader.Column == null)
|
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue