diff --git a/DnsServerCore/Dns/Zones/CacheZone.cs b/DnsServerCore/Dns/Zones/CacheZone.cs index 417836f0..367c60d9 100644 --- a/DnsServerCore/Dns/Zones/CacheZone.cs +++ b/DnsServerCore/Dns/Zones/CacheZone.cs @@ -199,8 +199,10 @@ namespace DnsServerCore.Dns.Zones ConcurrentDictionary> entries; - NetworkAddress eDnsClientSubnet = records[0].GetCacheRecordInfo().EDnsClientSubnet; - if ((eDnsClientSubnet is null) || !IsTypeSupportedForEDnsClientSubnet(type)) + CacheRecordInfo cacheRecordInfo = records[0].GetCacheRecordInfo(); + NetworkAddress eDnsClientSubnet = cacheRecordInfo.EDnsClientSubnet; + + if ((eDnsClientSubnet is null) || (!cacheRecordInfo.ConditionalForwardingClientSubnet && !IsTypeSupportedForEDnsClientSubnet(type))) { entries = _entries; } @@ -385,11 +387,11 @@ namespace DnsServerCore.Dns.Zones return count; } - public IReadOnlyList QueryRecords(DnsResourceRecordType type, bool serveStale, bool skipSpecialCacheRecord, NetworkAddress eDnsClientSubnet) + public IReadOnlyList QueryRecords(DnsResourceRecordType type, bool serveStale, bool skipSpecialCacheRecord, NetworkAddress eDnsClientSubnet, bool conditionalForwardingClientSubnet) { ConcurrentDictionary> entries; - if ((eDnsClientSubnet is null) || !IsTypeSupportedForEDnsClientSubnet(type)) + if ((eDnsClientSubnet is null) || (!conditionalForwardingClientSubnet && !IsTypeSupportedForEDnsClientSubnet(type))) { entries = _entries; } @@ -408,7 +410,7 @@ namespace DnsServerCore.Dns.Zones if (cacheSubnet.PrefixLength > eDnsClientSubnet.PrefixLength) continue; - if (cacheSubnet.Equals(eDnsClientSubnet) || cacheSubnet.Contains(eDnsClientSubnet.Address)) + if (cacheSubnet.Equals(eDnsClientSubnet) || (!conditionalForwardingClientSubnet && cacheSubnet.Contains(eDnsClientSubnet.Address))) { if ((selectedNetwork is null) || (cacheSubnet.PrefixLength > selectedNetwork.PrefixLength)) {