123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- /*
- Technitium DNS Server
- Copyright (C) 2024 Shreyas Zare (shreyas@technitium.com)
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- using DnsServerCore.ApplicationCommon;
- using System;
- using System.Net.Mail;
- using System.Threading;
- using System.Threading.Tasks;
- using TechnitiumLibrary.Net.Dns;
- using TechnitiumLibrary.Net.Proxy;
- namespace DnsServerCore.Dns.Applications
- {
- class DnsServerInternal : IDnsServer
- {
- #region variables
- readonly DnsServer _dnsServer;
- readonly string _applicationName;
- readonly string _applicationFolder;
- IDnsCache _dnsCache;
- #endregion
- #region constructor
- public DnsServerInternal(DnsServer dnsServer, string applicationName, string applicationFolder)
- {
- _dnsServer = dnsServer;
- _applicationName = applicationName;
- _applicationFolder = applicationFolder;
- }
- #endregion
- #region public
- public Task<DnsDatagram> DirectQueryAsync(DnsQuestionRecord question, int timeout = 4000)
- {
- return _dnsServer.DirectQueryAsync(question, timeout, true);
- }
- public Task<DnsDatagram> DirectQueryAsync(DnsDatagram request, int timeout = 4000)
- {
- return _dnsServer.DirectQueryAsync(request, timeout, true);
- }
- public Task<DnsDatagram> ResolveAsync(DnsQuestionRecord question, CancellationToken cancellationToken = default)
- {
- return DirectQueryAsync(question);
- }
- public void WriteLog(string message)
- {
- _dnsServer.LogManager?.Write("DNS App [" + _applicationName + "]: " + message);
- }
- public void WriteLog(Exception ex)
- {
- _dnsServer.LogManager?.Write("DNS App [" + _applicationName + "]: " + ex.ToString());
- }
- #endregion
- #region properties
- public string ApplicationName
- { get { return _applicationName; } }
- public string ApplicationFolder
- { get { return _applicationFolder; } }
- public string ServerDomain
- { get { return _dnsServer.ServerDomain; } }
- public MailAddress ResponsiblePerson
- { get { return _dnsServer.ResponsiblePerson; } }
- public IDnsCache DnsCache
- {
- get
- {
- if (_dnsCache is null)
- _dnsCache = new ResolverDnsCache(_dnsServer, true);
- return _dnsCache;
- }
- }
- public NetProxy Proxy
- { get { return _dnsServer.Proxy; } }
- public bool PreferIPv6
- { get { return _dnsServer.PreferIPv6; } }
- public ushort UdpPayloadSize
- { get { return _dnsServer.UdpPayloadSize; } }
- #endregion
- }
- }
|