IDnsRequestController.cs 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. Technitium DNS Server
  3. Copyright (C) 2021 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.Net;
  16. using System.Threading.Tasks;
  17. using TechnitiumLibrary.Net.Dns;
  18. namespace DnsServerCore.ApplicationCommon
  19. {
  20. public enum DnsRequestControllerAction
  21. {
  22. /// <summary>
  23. /// Allow the request to be processed.
  24. /// </summary>
  25. Allow = 0,
  26. /// <summary>
  27. /// Drop the request without any response.
  28. /// </summary>
  29. DropSilently = 1,
  30. /// <summary>
  31. /// Drop the request with a Refused response.
  32. /// </summary>
  33. DropWithRefused = 2
  34. }
  35. /// <summary>
  36. /// Allows a DNS App to inspect and optionally drop incoming DNS requests before they are processed by the DNS Server core.
  37. /// </summary>
  38. public interface IDnsRequestController
  39. {
  40. /// <summary>
  41. /// Allows a DNS App to inspect an incoming DNS request and decide whether to allow or drop it. This method is called by the DNS Server before an incoming request is processed.
  42. /// </summary>
  43. /// <param name="request">The incoming DNS request.</param>
  44. /// <param name="remoteEP">The end point (IP address and port) of the client making the request.</param>
  45. /// <param name="protocol">The protocol using which the request was received.</param>
  46. /// <returns>The action that must be taken by the DNS server i.e. if the request must be allowed or dropped.</returns>
  47. Task<DnsRequestControllerAction> GetRequestActionAsync(DnsDatagram request, IPEndPoint remoteEP, DnsTransportProtocol protocol);
  48. }
  49. }