A Rust crate for cross-platform network libraries and utilities. The goal is to build a comprehensive collection of network tools, libraries, and helpers — all under one dependency.
[dependencies]
netru = "0.1"Disable the utils feature to drop the iptools dependency:
netru = { version = "0.1", default-features = false }All types are available directly at the crate root:
use netru::{Sysproxy, Autoproxy};Useful for building bypass lists. Requires the utils feature (on by default).
use netru::utils::ipv4_cidr_to_wildcard;
let w = ipv4_cidr_to_wildcard("192.168.1.0/24")?; // ["192.168.1.*"]
let w = ipv4_cidr_to_wildcard("10.0.0.0/8")?; // ["10.*"]| Module | Description | Docs |
|---|---|---|
sysproxy |
OS system proxy get/set (HTTP, HTTPS, SOCKS, PAC) | src/sysproxy/README.md |
| Binary | Description | Usage |
|---|---|---|
proxy_ctl |
Toggle system proxy on/off from the command line | cargo run --bin proxy_ctl -- --enable 127.0.0.1:7890 |
# Enable system proxy
cargo run --bin proxy_ctl -- --enable 127.0.0.1:7890
# Disable system proxy
cargo run --bin proxy_ctl -- --disable
# Check current state
cargo run --bin proxy_ctl -- --check| Feature | Default | Description |
|---|---|---|
utils |
✅ | CIDR/IP utility helpers (pulls in iptools) |
- Rust 1.80+
- macOS:
networksetup(built-in) - Linux:
gsettings(GNOME) orkreadconfig5/kreadconfig6(KDE) - Windows: no extra dependencies
cargo build
cargo build --release# Run all tests
cargo test
# Run only unit tests — safe, does not touch system proxy settings
cargo test utils
# Run integration tests — temporarily modifies your system proxy
cargo test -- --test-threads=1
test_system_enableandtest_auto_enablemodify your system proxy settings during the test and restore a disabled state when complete. They are serialized withserial_testto avoid races.
cargo fmt
cargo clippy1. Check the package is valid:
cargo package --list # preview files included in the published crate
cargo publish --dry-run2. Login to crates.io (one-time):
cargo login
# paste your API token from https://crates.io/settings/tokens3. Bump the version in Cargo.toml, then publish:
cargo publishnetru/
├── Cargo.toml
├── README.md
├── src/
│ ├── lib.rs # Flat re-exports (pub use sysproxy::*)
│ ├── bin/
│ │ └── proxy_ctl.rs # CLI tool for toggling system proxy
│ └── sysproxy/
│ ├── README.md # Sysproxy module docs
│ ├── mod.rs # Types, Error, Result
│ ├── macos.rs
│ ├── windows.rs
│ ├── linux.rs
│ └── utils.rs
└── tests/
└── test.rs
Internal modules live under src/<module>/ but are never exposed as nested paths — everything is re-exported flat at netru::*. When a new module grows too many types, it gets its own subdirectory following the same pattern.
| Type | Description | Status |
|---|---|---|
Sysproxy / Autoproxy |
OS system proxy get/set | ✅ Stable |
NetInfo |
Network interface enumeration and stats | Planned |
DnsResolver |
Async DNS resolver with caching | Planned |
PortScanner |
TCP/UDP port scanner | Planned |
ProxyChecker |
Proxy health checker (latency, anonymity) | Planned |
PacFile |
PAC file parser and evaluator | Planned |
NetMonitor |
Real-time bandwidth and connection monitor | Planned |
Traceroute |
Cross-platform traceroute | Planned |
HttpProbe |
HTTP connectivity prober | Planned |
To add a new module:
- Create
src/<module>/mod.rswith its types and logic - Add platform-specific files as
src/<module>/<platform>.rsif needed - Re-export the public types in
src/lib.rs - Add an entry to the Roadmap table above
- Gate heavy dependencies behind an optional feature flag
MIT