Skip to content

Commit 63ed231

Browse files
committed
Bug fix
1 parent d59e59c commit 63ed231

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed

v2rayN/v2rayN/Handler/CoreConfig/CoreConfigV2ray.cs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Net;
22
using System.Net.NetworkInformation;
3+
using System.Text.Json.Nodes;
34
using v2rayN.Enums;
45
using v2rayN.Models;
56
using v2rayN.Resx;
@@ -53,7 +54,7 @@ public int GenerateClientConfigContent(ProfileItem node, out V2rayConfig? v2rayC
5354

5455
GenMoreOutbounds(node, v2rayConfig);
5556

56-
GenDns(v2rayConfig);
57+
GenDns(node, v2rayConfig);
5758

5859
GenStatistic(v2rayConfig);
5960

@@ -748,7 +749,7 @@ private int GenBoundStreamSettings(ProfileItem node, StreamSettings4Ray streamSe
748749
return 0;
749750
}
750751

751-
private int GenDns(V2rayConfig v2rayConfig)
752+
private int GenDns(ProfileItem node, V2rayConfig v2rayConfig)
752753
{
753754
try
754755
{
@@ -800,6 +801,8 @@ private int GenDns(V2rayConfig v2rayConfig)
800801
}
801802
}
802803

804+
GenDnsDomains(node, obj);
805+
803806
v2rayConfig.dns = obj;
804807
}
805808
catch (Exception ex)
@@ -809,6 +812,24 @@ private int GenDns(V2rayConfig v2rayConfig)
809812
return 0;
810813
}
811814

815+
private int GenDnsDomains(ProfileItem node, JsonNode dns)
816+
{
817+
var servers = dns["servers"];
818+
if (servers != null)
819+
{
820+
if (Utils.IsDomain(node.address))
821+
{
822+
var dnsServer = new DnsServer4Ray()
823+
{
824+
address = "223.5.5.5",
825+
domains = [node.address]
826+
};
827+
servers.AsArray().Insert(0, JsonUtils.SerializeToNode(dnsServer));
828+
}
829+
}
830+
return 0;
831+
}
832+
812833
private int GenStatistic(V2rayConfig v2rayConfig)
813834
{
814835
if (_config.guiItem.enableStatistics)

v2rayN/v2rayN/Models/V2rayConfig.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,12 @@ public class Dns4Ray
370370
public List<string> servers { get; set; }
371371
}
372372

373+
public class DnsServer4Ray
374+
{
375+
public string? address { get; set; }
376+
public List<string>? domains { get; set; }
377+
}
378+
373379
public class Routing4Ray
374380
{
375381
/// <summary>
@@ -380,7 +386,7 @@ public class Routing4Ray
380386
/// <summary>
381387
///
382388
/// </summary>
383-
public string domainMatcher { get; set; }
389+
public string? domainMatcher { get; set; }
384390

385391
/// <summary>
386392
///

0 commit comments

Comments
 (0)