https://github.com/akacdev/dnsoverhttps
💬 An async and lightweight C# library for Cloudflare's DNS over HTTPS.
https://github.com/akacdev/dnsoverhttps
api csharp dns dns-over-https doh domain domain-name-system library record resolve
Last synced: 5 months ago
JSON representation
💬 An async and lightweight C# library for Cloudflare's DNS over HTTPS.
- Host: GitHub
- URL: https://github.com/akacdev/dnsoverhttps
- Owner: akacdev
- License: mit
- Created: 2022-11-19T14:54:07.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2024-03-02T22:04:48.000Z (about 2 years ago)
- Last Synced: 2025-06-10T02:11:55.860Z (9 months ago)
- Topics: api, csharp, dns, dns-over-https, doh, domain, domain-name-system, library, record, resolve
- Language: C#
- Homepage: https://www.nuget.org/packages/DnsOverHttps
- Size: 61.5 KB
- Stars: 11
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# DnsOverHttps
An async and lightweight C# library for Cloudflare's DNS over HTTPS.
## Usage
This library provides an easy interface for interacting with Cloudflare's DNS over HTTPS endpoints.
DoH is a protocol that enhances the privacy and security of DNS queries by encrypting them using HTTPS. This helps prevent unauthorized access or tampering of DNS data during transmission. Learn more about it [here](https://developers.cloudflare.com/1.1.1.1/encryption/dns-over-https/).
To get started, import the library into your solution with either the `NuGet Package Manager` or the `dotnet` CLI.
```rust
dotnet add package DnsOverHttps
```
For the primary class to become available, import the used namespace.
```csharp
using DnsOverHttps;
```
Need more examples? Under the `Example` directory you can find a working demo project that implements this library.
## Properties
- Built for **.NET 8**, **.NET 7** and **.NET 6**
- Fully **async**
- Extensive **XML documentation**
- **No external dependencies** (makes use of built-in `HttpClient` and `JsonSerializer`)
- **Custom exceptions** (`DnsOverHttpsException`) for easy debugging
- Example project to demonstrate all capabilities of the library
## Features
- Resolve one or all DNS records under a hostname
- Ask for DNSSEC validation
- Query in parallel
- Specify advanced parameters
## Code Samples
### Initializing a new API client
```csharp
DnsOverHttpsClient dns = new();
```
### Resolving A DNS records including DNSSEC
```csharp
Response response = await dns.Resolve("discord.com", ResourceRecordType.A, true, true);
```
### Using helper methods to return the first or all answers
```csharp
Answer? nsAnswer = await dns.ResolveFirst("example.com", ResourceRecordType.NS);
Answer[] aAnswers = await dns.ResolveAll("reddit.com", ResourceRecordType.A);
```
## Resources
- Cloudflare: https://cloudflare.com
- 1.1.1.1: https://1.1.1.1
- Introduction: https://developers.cloudflare.com/1.1.1.1/encryption/dns-over-https
*This is a community-ran library. Not affiliated with Cloudflare, Inc.*
*Icon made by **Freepik** at [Flaticon](https://www.flaticon.com).*