mirror of
https://github.com/fergalmoran/DnsServer.git
synced 2025-12-22 09:29:50 +00:00
AdvancedForwarding: updated adguard upstream implementation to support multiple forwarders.
This commit is contained in:
@@ -547,6 +547,8 @@ namespace AdvancedForwarding
|
|||||||
{
|
{
|
||||||
#region variables
|
#region variables
|
||||||
|
|
||||||
|
static readonly char[] _popWordSeperator = new char[] { ' ' };
|
||||||
|
|
||||||
readonly IDnsServer _dnsServer;
|
readonly IDnsServer _dnsServer;
|
||||||
|
|
||||||
readonly string _name;
|
readonly string _name;
|
||||||
@@ -666,7 +668,28 @@ namespace AdvancedForwarding
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
forwardings.Add(new Forwarding(domains, NameServerAddress.Parse(forwarder), _dnssecValidation, _configProxyServer));
|
List<DnsForwarderRecordData> forwarderRecords = new List<DnsForwarderRecordData>();
|
||||||
|
string word = PopWord(ref forwarder);
|
||||||
|
|
||||||
|
while (word.Length > 0)
|
||||||
|
{
|
||||||
|
string nextWord = PopWord(ref forwarder);
|
||||||
|
|
||||||
|
if (nextWord.StartsWith('('))
|
||||||
|
{
|
||||||
|
word += " " + nextWord;
|
||||||
|
nextWord = PopWord(ref forwarder);
|
||||||
|
}
|
||||||
|
|
||||||
|
forwarderRecords.Add(GetForwarderRecord(NameServerAddress.Parse(word), _dnssecValidation, _configProxyServer));
|
||||||
|
|
||||||
|
word = nextWord;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (forwarderRecords.Count == 0)
|
||||||
|
throw new FormatException("Invalid AdGuard Upstreams config file format: missing upstream servers.");
|
||||||
|
|
||||||
|
forwardings.Add(new Forwarding(forwarderRecords, domains));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -689,6 +712,30 @@ namespace AdvancedForwarding
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static string PopWord(ref string line)
|
||||||
|
{
|
||||||
|
if (line.Length == 0)
|
||||||
|
return line;
|
||||||
|
|
||||||
|
line = line.TrimStart(_popWordSeperator);
|
||||||
|
|
||||||
|
int i = line.IndexOfAny(_popWordSeperator);
|
||||||
|
string word;
|
||||||
|
|
||||||
|
if (i < 0)
|
||||||
|
{
|
||||||
|
word = line;
|
||||||
|
line = "";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
word = line.Substring(0, i);
|
||||||
|
line = line.Substring(i + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return word;
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region public
|
#region public
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
# Example:
|
# Example:
|
||||||
# 8.8.8.8
|
# 8.8.8.8
|
||||||
# udp://9.9.9.9
|
# udp://9.9.9.9
|
||||||
# [/host.com/example.com/]tls://1.1.1.1
|
# [/host.com/example.com/]https://cloudflare-dns.com/dns-query (1.1.1.1) tls://1.1.1.1
|
||||||
# [/maps.host.com/]#
|
# [/maps.host.com/]#
|
||||||
# [/home/]192.168.10.2
|
# [/home/]192.168.10.2
|
||||||
# [/test.com/]https://dns.quad9.net/dns-query (9.9.9.9)
|
# [/test.com/]https://dns.quad9.net/dns-query (9.9.9.9)
|
||||||
|
|||||||
Reference in New Issue
Block a user