forked from metalbear-co/mirrord
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix port mapping (metalbear-co#2061)
* Fixed 'listen' detour * Added integration test * Added test build to CI * Added changelog entry * Fix existing tests * Format
- Loading branch information
Showing
6 changed files
with
73 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Fixed `port_mapping` feature. |
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,13 @@ | ||
use std::{net::TcpListener, io::Read}; | ||
|
||
const LISTEN_ON: &'static str = "0.0.0.0:9999"; | ||
const EXPECTED_MESSAGE: &'static [u8] = b"HELLO"; | ||
|
||
fn main() { | ||
let listener = TcpListener::bind(LISTEN_ON).unwrap(); | ||
let (mut stream, _peer) = listener.accept().unwrap(); | ||
|
||
let mut buff = [0_u8; 10]; | ||
let bytes_read = stream.read(&mut buff[..]).unwrap(); | ||
assert_eq!(&buff[..bytes_read], EXPECTED_MESSAGE); | ||
} |
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,34 @@ | ||
#![feature(assert_matches)] | ||
#![warn(clippy::indexing_slicing)] | ||
|
||
use std::{path::PathBuf, time::Duration}; | ||
|
||
use rstest::rstest; | ||
|
||
mod common; | ||
pub use common::*; | ||
|
||
#[rstest] | ||
#[tokio::test] | ||
#[timeout(Duration::from_secs(20))] | ||
async fn port_mapping( | ||
#[values(Application::RustIssue2058)] application: Application, | ||
dylib_path: &PathBuf, | ||
config_dir: &PathBuf, | ||
) { | ||
let (mut test_process, mut intproxy) = application | ||
.start_process_with_layer_and_port( | ||
dylib_path, | ||
vec![], | ||
Some(config_dir.join("port_mapping.json").to_str().unwrap()), | ||
) | ||
.await; | ||
|
||
println!("Application subscribed to port, sending data."); | ||
|
||
intproxy | ||
.send_connection_then_data("HELLO", application.get_app_port()) | ||
.await; | ||
|
||
test_process.wait_assert_success().await; | ||
} |