Browse Source

Bug fix

pull/4917/head
2dust 8 months ago
parent
commit
dc3f07ee84
  1. 35
      v2rayN/v2rayN/Handler/CoreConfigSingbox.cs
  2. 14
      v2rayN/v2rayN/Models/V2rayConfig.cs

35
v2rayN/v2rayN/Handler/CoreConfigSingbox.cs

@ -653,22 +653,30 @@ namespace v2rayN.Handler
var hasDomainIp = false;
if (item.domain?.Count > 0)
{
var countDomain = 0;
foreach (var it in item.domain)
{
ParseV2Domain(it, rule);
if (ParseV2Domain(it, rule)) countDomain++;
}
if (countDomain > 0)
{
rules.Add(rule);
hasDomainIp = true;
}
rules.Add(rule);
hasDomainIp = true;
}
if (item.ip?.Count > 0)
{
var countIp = 0;
foreach (var it in item.ip)
{
ParseV2Address(it, rule2);
if (ParseV2Address(it, rule2)) countIp++;
}
if (countIp > 0)
{
rules.Add(rule2);
hasDomainIp = true;
}
rules.Add(rule2);
hasDomainIp = true;
}
if (_config.tunModeItem.enableTun && item.process?.Count > 0)
@ -678,7 +686,8 @@ namespace v2rayN.Handler
hasDomainIp = true;
}
if (!hasDomainIp)
if (!hasDomainIp
&& (rule.port != null || rule.port_range != null || rule.protocol != null || rule.inbound != null))
{
rules.Add(rule);
}
@ -690,11 +699,11 @@ namespace v2rayN.Handler
return 0;
}
private void ParseV2Domain(string domain, Rule4Sbox rule)
private bool ParseV2Domain(string domain, Rule4Sbox rule)
{
if (domain.StartsWith("#") || domain.StartsWith("ext:") || domain.StartsWith("ext-domain:"))
{
return;
return false;
}
else if (domain.StartsWith("geosite:"))
{
@ -728,17 +737,18 @@ namespace v2rayN.Handler
rule.domain_keyword ??= [];
rule.domain_keyword?.Add(domain);
}
return true;
}
private void ParseV2Address(string address, Rule4Sbox rule)
private bool ParseV2Address(string address, Rule4Sbox rule)
{
if (address.StartsWith("ext:") || address.StartsWith("ext-ip:"))
{
return;
return false;
}
else if (address.StartsWith("geoip:!"))
{
return;
return false;
}
else if (address.StartsWith("geoip:"))
{
@ -750,6 +760,7 @@ namespace v2rayN.Handler
if (rule.ip_cidr is null) { rule.ip_cidr = new(); }
rule.ip_cidr?.Add(address);
}
return true;
}
private int GenDns(ProfileItem node, SingboxConfig singboxConfig)

14
v2rayN/v2rayN/Models/V2rayConfig.cs

@ -389,19 +389,19 @@ namespace v2rayN.Models
[Serializable]
public class RulesItem4Ray
{
public string type { get; set; }
public string? type { get; set; }
public string port { get; set; }
public string? port { 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 class StreamSettings4Ray

Loading…
Cancel
Save