IDnsServer.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*
  2. Technitium DNS Server
  3. Copyright (C) 2024 Shreyas Zare (shreyas@technitium.com)
  4. This program is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation, either version 3 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. using System;
  16. using System.Net.Mail;
  17. using System.Threading.Tasks;
  18. using TechnitiumLibrary.Net.Dns;
  19. using TechnitiumLibrary.Net.Proxy;
  20. namespace DnsServerCore.ApplicationCommon
  21. {
  22. /// <summary>
  23. /// Provides an interface to access the internal DNS Server core.
  24. /// </summary>
  25. public interface IDnsServer : IDnsClient
  26. {
  27. /// <summary>
  28. /// Allows querying the DNS server core directly. This call supports recursion even if its not enabled in the DNS server configuration. The request wont be routed to any of the installed DNS Apps except for processing APP records. The request and its response are not counted in any stats or logged.
  29. /// </summary>
  30. /// <param name="question">The question record containing the details to query.</param>
  31. /// <param name="timeout">The timeout value in milliseconds to wait for response.</param>
  32. /// <returns>The DNS response for the DNS query.</returns>
  33. /// <exception cref="TimeoutException">When request times out.</exception>
  34. Task<DnsDatagram> DirectQueryAsync(DnsQuestionRecord question, int timeout = 4000);
  35. /// <summary>
  36. /// Allows querying the DNS server core directly. This call supports recursion even if its not enabled in the DNS server configuration. The request wont be routed to any of the installed DNS Apps except for processing APP records. The request and its response are not counted in any stats or logged.
  37. /// </summary>
  38. /// <param name="request">The DNS request to query.</param>
  39. /// <param name="timeout">The timeout value in milliseconds to wait for response.</param>
  40. /// <returns>The DNS response for the DNS query.</returns>
  41. /// <exception cref="TimeoutException">When request times out.</exception>
  42. Task<DnsDatagram> DirectQueryAsync(DnsDatagram request, int timeout = 4000);
  43. /// <summary>
  44. /// Writes a log entry to the DNS server log file.
  45. /// </summary>
  46. /// <param name="message">The message to log.</param>
  47. void WriteLog(string message);
  48. /// <summary>
  49. /// Writes a log entry to the DNS server log file.
  50. /// </summary>
  51. /// <param name="ex">The exception to log.</param>
  52. void WriteLog(Exception ex);
  53. /// <summary>
  54. /// The name of this installed application.
  55. /// </summary>
  56. string ApplicationName { get; }
  57. /// <summary>
  58. /// The folder where this application is saved on the disk. Can be used to create temp files, read/write files, etc. for this application.
  59. /// </summary>
  60. string ApplicationFolder { get; }
  61. /// <summary>
  62. /// The primary domain name used by this DNS Server to identify itself.
  63. /// </summary>
  64. string ServerDomain { get; }
  65. /// <summary>
  66. /// The default responsible person email address for this DNS Server.
  67. /// </summary>
  68. MailAddress ResponsiblePerson { get; }
  69. /// <summary>
  70. /// The DNS cache object which provides direct access to the DNS server cache.
  71. /// </summary>
  72. IDnsCache DnsCache { get; }
  73. /// <summary>
  74. /// The proxy server setting on the DNS server to be used when required to make any outbound network connection.
  75. /// </summary>
  76. NetProxy Proxy { get; }
  77. /// <summary>
  78. /// Tells if the DNS server prefers using IPv6 as per the settings.
  79. /// </summary>
  80. bool PreferIPv6 { get; }
  81. /// <summary>
  82. /// Returns the UDP payload size configured in the settings.
  83. /// </summary>
  84. public ushort UdpPayloadSize { get; }
  85. }
  86. }