Last active
March 6, 2021 19:08
-
-
Save protectroot-com/22e1ae7f31b5c7a77e8c77c0efd2708f to your computer and use it in GitHub Desktop.
C# .net core 5.0 DOH query
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using Makaretu.Dns; | |
// add the Makaretu.Dns.Unicast Nuget package. | |
namespace testing123 | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
//add the Makaretu.Dns.Unicast Nuget package. | |
Console.WriteLine("starting.."); | |
var result = yeet(); | |
//it works! | |
} | |
public static async System.Threading.Tasks.Task yeet () | |
{ | |
var dns = new Makaretu.Dns.DohClient(); | |
//pick your doh url ---> github.com/curl/curl/wiki/DNS-over-HTTPS | |
//using xfinity as dns over https server. | |
dns.ServerUrl = "https://doh.xfinity.com/dns-query"; | |
//query for twitter IP | |
var response = dns.QueryAsync("twitter.com", DnsType.A); | |
Console.WriteLine(response.Result.Answers.Count); | |
foreach (var item in response.Result.Answers) | |
{ | |
Console.WriteLine(item.ToString()); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment