-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
54 lines (45 loc) · 1.49 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
using Ae.Dns.Client;
using Ae.Dns.Protocol;
using static System.Console;
var proxydomain = "https://REPLACE_ME.workers.dev/";
var testCount = 400;
string[] oisdbig;
using (HttpClient client = new HttpClient())
{
oisdbig = client.GetStringAsync(
"https://raw.githubusercontent.com/sjhgvr/oisd/main/domainswild_big.txt").Result
.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None)
.Where(x=>x.StartsWith("*"))
.Select(x=>x.Substring(2)).ToArray();
}
using var httpClient = new HttpClient { BaseAddress = new Uri(proxydomain) };
using var dnsClient = new DnsHttpClient(httpClient);
var failCount = 0;
string domain = "";
for (int i = 0; i < testCount; i++)
{
try
{
domain = oisdbig[Random.Shared.Next(oisdbig.Length)];
var query = DnsQueryFactory.CreateQuery(domain);
var answers = dnsClient.Query(query, CancellationToken.None).Result.Answers;
var result = ((Ae.Dns.Protocol.Records.DnsDomainResource)answers.First(x=>x.Type==Ae.Dns.Protocol.Enums.DnsQueryType.CNAME).Resource).Domain;
if (result != "blockpage.nextdns.io")
{
throw new Exception("Invalid result");
}
}
catch (Exception ex)
{
WriteLine($"Failure on {domain} due to {ex.Message}");
failCount++;
}
}
if (failCount==0)
{
WriteLine($"All {testCount} succeeded");
}
else
{
WriteLine($"{failCount} failure out of {testCount}");
}