asphyxia/lib.rs
1//! Asphyxia - A fast and efficient network scanner
2//!
3//! This library provides high-performance network scanning capabilities for both port scanning
4//! and address scanning operations. It's designed to be efficient, reliable, and easy to use.
5//!
6//! ## Features
7//!
8//! - **Port Scanning**: Scan individual ports or ranges of ports on target hosts
9//! - **Address Scanning**: Check host availability and scan IP ranges
10//! - **Subnet Scanning**: Scan entire subnets for available hosts
11//! - **Utility Functions**: Helper functions for parsing ports, IPs, and subnets
12//!
13//! ## Module Organization
14//!
15//! - `scanner::port`: Port scanning functionality
16//! - `scanner::address`: Address and subnet scanning functionality
17//! - `utils`: Utility functions for parsing and validation
18//! - `cli`: Command-line interface implementation
19//!
20//! ## Examples
21//!
22//! ### Basic Port Scanning
23//! ```rust
24//! use asphyxia::{scan_port, scan_address};
25//!
26//! // Scan a single port
27//! if let Some(port) = scan_port("example.com".to_string(), 80) {
28//! println!("Port 80 is open");
29//! }
30//!
31//! // Scan multiple ports
32//! let ports = vec![80, 443, 8080];
33//! for port in ports {
34//! if let Some(_) = scan_port("example.com".to_string(), port) {
35//! println!("Port {} is open", port);
36//! }
37//! }
38//! ```
39//!
40//! ### Address and Subnet Scanning
41//! ```rust
42//! use asphyxia::{scan_address, scan_subnet, scan_ip_range};
43//! use std::net::Ipv4Addr;
44//! use std::time::Duration;
45//!
46//! // Check if a host is available
47//! let ip = "192.168.1.1".parse::<Ipv4Addr>().unwrap();
48//! let timeout = Duration::from_secs(1);
49//! if let Some(_) = scan_address(ip, Some(timeout)) {
50//! println!("Host is available");
51//! }
52//!
53//! // Scan a subnet
54//! let subnet = "192.168.1.0/24".parse().unwrap();
55//! let available_hosts = scan_subnet(subnet);
56//! println!("Found {} available hosts", available_hosts.len());
57//!
58//! // Scan an IP range
59//! let start = "192.168.1.1".parse::<Ipv4Addr>().unwrap();
60//! let end = "192.168.1.10".parse::<Ipv4Addr>().unwrap();
61//! let hosts = scan_ip_range(start, end);
62//! println!("Found {} hosts in range", hosts.len());
63//! ```
64//!
65//! ### Using Utility Functions
66//! ```rust
67//! use asphyxia::{parse_ports, parse_ipv4, parse_subnet};
68//!
69//! // Parse port ranges
70//! let ports = parse_ports("80,443,8000,8080").unwrap();
71//! println!("Ports to scan: {:?}", ports);
72//!
73//! // Parse IP address
74//! let ip = parse_ipv4("192.168.1.1").unwrap();
75//! println!("IP address: {}", ip);
76//!
77//! // Parse subnet
78//! let subnet = parse_subnet("192.168.1.0/24").unwrap();
79//! println!("Subnet: {}", subnet);
80//! ```
81//!
82//! ## Error Handling
83//!
84//! Most functions return `Option<T>` or `Result<T, E>` to handle potential errors
85//! gracefully. Always check the return values to ensure proper error handling.
86//!
87//! ## Performance Considerations
88//!
89//! The library is designed for performance and uses asynchronous operations where
90//! appropriate. For large-scale scanning operations, consider using the subnet
91//! scanning functions which are optimized for scanning multiple hosts.
92
93pub mod cli;
94pub mod scanner;
95pub mod utils;
96
97pub use scanner::address::{scan_address, scan_ip_range, scan_subnet};
98/// Re-export commonly used types and functions
99pub use scanner::port::{is_online, resolve_host, scan_port};
100pub use utils::{parse_ipv4, parse_ports, parse_subnet};