Code Monkey home page Code Monkey logo

whoischecker's Introduction

WhoIsChecker Library

WhoIsChecker is a .NET library for checking the expiration date of domains using WHOIS servers. This library supports multiple target frameworks including .NET Standard 2.1, .NET 6.0, and .NET 7.0.

Features

  • Query WHOIS information for domains.
  • Extract and convert the domain expiration date to local system time.
  • Calculate the number of days until a domain expires.
  • Automatically download and use the latest WHOIS server list.

Getting Started

Installation

To install WhoIsChecker, add the NuGet package to your project:

dotnet add package WhoIsChecker

Usage

Here's an example of how to use the WhoIsChecker library:

  1. Load WHOIS Servers: Load the WHOIS servers list from a JSON file or download it if it doesn't exist or is outdated.

  2. Query WHOIS Server: Query the WHOIS server for a domain's expiration date.

    using System;
    using System.Threading.Tasks;
    using WhoIsChecker.Data;
    using WhoIsChecker.Services;
    
    class Program
    {
        static async Task Main(string[] args)
        {
            if (args.Length == 0)
            {
                Console.WriteLine("Please provide a domain as an argument.");
                return;
            }
    
            string domain = args[0];
            string tld = GetTld(domain);
    
            var whoisServers = await DomainWhoisServers.LoadAsync();
    
            if (whoisServers.TryGetValue(tld, out string? whoisServer))
            {
                if (whoisServer == null)
                {
                    Console.WriteLine("NO WHOIS SERVER FOUND");
                }
                else
                {
                    var whoisService = new WhoisService();
                    var (expirationDate, message) = await whoisService.QueryWhoisServer(domain, whoisServer);
                    if (expirationDate != null)
                    {
                        Console.WriteLine($"Expiration Date (Local Time): {expirationDate}");
                    }
                    Console.WriteLine(message);
                }
            }
            else
            {
                Console.WriteLine("TLD not found in the list.");
            }
        }
    
        private static string GetTld(string domain)
        {
            var parts = domain.Split('.');
            return parts[^1].ToLower();
        }
    }

Building the Library

To build the library, navigate to the project directory and run the following command:

dotnet build --configuration Release

Packaging the Library

To create a NuGet package, use the following command:

dotnet pack --configuration Release

This will generate a .nupkg file in the bin/Release directory.

Publishing the Library

To publish the NuGet package, use the following command:

dotnet nuget push bin/Release/WhoIsChecker.1.0.0.nupkg --api-key YOUR_API_KEY --source https://api.nuget.org/v3/index.json

Replace YOUR_API_KEY wityh your actual NuGet API key.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Contributing

Contributions are welcome! Please open an issue or submit a pull request on GitHub.

Acknowledgements

Special thanks to all the contributors and open-source projects that made this library possible.

Contact

For more information, please visit the project page.

whoischecker's People

Contributors

onenoteperpage avatar danijeljw avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.