#whois #domain #ip #lookup #async-api #github #server

whois-rust

This is a WHOIS client library for Rust, inspired by https://github.com/hjr265/node-whois

30 stable releases

1.6.0 Dec 18, 2023
1.5.2 Sep 11, 2023
1.5.1 Nov 4, 2022
1.5.0 Mar 18, 2022
1.1.4 Nov 14, 2018

#510 in Network programming

Download history 196/week @ 2024-07-04 216/week @ 2024-07-11 174/week @ 2024-07-18 187/week @ 2024-07-25 128/week @ 2024-08-01 222/week @ 2024-08-08 234/week @ 2024-08-15 149/week @ 2024-08-22 123/week @ 2024-08-29 212/week @ 2024-09-05 161/week @ 2024-09-12 172/week @ 2024-09-19 168/week @ 2024-09-26 122/week @ 2024-10-03 124/week @ 2024-10-10 152/week @ 2024-10-17

627 downloads per month
Used in 4 crates

MIT license

29KB
579 lines

WHOIS Rust

CI

This is a WHOIS client library for Rust, inspired by https://github.com/hjr265/node-whois

Usage

You can make a servers.json file or copy one from https://github.com/hjr265/node-whois

This is a simple example of servers.json.

{
    "org": "whois.pir.org",
    "": "whois.ripe.net",
    "_": {
        "ip": {
            "host": "whois.arin.net",
            "query": "n + $addr\r\n"
        }
    }
}

Then, use the from_path (or from_string if your JSON data is in-memory) associated function to create a WhoIs instance.

use whois_rust::WhoIs;

let whois = WhoIs::from_path("/path/to/servers.json").unwrap();

Use the lookup method and input a WhoIsLookupOptions instance to lookup a domain or an IP.

use whois_rust::{WhoIs, WhoIsLookupOptions};

let whois = WhoIs::from_path("/path/to/servers.json").unwrap();

let result: String = whois.lookup(WhoIsLookupOptions::from_string("magiclen.org").unwrap()).unwrap();

Asynchronous APIs

You may want to use async APIs with your async runtime. This crate supports tokio, currently.

[dependencies.whois-rust]
version = "*"
features = ["tokio"]

After enabling the async feature, the from_path_async function and the lookup_async function are available.

Testing

# git clone --recurse-submodules git://github.com/magiclen/whois-rust.git

git clone git://github.com/magiclen/whois-rust.git

cd whois-rust

git submodule init
git submodule update --recursive

cargo test

Crates.io

https://crates.io/crates/whois-rust

Documentation

https://docs.rs/whois-rust

License

MIT

Dependencies

~10–20MB
~284K SLoC