-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from GyulyVGC/v0.2.0
v0.2.0
- Loading branch information
Showing
10 changed files
with
292 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "listeners" | ||
version = "0.1.0" | ||
version = "0.2.0" | ||
edition = "2021" | ||
authors = ["Giuliano Bellini <[email protected]>"] | ||
description = "Get processes listening on a TCP port in a cross-platform way" | ||
|
@@ -9,7 +9,7 @@ repository = "https://github.com/GyulyVGC/listeners" | |
license = "MIT" | ||
keywords = ["tcp", "listen", "port", "process"] | ||
categories = ["network-programming"] | ||
include = ["src/**/*", "LICENSE", "README.md", "CHANGELOG.md"] | ||
include = ["src/**/*", "LICENSE", "README.md", "CHANGELOG.md", "examples/**/*"] | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
use std::env::args; | ||
|
||
fn main() { | ||
let pid = args() | ||
.nth(1) | ||
.expect("Expected CLI argument: PID") | ||
.parse() | ||
.expect("PID must be an unsigned integer on at most 32 bits"); | ||
|
||
// Retrieve ports listened to by a process given its PID | ||
if let Ok(ports) = listeners::get_ports_by_pid(pid) { | ||
for p in ports { | ||
println!("{p}"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
use std::env::args; | ||
|
||
fn main() { | ||
let process_name = args().nth(1).expect("Expected CLI argument: process name"); | ||
|
||
// Retrieve ports listened to by a process given its name | ||
if let Ok(ports) = listeners::get_ports_by_process_name(&process_name) { | ||
for p in ports { | ||
println!("{p}"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
use std::env::args; | ||
|
||
fn main() { | ||
let port = args() | ||
.nth(1) | ||
.expect("Expected CLI argument: port") | ||
.parse() | ||
.expect("Port must be an unsigned integer on at most 16 bits"); | ||
|
||
// Retrieve PID and name of processes listening on a given port | ||
if let Ok(processes) = listeners::get_processes_by_port(port) { | ||
for p in processes { | ||
println!("{p}"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.