Example #1
0
        public void BkTests(string hostnameOrIp)
        {
            var result = new WhoisLookup().Lookup(hostnameOrIp);

            Console.WriteLine($"Host: {hostnameOrIp}\r\nOrg: {result.Registrant?.Organization}\r\nDomain: {result.Domain}\r\nPatternFile: {result.PatternFile}\r\n\r\n{result.Text}");

            Assert.AreNotEqual(null, result.Registrant?.Organization);
        }
Example #2
0
        public void TestConfiguration()
        {
            // Global configuration
            WhoisOptions.Defaults.Encoding = Encoding.UTF8;

            // Per-instance configuration
            var lookup = new WhoisLookup();

            lookup.Options.TimeoutSeconds = 30;
        }
Example #3
0
        public void TestParsing()
        {
            var lookup = new WhoisLookup();

            // Clear the embedded templates (not recommended)
            lookup.Parser.ClearTemplates();

            // Add a custom WHOIS response parsing template
            lookup.Parser.AddTemplate("Domain: { DomainName$ }", "Simple Pattern");
        }
Example #4
0
        public void TestBasicLookup()
        {
            // Create a WhoisLookup instance
            var whois = new WhoisLookup();

            // Query github.com
            var response = whois.Lookup("github.com");

            // Output the response
            Console.WriteLine(response.Content);
        }
Example #5
0
        public async Task TestAsyncLookup()
        {
            // Create a WhoisLookup instance
            var whois = new WhoisLookup();

            // Query github.com
            var response = await whois.LookupAsync("github.com");

            // Output the response
            Console.WriteLine(response.Content);
        }
Example #6
0
        public void SetUp()
        {
            whoisServerLookup = new Mock <IWhoisServerLookup>();
            tcpReader         = new Mock <ITcpReader>();
            sampleReader      = new SampleReader();

            lookup = new WhoisLookup
            {
                TcpReader    = tcpReader.Object,
                ServerLookup = whoisServerLookup.Object
            };
        }
Example #7
0
        public void TestCustomNetworking()
        {
            // Create a WhoisLookup instance
            var lookup = new WhoisLookup();

            // Assign the custom TcpReader
            lookup.TcpReader = new MyCustomTcpReader();

            // Lookups will now use the custom TcpReader
            var response = lookup.Lookup("github.com");

            Console.WriteLine(response.Content);
        }
Example #8
0
        public void TestParsedLookup()
        {
            // Create a WhoisLookup instance
            var whois = new WhoisLookup();

            // Query github.com
            var response = whois.Lookup("github.com");

            // Convert the response to JSON
            var json = JsonConvert.SerializeObject(response, Formatting.Indented);

            // Output the json
            Console.WriteLine(json);
        }
Example #9
0
        private static async Task Run(Options options)
        {
            var lookup = new WhoisLookup();

            var result = await lookup.LookupAsync(options.Query);

            if (options.ConvertToJson)
            {
                result.Content = null;

                var json = JsonConvert.SerializeObject(result, Formatting.Indented);

                Console.WriteLine(json);
            }
            else
            {
                Console.WriteLine(result.Content);
            }

            lookup.Dispose();
        }
Example #10
0
 public void SetUp()
 {
     lookup = new WhoisLookup();
 }
Example #11
0
        public void SetUp()
        {
            lookup = new WhoisLookup();

            lookup.Visitors.Clear();
        }
Example #12
0
 public void SetUp()
 {
     lookup = new WhoisLookup();
 }
Example #13
0
        public void SetUp()
        {
            lookup = new WhoisLookup();

            lookup.Visitors.Clear();
        }
Example #14
0
 private void whoIsToolStripMenuItem_Click(object sender, EventArgs e)
 {
     Uri url = new Uri(uiTabbedBrowserControl.CurrentTab.Browser.URL);
     try
     {
         string host = url.Host;
         if (!(host.EndsWith(".com") || host.EndsWith(".net")))
         {
             if (host.StartsWith("www."))
                 host = host.Remove(0, 4);
         }
         var whois = new WhoisLookup().Lookup(host);
         var view = new ViewPageSource(whois.ToString(), Enums.Actions.Whois, new Tuple<string, string, string>(url.Host, host, ""));
         view.Show();
     }
     catch
     {
         MessageBox.Show("Unable to obtain Whois? information for this website.", "Error obtaining Whois?", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
 }