mirror of
https://github.com/2dust/v2rayN.git
synced 2025-04-19 13:42:24 +00:00
Add domain field for WireGuard exit node
This commit is contained in:
parent
e07033e22c
commit
83a46c2873
1 changed files with 24 additions and 4 deletions
|
@ -1176,11 +1176,14 @@ public class CoreConfigV2rayService
|
|||
private async Task<int> GenDnsDomains(ProfileItem? node, JsonNode dns, DNSItem? dNSItem)
|
||||
{
|
||||
if (node == null)
|
||||
{ return 0; }
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
var servers = dns["servers"];
|
||||
if (servers != null)
|
||||
{
|
||||
var domainList = new List<string>();
|
||||
string? wireguardEndpointDomain = null;
|
||||
if (Utils.IsDomain(node.Address))
|
||||
{
|
||||
domainList.Add(node.Address);
|
||||
|
@ -1188,7 +1191,7 @@ public class CoreConfigV2rayService
|
|||
var subItem = await AppHandler.Instance.GetSubItem(node.Subid);
|
||||
if (subItem is not null)
|
||||
{
|
||||
//Previous proxy
|
||||
// Previous proxy
|
||||
var prevNode = await AppHandler.Instance.GetProfileItemViaRemarks(subItem.PrevProfile);
|
||||
if (prevNode is not null
|
||||
&& prevNode.ConfigType != EConfigType.Custom
|
||||
|
@ -1199,17 +1202,24 @@ public class CoreConfigV2rayService
|
|||
domainList.Add(prevNode.Address);
|
||||
}
|
||||
|
||||
//Next proxy
|
||||
// Next proxy
|
||||
var nextNode = await AppHandler.Instance.GetProfileItemViaRemarks(subItem.NextProfile);
|
||||
if (nextNode is not null
|
||||
&& nextNode.ConfigType != EConfigType.Custom
|
||||
&& nextNode.ConfigType != EConfigType.Hysteria2
|
||||
&& nextNode.ConfigType != EConfigType.TUIC
|
||||
&& Utils.IsDomain(nextNode.Address))
|
||||
{
|
||||
if (nextNode.ConfigType == EConfigType.WireGuard)
|
||||
{
|
||||
wireguardEndpointDomain = nextNode.Address;
|
||||
}
|
||||
else
|
||||
{
|
||||
domainList.Add(nextNode.Address);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (domainList.Count > 0)
|
||||
{
|
||||
var dnsServer = new DnsServer4Ray()
|
||||
|
@ -1218,6 +1228,16 @@ public class CoreConfigV2rayService
|
|||
skipFallback = true,
|
||||
domains = domainList
|
||||
};
|
||||
servers.AsArray().Add(JsonUtils.SerializeToNode(dnsServer));
|
||||
}
|
||||
if (wireguardEndpointDomain is not null)
|
||||
{
|
||||
var dnsServer = new DnsServer4Ray()
|
||||
{
|
||||
address = string.IsNullOrEmpty(dNSItem?.DomainDNSAddress) ? Global.DomainDNSAddress.FirstOrDefault() : dNSItem?.DomainDNSAddress,
|
||||
skipFallback = true,
|
||||
domains = new() { wireguardEndpointDomain }
|
||||
};
|
||||
servers.AsArray().Insert(0, JsonUtils.SerializeToNode(dnsServer));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue