public async Task Query_EDNS()
        {
            var doh   = new DohClient();
            var query = new Message
            {
                RD        = true,
                Questions =
                {
                    new Question {
                        Name = "ipfs.io", Type = DnsType.TXT
                    }
                },
                AdditionalRecords =
                {
                    new OPTRecord
                    {
                        DO      = true,
                        Options =
                        {
                            new EdnsNSIDOption(),
                            new EdnsKeepaliveOption(),
                            new EdnsPaddingOption {
                                Padding = new byte[]{    0, 0, 0, 0 }
                            }
                        }
                    }
                }
            };
            var response = await doh.QueryAsync(query);

            Assert.IsNotNull(response);
            Assert.AreNotEqual(0, response.Answers.Count);
        }
        public void Resolve_Unknown()
        {
            var doh = new DohClient();

            ExceptionAssert.Throws <IOException>(() =>
            {
                var _ = doh.ResolveAsync("emanon.noname").Result;
            });
        }
        public async Task Resolve()
        {
            var doh       = new DohClient();
            var addresses = await doh.ResolveAsync("cloudflare-dns.com");

            Assert.AreNotEqual(0, addresses.Count());
            Assert.IsTrue(addresses.Any(a => a.AddressFamily == AddressFamily.InterNetwork));
            Assert.IsTrue(addresses.Any(a => a.AddressFamily == AddressFamily.InterNetworkV6));
        }
        public async Task Reverse()
        {
            var doh  = new DohClient();
            var name = await doh.ResolveAsync(IPAddress.Parse("1.1.1.1"));

            Assert.AreEqual("one.one.one.one", name);

            name = await doh.ResolveAsync(IPAddress.Parse("2606:4700:4700::1111"));

            Assert.AreEqual("one.one.one.one", name);
        }
        public async Task Resolve_Reverse()
        {
            var doh       = new DohClient();
            var github    = "github.com";
            var addresses = await doh.ResolveAsync(github);

            foreach (var address in addresses)
            {
                var name = await doh.ResolveAsync(address);

                StringAssert.EndsWith(name.ToString(), ".com");
            }
        }
        public async Task Query()
        {
            var doh   = new DohClient();
            var query = new Message {
                RD = true
            };

            query.Questions.Add(new Question {
                Name = "ipfs.io", Type = DnsType.TXT
            });
            var response = await doh.QueryAsync(query);

            Assert.IsNotNull(response);
            Assert.AreNotEqual(0, response.Answers.Count);
        }
        public void Query_UnknownName()
        {
            var doh   = new DohClient();
            var query = new Message {
                RD = true
            };

            query.Questions.Add(new Question {
                Name = "emanon.noname.google.com", Type = DnsType.A
            });
            ExceptionAssert.Throws <IOException>(() =>
            {
                var _ = doh.QueryAsync(query).Result;
            }, "DNS error 'NameError'.");
        }
 public void Query_UnknownName_NoThrow()
 {
     using (var doh = new DohClient {
         ThrowResponseError = false
     })
     {
         var query = new Message {
             RD = true
         };
         query.Questions.Add(new Question {
             Name = "emanon.noname.google.com", Type = DnsType.A
         });
         var result = doh.QueryAsync(query).Result;
         Assert.AreEqual(MessageStatus.NameError, result.Status);
     }
 }
        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());
            }
        }
示例#10
0
        public void Query_Timeout()
        {
            var doh = new DohClient
            {
                Timeout = TimeSpan.FromMilliseconds(1)
            };
            var query = new Message {
                RD = true
            };

            query.Questions.Add(new Question {
                Name = "ipfs-x.io", Type = DnsType.TXT
            });
            ExceptionAssert.Throws <TaskCanceledException>(() =>
            {
                var _ = doh.QueryAsync(query).Result;
            });
        }
示例#11
0
        public async Task Query_SecureEuServer()
        {
            var doh = new DohClient
            {
                ServerUrl = "https://doh.securedns.eu/dns-query"
            };
            var query = new Message {
                RD = true
            };

            query.Questions.Add(new Question {
                Name = "ipfs.io", Type = DnsType.TXT
            });
            var response = await doh.QueryAsync(query);

            Assert.IsNotNull(response);
            Assert.AreNotEqual(0, response.Answers.Count);
        }
示例#12
0
        public void Query_InvalidServer()
        {
            var doh = new DohClient
            {
                ServerUrl = "https://emanon.noname"
            };
            var query = new Message {
                RD = true
            };

            query.Questions.Add(new Question {
                Name = "emanon.noname.google.com", Type = DnsType.A
            });
            ExceptionAssert.Throws <Exception>(() =>
            {
                var _ = doh.QueryAsync(query).Result;
            });
        }
示例#13
0
        public async Task SecureQuery_Has_RRs()
        {
            var dns = new DohClient();
            var query = new Message {
                RD = true
            }.UseDnsSecurity();

            query.Questions.Add(new Question {
                Name = "cloudflare-dns.com", Type = DnsType.AAAA
            });
            var response = await dns.QueryAsync(query);

            Assert.IsNotNull(response);
            Assert.AreNotEqual(0, response.Answers.Count);

            var opt = response.AdditionalRecords.OfType <OPTRecord>().Single();

            Assert.AreEqual(true, opt.DO);

            var rrsig = response.Answers.OfType <RRSIGRecord>().Single();

            Assert.AreEqual(DnsType.AAAA, rrsig.TypeCovered);
        }
示例#14
0
        public void Server()
        {
            var doh = new DohClient();

            Assert.IsNotNull(doh.ServerUrl);
        }