Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/magiclen/whois-rust
This is a WHOIS client library for Rust, inspired by https://github.com/hjr265/node-whois
https://github.com/magiclen/whois-rust
rust whois
Last synced: 5 days ago
JSON representation
This is a WHOIS client library for Rust, inspired by https://github.com/hjr265/node-whois
- Host: GitHub
- URL: https://github.com/magiclen/whois-rust
- Owner: magiclen
- License: mit
- Created: 2018-10-29T09:02:12.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2024-08-20T08:35:59.000Z (4 months ago)
- Last Synced: 2024-11-24T15:13:00.206Z (28 days ago)
- Topics: rust, whois
- Language: Rust
- Homepage:
- Size: 51.8 KB
- Stars: 22
- Watchers: 3
- Forks: 10
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
WHOIS Rust
====================[![CI](https://github.com/magiclen/whois-rust/actions/workflows/ci.yml/badge.svg)](https://github.com/magiclen/whois-rust/actions/workflows/ci.yml)
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**.
```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.
```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.
```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.
```toml
[dependencies.whois-rust]
version = "*"
features = ["tokio"]
```After enabling the async feature, the `from_path_async` function and the `lookup_async` function are available.
## Testing
```bash
# git clone --recurse-submodules git://github.com/magiclen/whois-rust.gitgit clone git://github.com/magiclen/whois-rust.git
cd whois-rust
git submodule init
git submodule update --recursivecargo test
```## Crates.io
https://crates.io/crates/whois-rust
## Documentation
https://docs.rs/whois-rust
## License
[MIT](LICENSE)