✅ this version was able to forward VNC over LAN.
But I can't run it on my server because it's built with a really new libc. uuugggghhhhmain
parent
57091ddaab
commit
fa8f02999c
|
@ -319,12 +319,6 @@ version = "0.3.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10"
|
checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "drop_guard"
|
|
||||||
version = "0.2.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "78bb5d73478dbcb7c404cd86336e90c67425497ca94b6f7352c8ea7deb9098e2"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "either"
|
name = "either"
|
||||||
version = "1.6.1"
|
version = "1.6.1"
|
||||||
|
@ -1357,10 +1351,10 @@ name = "quic_demo"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"drop_guard",
|
|
||||||
"futures-util",
|
"futures-util",
|
||||||
"quinn",
|
"quinn",
|
||||||
"rcgen",
|
"rcgen",
|
||||||
|
"structopt",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tracing",
|
"tracing",
|
||||||
"tracing-subscriber",
|
"tracing-subscriber",
|
||||||
|
|
|
@ -8,10 +8,10 @@ edition = "2018"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow = "1.0.38"
|
anyhow = "1.0.38"
|
||||||
drop_guard = "0.2.1"
|
|
||||||
futures-util = "0.3.9"
|
futures-util = "0.3.9"
|
||||||
quinn = "0.7.2"
|
quinn = "0.7.2"
|
||||||
rcgen = "0.8.11"
|
rcgen = "0.8.11"
|
||||||
|
structopt = "0.3.20"
|
||||||
tokio = { version = "1.4.0", features = ["full"] }
|
tokio = { version = "1.4.0", features = ["full"] }
|
||||||
tracing-subscriber = "0.2.16"
|
tracing-subscriber = "0.2.16"
|
||||||
tracing = "0.1.25"
|
tracing = "0.1.25"
|
||||||
|
|
|
@ -1,15 +1,29 @@
|
||||||
use tokio::{
|
use structopt::StructOpt;
|
||||||
net::TcpListener,
|
use tokio::net::TcpListener;
|
||||||
};
|
|
||||||
|
|
||||||
use quic_demo::prelude::*;
|
use quic_demo::prelude::*;
|
||||||
|
|
||||||
|
#[derive (Debug, StructOpt)]
|
||||||
|
struct Opt {
|
||||||
|
#[structopt (long)]
|
||||||
|
relay_addr: Option <String>,
|
||||||
|
#[structopt (long)]
|
||||||
|
local_tcp_port: Option <u16>,
|
||||||
|
#[structopt (long)]
|
||||||
|
client_id: Option <u8>,
|
||||||
|
#[structopt (long)]
|
||||||
|
server_id: Option <u8>,
|
||||||
|
}
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main () -> anyhow::Result <()> {
|
async fn main () -> anyhow::Result <()> {
|
||||||
tracing_subscriber::fmt::init ();
|
tracing_subscriber::fmt::init ();
|
||||||
|
|
||||||
|
let opt = Opt::from_args ();
|
||||||
|
let local_tcp_port = opt.local_tcp_port.unwrap_or (30381);
|
||||||
|
|
||||||
let server_cert = tokio::fs::read ("quic_server.crt").await?;
|
let server_cert = tokio::fs::read ("quic_server.crt").await?;
|
||||||
let server_addr = "127.0.0.1:30380".parse ()?;
|
let relay_addr = opt.relay_addr.unwrap_or_else (|| String::from ("127.0.0.1:30380")).parse ()?;
|
||||||
let endpoint = make_client_endpoint ("0.0.0.0:0".parse ()?, &[&server_cert])?;
|
let endpoint = make_client_endpoint ("0.0.0.0:0".parse ()?, &[&server_cert])?;
|
||||||
|
|
||||||
trace! ("Connecting to relay server");
|
trace! ("Connecting to relay server");
|
||||||
|
@ -17,15 +31,16 @@ async fn main () -> anyhow::Result <()> {
|
||||||
let quinn::NewConnection {
|
let quinn::NewConnection {
|
||||||
connection,
|
connection,
|
||||||
..
|
..
|
||||||
} = endpoint.connect (&server_addr, "localhost")?.await?;
|
} = endpoint.connect (&relay_addr, "localhost")?.await?;
|
||||||
|
|
||||||
let (mut send, mut recv) = connection.open_bi ().await?;
|
let (mut send, mut recv) = connection.open_bi ().await?;
|
||||||
|
|
||||||
let our_id = 42;
|
let client_id = opt.client_id.unwrap_or (42);
|
||||||
|
let server_id = opt.server_id.unwrap_or (43);
|
||||||
|
|
||||||
let req_buf = [
|
let req_buf = [
|
||||||
Command::CONNECT_P2_TO_P3.0,
|
Command::CONNECT_P2_TO_P3.0,
|
||||||
our_id,
|
client_id,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
];
|
];
|
||||||
|
@ -40,7 +55,7 @@ async fn main () -> anyhow::Result <()> {
|
||||||
0,
|
0,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
let listener = TcpListener::bind ("127.0.0.1:30381").await?;
|
let listener = TcpListener::bind (("127.0.0.1", local_tcp_port)).await?;
|
||||||
|
|
||||||
trace! ("Accepting local TCP connections from P1");
|
trace! ("Accepting local TCP connections from P1");
|
||||||
|
|
||||||
|
@ -57,7 +72,6 @@ async fn main () -> anyhow::Result <()> {
|
||||||
|
|
||||||
// Ask P3 if we can connect to P4
|
// Ask P3 if we can connect to P4
|
||||||
|
|
||||||
let server_id = 43;
|
|
||||||
let req_buf = [
|
let req_buf = [
|
||||||
Command::CONNECT_P2_TO_P4.0,
|
Command::CONNECT_P2_TO_P4.0,
|
||||||
server_id,
|
server_id,
|
||||||
|
|
|
@ -1,13 +1,27 @@
|
||||||
|
use structopt::StructOpt;
|
||||||
use tokio::net::TcpStream;
|
use tokio::net::TcpStream;
|
||||||
|
|
||||||
use quic_demo::prelude::*;
|
use quic_demo::prelude::*;
|
||||||
|
|
||||||
|
#[derive (Debug, StructOpt)]
|
||||||
|
struct Opt {
|
||||||
|
#[structopt (long)]
|
||||||
|
relay_addr: Option <String>,
|
||||||
|
#[structopt (long)]
|
||||||
|
local_tcp_port: Option <u16>,
|
||||||
|
#[structopt (long)]
|
||||||
|
server_id: Option <u8>,
|
||||||
|
}
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main () -> anyhow::Result <()> {
|
async fn main () -> anyhow::Result <()> {
|
||||||
tracing_subscriber::fmt::init ();
|
tracing_subscriber::fmt::init ();
|
||||||
|
|
||||||
|
let opt = Opt::from_args ();
|
||||||
|
let local_tcp_port = opt.local_tcp_port.unwrap_or (30382);
|
||||||
|
|
||||||
let server_cert = tokio::fs::read ("quic_server.crt").await?;
|
let server_cert = tokio::fs::read ("quic_server.crt").await?;
|
||||||
let server_addr = "127.0.0.1:30380".parse ()?;
|
let relay_addr = opt.relay_addr.unwrap_or_else (|| String::from ("127.0.0.1:30380")).parse ()?;
|
||||||
let endpoint = make_client_endpoint ("0.0.0.0:0".parse ()?, &[&server_cert])?;
|
let endpoint = make_client_endpoint ("0.0.0.0:0".parse ()?, &[&server_cert])?;
|
||||||
|
|
||||||
trace! ("Connecting to relay server");
|
trace! ("Connecting to relay server");
|
||||||
|
@ -16,11 +30,11 @@ async fn main () -> anyhow::Result <()> {
|
||||||
connection,
|
connection,
|
||||||
mut bi_streams,
|
mut bi_streams,
|
||||||
..
|
..
|
||||||
} = endpoint.connect (&server_addr, "localhost")?.await?;
|
} = endpoint.connect (&relay_addr, "localhost")?.await?;
|
||||||
|
|
||||||
let (mut send, mut recv) = connection.open_bi ().await?;
|
let (mut send, mut recv) = connection.open_bi ().await?;
|
||||||
|
|
||||||
let our_id = 43;
|
let our_id = opt.server_id.unwrap_or (43);
|
||||||
let req_buf = [
|
let req_buf = [
|
||||||
Command::CONNECT_P4_TO_P3.0,
|
Command::CONNECT_P4_TO_P3.0,
|
||||||
our_id,
|
our_id,
|
||||||
|
@ -74,7 +88,7 @@ async fn main () -> anyhow::Result <()> {
|
||||||
|
|
||||||
debug! ("Started PTTH connection");
|
debug! ("Started PTTH connection");
|
||||||
|
|
||||||
let stream = TcpStream::connect ("127.0.0.1:30382").await?;
|
let stream = TcpStream::connect (("127.0.0.1", local_tcp_port)).await?;
|
||||||
let (local_recv, local_send) = stream.into_split ();
|
let (local_recv, local_send) = stream.into_split ();
|
||||||
|
|
||||||
trace! ("Relaying bytes...");
|
trace! ("Relaying bytes...");
|
||||||
|
|
|
@ -1,11 +1,21 @@
|
||||||
|
use structopt::StructOpt;
|
||||||
|
|
||||||
use quic_demo::prelude::*;
|
use quic_demo::prelude::*;
|
||||||
|
|
||||||
|
#[derive (Debug, StructOpt)]
|
||||||
|
struct Opt {
|
||||||
|
#[structopt (long)]
|
||||||
|
listen_addr: Option <String>,
|
||||||
|
}
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main () -> anyhow::Result <()> {
|
async fn main () -> anyhow::Result <()> {
|
||||||
tracing_subscriber::fmt::init ();
|
tracing_subscriber::fmt::init ();
|
||||||
|
|
||||||
let server_addr = "0.0.0.0:30380".parse ()?;
|
let opt = Opt::from_args ();
|
||||||
let (mut incoming, server_cert) = make_server_endpoint (server_addr)?;
|
|
||||||
|
let listen_addr = opt.listen_addr.unwrap_or_else (|| String::from ("0.0.0.0:30380")).parse ()?;
|
||||||
|
let (mut incoming, server_cert) = make_server_endpoint (listen_addr)?;
|
||||||
tokio::fs::write ("quic_server.crt", &server_cert).await?;
|
tokio::fs::write ("quic_server.crt", &server_cert).await?;
|
||||||
|
|
||||||
let relay_state = RelayState::default ();
|
let relay_state = RelayState::default ();
|
||||||
|
|
Loading…
Reference in New Issue