update: both the downstream POCs work, with the bogus downstream.
parent
0cb24695d0
commit
8d62b29319
|
@ -1662,6 +1662,7 @@ version = "0.1.0"
|
|||
dependencies = [
|
||||
"anyhow",
|
||||
"base64 0.12.3",
|
||||
"clap",
|
||||
"futures",
|
||||
"reqwest",
|
||||
"rmp-serde",
|
||||
|
|
|
@ -9,6 +9,7 @@ edition = "2018"
|
|||
[dependencies]
|
||||
anyhow = "1.0.34"
|
||||
base64 = "0.12.3"
|
||||
clap = "2.33.3"
|
||||
futures = "0.3.7"
|
||||
reqwest = { version = "0.10.8", features = ["stream"] }
|
||||
rmp-serde = "0.14.4"
|
||||
|
|
|
@ -1,16 +1,43 @@
|
|||
use clap::{App, SubCommand};
|
||||
use reqwest::Client;
|
||||
use tokio::{
|
||||
io::AsyncWriteExt,
|
||||
net::TcpStream,
|
||||
net::{
|
||||
TcpStream,
|
||||
TcpListener,
|
||||
},
|
||||
stream::StreamExt,
|
||||
};
|
||||
|
||||
#[tokio::main]
|
||||
async fn main () -> anyhow::Result <()> {
|
||||
let matches = App::new ("ptth_forwarding")
|
||||
.author ("Trish")
|
||||
.about ("Terminator for PTTH port forwarding")
|
||||
.subcommand (
|
||||
SubCommand::with_name ("server")
|
||||
.about ("Run this on the host with the TCP server")
|
||||
)
|
||||
.subcommand (
|
||||
SubCommand::with_name ("client")
|
||||
.about ("Run this on the host with the TCP client")
|
||||
)
|
||||
.get_matches ();
|
||||
|
||||
let client = Client::builder ()
|
||||
.build ()?;
|
||||
|
||||
let mut tcp_stream = TcpStream::connect ("127.0.0.1:4010").await?;
|
||||
let mut tcp_stream = if let Some (matches) = matches.subcommand_matches ("server") {
|
||||
TcpStream::connect ("127.0.0.1:4010").await?
|
||||
}
|
||||
else if let Some (matches) = matches.subcommand_matches ("client") {
|
||||
let mut listener = TcpListener::bind ("127.0.0.1:4020").await?;
|
||||
let (stream, _addr) = listener.accept ().await?;
|
||||
stream
|
||||
}
|
||||
else {
|
||||
panic! ("Must use server or client subcommand.");
|
||||
};
|
||||
|
||||
let resp = client.get ("http://127.0.0.1:4003/").send ().await?;
|
||||
let mut downstream = resp.bytes_stream ();
|
||||
|
|
Loading…
Reference in New Issue