Skip to content

supercoolspy/whois-that

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

whois-that

Crates.io Documentation MIT License

whois-that is a fast, asynchronous WHOIS client library for Rust using tokio. It provides comprehensive domain information lookups with support for international domains, custom server lists, and various character encodings.

Features

  • Async by default - Built on Tokio for non-blocking network operations
  • International Domain Support - Handles IDNs via IDNA Punycode conversion
  • Multiple Character Encodings - Support for non-UTF8 responses (Windows-1252)
  • Configurable Server Lists - Use default or custom WHOIS server configurations
  • Efficient Domain Suffix Lookup - Fast TLD and domain lookups
  • Minimal Dependencies - Feature flags let you include only what you need

Installation

Add this to your Cargo.toml:

[dependencies]
whois-that = "0.1"
tokio = { version = "1", features = ["full"] }

Feature Flags

The library uses feature flags to provide flexibility:

Flag Description Default
serde Enable serde support for loading server lists from files/JSON data
idna Enable IDNA support for international domain names
decode-global Enable Windows-1252 character encoding support

To use only specific features:

[dependencies]
whois-that = { version = "0.1", default-features = false, features = ["serde", "idna"] }

Usage

Basic Usage

use whois_that::whois::Whois;
use whois_that::builder::WhoisBuilder;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Create a default whois client with built-in server list
    let whois = WhoisBuilder::default().build()?;
    
    // Look up WHOIS data for a domain
    let whois_data = whois.whois_lookup("google.com").await?;
    
    println!("{}", whois_data);
    
    Ok(())
}

Custom Server List

You can provide your own WHOIS server list as a JSON file:

use whois_that::whois::Whois;
use whois_that::builder::WhoisBuilder;
use std::path::Path;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Create a whois client with a custom server list
    let whois = WhoisBuilder::default()
        .with_server_path(Path::new("path/to/custom_servers.json"))
        .build()?;
    
    // Look up WHOIS data for a domain
    let whois_data = whois.whois_lookup("example.com").await?;
    
    println!("{}", whois_data);
    
    Ok(())
}

International Domain Names

When the idna feature is enabled (on by default), you can lookup international domain names:

use whois_that::whois::Whois;
use whois_that::builder::WhoisBuilder;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let whois = WhoisBuilder::default().build()?;
    
    // Look up WHOIS data for an IDN domain
    let whois_data = whois.whois_lookup("例子.网址").await?;
    println!("{}", whois_data);
    
    Ok(())
}

Server List Format

Custom server lists should be JSON files in the following formats:

{
  // Standard format
  "io": "whois.nic.io",
  // Detailed format
  "net": {
    "host": "whois.verisign-grs.com",
    "query": "DOMAIN $addr\r\n",
    "punycode": true
  },
}

Contributing

Contributions are welcome!

Acknowledgments

About

A feature full whois client library with support for non-UTF8 responses

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages