30 个稳定版本
1.6.0 | 2023 年 12 月 18 日 |
---|---|
1.5.2 | 2023 年 9 月 11 日 |
1.5.1 | 2022 年 11 月 4 日 |
1.5.0 | 2022 年 3 月 18 日 |
1.1.4 | 2018 年 11 月 14 日 |
#1 in #whois
每月下载量 676
用于 3 crates
29KB
579 行
WHOIS Rust
这是一个受 https://github.com/hjr265/node-whois 启发的 Rust WHOIS 客户端库。
用法
您可以创建一个 servers.json 文件或从 https://github.com/hjr265/node-whois 复制一个。
以下是 servers.json 的一个简单示例。
{
"org": "whois.pir.org",
"": "whois.ripe.net",
"_": {
"ip": {
"host": "whois.arin.net",
"query": "n + $addr\r\n"
}
}
}
然后,使用关联函数 from_path
(如果您的 JSON 数据在内存中,则使用 from_string
)来创建一个 WhoIs
实例。
use whois_rust::WhoIs;
let whois = WhoIs::from_path("/path/to/servers.json").unwrap();
使用 lookup
方法并输入一个 WhoIsLookupOptions
实例来查找域名或 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();
异步 API
您可能想使用与您的异步运行时一起使用的异步 API。此 crate 目前支持 tokio
。
[dependencies.whois-rust]
version = "*"
features = ["tokio"]
启用异步功能后,将提供 from_path_async
函数和 lookup_async
函数。
测试
# 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
文档
许可证
依赖项
~10–21MB
~298K SLoC