#open-ports #ip-address #retrieve #async #ip-addr #vec #concurrency

oports

Async library to retrieve open ports for a given IP address

4 releases (1 stable)

1.0.0 Sep 7, 2020
0.2.1 Feb 15, 2020
0.2.0 Dec 24, 2019
0.1.1 Dec 24, 2019

#8 in #open-ports

Download history 11/week @ 2023-12-03 33/week @ 2023-12-10 8/week @ 2023-12-17 1/week @ 2023-12-24 27/week @ 2023-12-31 14/week @ 2024-01-07 5/week @ 2024-01-14 15/week @ 2024-01-21 16/week @ 2024-02-11 6/week @ 2024-02-18 32/week @ 2024-02-25 11/week @ 2024-03-03 53/week @ 2024-03-10 10/week @ 2024-03-17

108 downloads per month

MIT license

10KB
64 lines

oports

Rust library to asynchronously retrieve open ports for a given IP address

Install

Add oports as a dependency in the cargo.toml file of your project:

[dependencies]
oports = "1.0.0"

If you have cargo-edit utility tool installed, use:

$ cargo add oports

Interface

is_port_open(ip: IpAddr, port: u16) -> bool

Check if the given port is open for a specified IP address.

use oports;
use std::net::IpAddr;

let localhost = IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1));
let is_open = oports::is_port_open(localhost, 4040).await;

get_open_ports(ip: IpAddr, ports: Vec, concurrency: Option) -> Vec

Retrieves a vec with open ports for a given vec of port numbers an IP addresses. The default concurrency is 100 if the Option resolves to a None value.

use oports;
use std::net::IpAddr;

let localhost = IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1));
let ports = (8000..9090).collect::<Vec<u16>>();
let concurrency = Some(120)
let open_ports = oports::get_open_ports(localhost, ports, concurrency).await;

get_all_open_ports(ip: IpAddr, concurrency: Option) -> Vec

Retrieves a vec with all open ports for a given IP address. The default concurrency is 100 if the Option resolves to a None value.

use oports;
use std::net::IpAddr;

let localhost = IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1));
let ports = (8080..u16::max_value()).collect::<Vec<u16>>();
let concurrency = None // Default to 100
let all_open_ports = oports::get_all_open_ports(localhost, concurrency).await;

License

MIT License

Dependencies

~5–16MB
~190K SLoC