Skip to content

Commit

Permalink
Dump routing table for unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
shutton committed Mar 7, 2024
1 parent 3a4be5f commit 7cad127
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ mod routing_table;

use std::fmt::Write;

pub use routing_table::execute_netstat;

// Exports
pub use route_entry::RouteEntry;
pub use routing_flag::RoutingFlag;
Expand Down
5 changes: 3 additions & 2 deletions src/routing_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl RoutingTable {
/// Returns an error if the `netstat` command fails to execute, or returns
/// unparseable output.
pub async fn load_from_netstat() -> Result<Self, Error> {
let output = query_netstat_routing_table().await?;
let output = execute_netstat().await?;
Self::from_netstat_output(&output)
}

Expand Down Expand Up @@ -122,7 +122,8 @@ impl RoutingTable {
}
}

async fn query_netstat_routing_table() -> Result<String, Error> {
/// Execute `netstat -rn` and return the output
pub async fn execute_netstat() -> Result<String, Error> {
let output = Command::new(NETSTAT_PATH)
.arg("-rn")
.stdin(std::process::Stdio::null())
Expand Down

0 comments on commit 7cad127

Please sign in to comment.