mirror of
https://github.com/fergalmoran/DnsServer.git
synced 2026-02-23 00:07:28 +00:00
code refactoring done.
This commit is contained in:
@@ -46,9 +46,9 @@ namespace DnsServerCore.Dns.Applications
|
||||
|
||||
#endregion
|
||||
|
||||
public Task<DnsDatagram> DirectQueryAsync(DnsQuestionRecord question, int timeout = 2000)
|
||||
public Task<DnsDatagram> DirectQueryAsync(DnsQuestionRecord question)
|
||||
{
|
||||
return _dnsServer.DirectQueryAsync(question, timeout);
|
||||
return _dnsServer.DirectQueryAsync(question);
|
||||
}
|
||||
|
||||
public void WriteLog(string message)
|
||||
|
||||
@@ -169,8 +169,8 @@ namespace DnsServerCore.Dns.Zones
|
||||
//resolve addresses
|
||||
try
|
||||
{
|
||||
DnsDatagram response = await dnsServer.DirectQueryAsync(new DnsQuestionRecord(nsDomain, DnsResourceRecordType.A, DnsClass.IN));
|
||||
if ((response != null) && (response.Answer.Count > 0))
|
||||
DnsDatagram response = await dnsServer.DirectQueryAsync(new DnsQuestionRecord(nsDomain, DnsResourceRecordType.A, DnsClass.IN)).WithTimeout(2000);
|
||||
if (response.Answer.Count > 0)
|
||||
{
|
||||
IReadOnlyList<IPAddress> addresses = DnsClient.ParseResponseA(response);
|
||||
foreach (IPAddress address in addresses)
|
||||
@@ -184,8 +184,8 @@ namespace DnsServerCore.Dns.Zones
|
||||
{
|
||||
try
|
||||
{
|
||||
DnsDatagram response = await dnsServer.DirectQueryAsync(new DnsQuestionRecord(nsDomain, DnsResourceRecordType.AAAA, DnsClass.IN));
|
||||
if ((response != null) && (response.Answer.Count > 0))
|
||||
DnsDatagram response = await dnsServer.DirectQueryAsync(new DnsQuestionRecord(nsDomain, DnsResourceRecordType.AAAA, DnsClass.IN)).WithTimeout(2000);
|
||||
if (response.Answer.Count > 0)
|
||||
{
|
||||
IReadOnlyList<IPAddress> addresses = DnsClient.ParseResponseAAAA(response);
|
||||
foreach (IPAddress address in addresses)
|
||||
|
||||
@@ -23,6 +23,7 @@ using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using TechnitiumLibrary.IO;
|
||||
using TechnitiumLibrary.Net.Dns;
|
||||
using TechnitiumLibrary.Net.Dns.ResourceRecords;
|
||||
|
||||
@@ -91,11 +92,11 @@ namespace DnsServerCore.Dns.Zones
|
||||
SecondaryZone secondaryZone = new SecondaryZone(dnsServer, name);
|
||||
|
||||
DnsQuestionRecord soaQuestion = new DnsQuestionRecord(name, DnsResourceRecordType.SOA, DnsClass.IN);
|
||||
DnsDatagram soaResponse = null;
|
||||
DnsDatagram soaResponse;
|
||||
|
||||
if (primaryNameServerAddresses == null)
|
||||
{
|
||||
soaResponse = await secondaryZone._dnsServer.DirectQueryAsync(soaQuestion);
|
||||
soaResponse = await secondaryZone._dnsServer.DirectQueryAsync(soaQuestion).WithTimeout(2000);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -107,7 +108,7 @@ namespace DnsServerCore.Dns.Zones
|
||||
soaResponse = await dnsClient.ResolveAsync(soaQuestion);
|
||||
}
|
||||
|
||||
if ((soaResponse == null) || (soaResponse.Answer.Count == 0) || (soaResponse.Answer[0].Type != DnsResourceRecordType.SOA))
|
||||
if ((soaResponse.Answer.Count == 0) || (soaResponse.Answer[0].Type != DnsResourceRecordType.SOA))
|
||||
throw new DnsServerException("DNS Server failed to find SOA record for: " + name);
|
||||
|
||||
DnsSOARecord receivedSoa = soaResponse.Answer[0].RDATA as DnsSOARecord;
|
||||
|
||||
@@ -22,6 +22,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using TechnitiumLibrary.IO;
|
||||
using TechnitiumLibrary.Net.Dns;
|
||||
using TechnitiumLibrary.Net.Dns.ResourceRecords;
|
||||
|
||||
@@ -76,11 +77,11 @@ namespace DnsServerCore.Dns.Zones
|
||||
StubZone stubZone = new StubZone(dnsServer, name);
|
||||
|
||||
DnsQuestionRecord soaQuestion = new DnsQuestionRecord(name, DnsResourceRecordType.SOA, DnsClass.IN);
|
||||
DnsDatagram soaResponse = null;
|
||||
DnsDatagram soaResponse;
|
||||
|
||||
if (primaryNameServerAddresses == null)
|
||||
{
|
||||
soaResponse = await stubZone._dnsServer.DirectQueryAsync(soaQuestion);
|
||||
soaResponse = await stubZone._dnsServer.DirectQueryAsync(soaQuestion).WithTimeout(2000);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -92,7 +93,7 @@ namespace DnsServerCore.Dns.Zones
|
||||
soaResponse = await dnsClient.ResolveAsync(soaQuestion);
|
||||
}
|
||||
|
||||
if ((soaResponse == null) || (soaResponse.Answer.Count == 0) || (soaResponse.Answer[0].Type != DnsResourceRecordType.SOA))
|
||||
if ((soaResponse.Answer.Count == 0) || (soaResponse.Answer[0].Type != DnsResourceRecordType.SOA))
|
||||
throw new DnsServerException("DNS Server failed to find SOA record for: " + name);
|
||||
|
||||
DnsSOARecord receivedSoa = soaResponse.Answer[0].RDATA as DnsSOARecord;
|
||||
|
||||
Reference in New Issue
Block a user