| Crates.io | anynet |
| lib.rs | anynet |
| version | 1.0.2 |
| created_at | 2025-09-03 12:24:18.927825+00 |
| updated_at | 2025-09-03 12:24:18.927825+00 |
| description | A Rust crate for inspecting local network interfaces and reporting active server ports at startup. |
| homepage | |
| repository | https://github.com/canmi21/anynet |
| max_upload_size | |
| id | 1822448 |
| size | 54,563 |
A Rust crate for inspecting local network interfaces and reporting active server ports at startup.
anynet is a lightweight Rust crate designed to help developers inspect local network interfaces and report active server ports when a server starts. It provides a simple macro, anynet!, to log network information such as localhost, local network IPs, and optionally the public IP address. The crate is ideal for command-line utilities, network programming, and web development projects.
fancy-log crate for configurable log levels (Info, Debug, Warn, Error).anynet! macro for quick integration.Add anynet to your project by including it in your Cargo.toml:
[dependencies]
anynet = "1"
The anynet! macro can be used to log network information for a given port. It supports two modes:
use anynet::anynet;
fn main() {
anynet!(port = 8080);
}
use anynet::anynet;
fn main() {
anynet!(port = 8080, public = true);
}
Running the demo with LogLevel::Debug:
--- Running demo with public=false (default) ---
✓ Listening on http://localhost:8080
✓ Listening on http://192.168.1.100:8080
✓ Listening on http://10.0.0.2:8080 +1 more
➜ Listening on http://172.16.0.3:8080
--- Running demo with public=true ---
✓ Listening on http://localhost:3000
✓ Listening on http://192.168.1.100:3000
✓ Listening on http://10.0.0.2:3000 +1 more
• Possible Public Network: http://203.0.113.1:3000
➜ Listening on http://172.16.0.3:3000
--- Running demo with invalid port ---
✗ Invalid port number: 0. Port must be between 1 and 65535.
The crate includes a demo example located in examples/demo.rs. To run it:
cargo run --example demo
This example demonstrates both modes of the anynet! macro and different log levels.
fancy-log = "0.1": For styled logging output.get_if_addrs = "0.5": For retrieving local network interfaces.ip-lookup = "0.1": For fetching public IP addresses.This project is licensed under the MIT License. See the LICENSE file for details.
Contributions are welcome! Please open an issue or submit a pull request on the GitHub repository.
For questions or feedback, please open an issue on the GitHub repository.