Skip to content

Commit

Permalink
Bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
2dust committed Jun 26, 2024
1 parent d59e59c commit 63ed231
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
25 changes: 23 additions & 2 deletions v2rayN/v2rayN/Handler/CoreConfig/CoreConfigV2ray.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Net;
using System.Net.NetworkInformation;
using System.Text.Json.Nodes;
using v2rayN.Enums;
using v2rayN.Models;
using v2rayN.Resx;
Expand Down Expand Up @@ -53,7 +54,7 @@ public int GenerateClientConfigContent(ProfileItem node, out V2rayConfig? v2rayC

GenMoreOutbounds(node, v2rayConfig);

GenDns(v2rayConfig);
GenDns(node, v2rayConfig);

GenStatistic(v2rayConfig);

Expand Down Expand Up @@ -748,7 +749,7 @@ private int GenBoundStreamSettings(ProfileItem node, StreamSettings4Ray streamSe
return 0;
}

private int GenDns(V2rayConfig v2rayConfig)
private int GenDns(ProfileItem node, V2rayConfig v2rayConfig)
{
try
{
Expand Down Expand Up @@ -800,6 +801,8 @@ private int GenDns(V2rayConfig v2rayConfig)
}
}

GenDnsDomains(node, obj);

v2rayConfig.dns = obj;
}
catch (Exception ex)
Expand All @@ -809,6 +812,24 @@ private int GenDns(V2rayConfig v2rayConfig)
return 0;
}

private int GenDnsDomains(ProfileItem node, JsonNode dns)
{
var servers = dns["servers"];
if (servers != null)
{
if (Utils.IsDomain(node.address))
{
var dnsServer = new DnsServer4Ray()
{
address = "223.5.5.5",
domains = [node.address]
};
servers.AsArray().Insert(0, JsonUtils.SerializeToNode(dnsServer));
}
}
return 0;
}

private int GenStatistic(V2rayConfig v2rayConfig)
{
if (_config.guiItem.enableStatistics)
Expand Down
8 changes: 7 additions & 1 deletion v2rayN/v2rayN/Models/V2rayConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,12 @@ public class Dns4Ray
public List<string> servers { get; set; }
}

public class DnsServer4Ray
{
public string? address { get; set; }
public List<string>? domains { get; set; }
}

public class Routing4Ray
{
/// <summary>
Expand All @@ -380,7 +386,7 @@ public class Routing4Ray
/// <summary>
///
/// </summary>
public string domainMatcher { get; set; }
public string? domainMatcher { get; set; }

/// <summary>
///
Expand Down

0 comments on commit 63ed231

Please sign in to comment.