Class DohClient
Client to a DNS server over HTTPS.
Inherited Members
Namespace: Makaretu.Dns
Assembly: Makaretu.Dns.Unicast.dll
Syntax
public class DohClient : DnsClientBase, IDnsClient, IDisposable, IResolver
Remarks
DNS over HTTPS (DoH) is an experimental protocol for performing remote Domain Name System (DNS) resolution via the HTTPS protocol. The goal is to increase user privacy and security by preventing eavesdropping and manipulation of DNS data by man-in-the-middle attacks.
The DohClient uses the HTTP POST method to hide as much information as is possible. Also, it tends to generate smaller requests.
Fields
| Improve this Doc View SourceDnsJsonFormat
The MIME type for a DNS message encoded in JSON.
Declaration
public const string DnsJsonFormat = "application/dns-json"
Field Value
Type | Description |
---|---|
String |
DnsWireFormat
The MIME type for a DNS message encoded in UPD wire format.
Declaration
public const string DnsWireFormat = "application/dns-message"
Field Value
Type | Description |
---|---|
String |
Remarks
Previous drafts defined this as "application/dns-udpwireformat".
Properties
| Improve this Doc View SourceHttpClient
The client that sends HTTP requests and receives HTTP responses.
Declaration
public HttpClient HttpClient { get; set; }
Property Value
Type | Description |
---|---|
HttpClient |
Remarks
It is best practice to use only one HttpClient in an application.
ServerUrl
The DNS server to communication with.
Declaration
public string ServerUrl { get; set; }
Property Value
Type | Description |
---|---|
String | Defaults to "https://cloudflare-dns.com/dns-query". |
Timeout
Time to wait for a DNS response.
Declaration
public TimeSpan Timeout { get; set; }
Property Value
Type | Description |
---|---|
TimeSpan | The default is 4 seconds. |
Methods
| Improve this Doc View SourceQueryAsync(Message, CancellationToken)
Send a DNS query with the specified message.
Declaration
public override Task<Message> QueryAsync(Message request, CancellationToken cancel = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Message | request | |
CancellationToken | cancel | Is used to stop the task. When cancelled, the TaskCanceledException is raised. |
Returns
Type | Description |
---|---|
Task<Message> | A task that represents the asynchronous operation. The task's value contains the response Message. |
Overrides
Exceptions
Type | Condition |
---|---|
IOException | When the DNS server returns error status or no response. |