26 stable releases

1.4.0 Oct 23, 2021
1.3.2 May 4, 2021
1.2.4 Mar 11, 2021
1.2.3 Jul 29, 2020
1.1.4 Nov 14, 2018

#15 in WebSocket

Download history 54/week @ 2021-08-11 22/week @ 2021-08-18 21/week @ 2021-08-25 4/week @ 2021-09-01 16/week @ 2021-09-08 46/week @ 2021-09-15 13/week @ 2021-09-22 27/week @ 2021-09-29 7/week @ 2021-10-06 57/week @ 2021-10-13 27/week @ 2021-10-20 15/week @ 2021-10-27 44/week @ 2021-11-03 16/week @ 2021-11-17 14/week @ 2021-11-24

74 downloads per month
Used in 3 crates

MIT license

28KB
581 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.

extern crate whois_rust;

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.

extern crate whois_rust;

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

git submodule init
git submodule update --recursive

cd whois-rust

cargo test

Crates.io

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

Documentation

https://docs.rs/whois-rust

License

MIT

Dependencies

~13MB
~267K SLoC