4using System.Net.Http.Headers;
5using System.Threading.Tasks;
33 set => this.uri = value;
42 protected override async Task
SendAsync(
byte[] Message, IPEndPoint Destination)
44 using (HttpClient HttpClient =
new HttpClient()
46 Timeout = TimeSpan.FromMilliseconds(10000)
49 using (HttpRequestMessage Request =
new HttpRequestMessage()
51 RequestUri = this.uri,
52 Method = HttpMethod.Post
55 Request.Headers.Accept.Add(
new MediaTypeWithQualityHeaderValue(
"application/dns-message"));
56 Request.Content =
new ByteArrayContent(Message);
57 Request.Content.Headers.ContentType =
new MediaTypeHeaderValue(
"application/dns-message");
59 HttpResponseMessage Response = await HttpClient.SendAsync(Request);
61 if (Response.IsSuccessStatusCode)
63 byte[] Bin = await Response.Content.ReadAsByteArrayAsync();
74 Log.
Error(
"Unable to process DNS packet: " + ex.Message);
79 ushort ID = Message[0];
Static class managing the application event log. Applications and services log events on this static ...
static void Error(string Message, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, string StackTrace, params KeyValuePair< string, object >[] Tags)
Logs an error event.
Task Exception(Exception Exception)
Called to inform the viewer of an exception state.
Task ReceiveBinary(byte[] Data)
Called when binary data has been received.
Abstract base class for DNS clients.
virtual void Init()
Called when DNS client is ready to be initialized.
virtual async Task ProcessIncomingMessage(DnsMessage Message)
Processes an incoming message.
virtual async Task ProcessMessageFailure(ushort ID)
Request resulted in a failure.
Implements a DNS over HTTPS (DoH)-based client.
Uri Uri
DNS over HTTPS URI.
DnsHttpsClient(Uri Uri)
Implements a DNS over HTTPS (DoH)-based client.
override async Task SendAsync(byte[] Message, IPEndPoint Destination)
Sends a message to a destination.