Crates.io | whois-rs |
lib.rs | whois-rs |
version | |
source | src |
created_at | 2024-12-16 13:33:03.14269 |
updated_at | 2024-12-16 13:33:03.14269 |
description | This is a WHOIS client library for Rust, inspired by https://github.com/hjr265/node-whois, forked from https://github.com/magiclen/whois-rust. |
homepage | |
repository | https://github.com/cycle-five/whois-rust |
max_upload_size | |
id | 1485000 |
Cargo.toml error: | TOML parse error at line 30, column 1 | 30 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
This is a WHOIS client library for Rust, inspired by https://github.com/hjr265/node-whois
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();
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.
# 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
https://crates.io/crates/whois-rust