## :globe_with_meridians:What is tcp-scan?
A very simplistic port scanner. Enter an IP, the ports to be scanned, a timeout time, and the open ports are returned in a list.
## :stars:Features
Simply scans ports for a given IP address and timeout value and returns whether they are open. Can scan an individual port, a list of ports, or a range of ports.
## :pencil:Setup
Include `tcp-scan` under `dependencies` in `cargo.toml`. When importing the module, use `tcp_scan`.
Each function call needs to end with `.await` and run inside of an async function.
To call a function within the `main()` function [tokio](https://github.com/tokio-rs/tokio) can be used as follows. In the `cargo.toml` file, include `tokio = { version = "1.38", features = ["macros"] }` under the `dependencies` section. Additionally, include `#[tokio::main]` immediately before the `main()` function and it will allow you to declare `main()` as `async`.
## :pencil:Usage
The following are example usage calls of the port scanning functions.
```rust
// Scan an individual port to check if it is open.
// A variable of the bool data type is returned - true for open and false for not.
let is_open: bool = scan_port("192.0.2.1", 135, 300).await;
// Scan an array of ports to check if any of them are open.
// A variable of the Vec<u16\> data type is returned which stores the list of open ports.
let open_ports: Vec<u16> = scan_ports_list("192.0.2.1", &[135,136,137,138,139,140], 400).await;
// Scan all ports in the range from 0 to 1000 (where 1000 is included).
// A Vec<u16\> is returned.
let all_open_ports: Vec<u16> = scan_ports_range("192.0.2.1", 0..=1000, 300).await;
// Scan every available port.
// A Vec<u16\> is returned.
let all_open_ports: Vec<u16> = scan_ports_range("192.0.2.1", 0..=65535, 300).await;
```
## :mag:Why use this library?
This library is meant to be used simply when one needs to know whether a singular port or number of ports are open or not. This library includes only the minimum amount of code for an implementation of this, nothing more.
If more information is needed on ports, it is recommended to use another more extensive library.
## :heart:Support
You can support me or my projects by donating to my bitcoin address: `bc1qfavx0pmkul0ekhywxr6xjvjdnzm7y344vhfjem`.