# gscan
[](https://crates.io/crates/gscan)
[](https://opensource.org/licenses/MIT)
**gscan** is a lightweight, async-powered **network port scanning library** written in **Rust**.
It uses an internal asynchronous engine (powered by **Tokio**) to perform fast TCP port scans, while exposing a **simple, blocking API** suitable for small tools, scripts, and experiments.
---
## Features
- **Asynchronous core:** Uses Tokio to scan many ports concurrently
- **Simple API:** No `async`, `await`, or `#[tokio::main]` required by the caller
- **Bounded concurrency:** Prevents resource exhaustion during large scans
- **Timeout-based scanning:** Avoids hanging connections
- **Structured results:** Returns parsed IP addresses and sorted port lists
---
## Installation
Add this to your `Cargo.toml`:
```toml
[dependencies]
gscan = "0.1.5"
```
### Example: Scanning a Local Range
The library exposes a single public scanning function:
```rust
pub fn scan(ip: &str, port_start: u16, port_end: u16) -> ScanResult
```
`ScanResult` Structure
```rust
pub struct ScanResult {
pub ip: IpAddr,
pub ports: Vec<u16>,
}
```
Example: Scanning a Local Port Range
```rust
use gscan;
fn main() {
println!("Starting scan...");
let result = gscan::scan("127.0.0.1", 1, 1000);
println!("Scan complete for IP: {}", result.ip);
println!("Open ports found: {:?}", result.ports);
}
```
## License
Distributed under the **MIT License**.
---