making a GUI for the client proxy
parent
2a58d86b5c
commit
79967fbf3f
|
@ -342,9 +342,9 @@ checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed"
|
|||
|
||||
[[package]]
|
||||
name = "fltk"
|
||||
version = "1.1.0"
|
||||
version = "1.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3fd9596a1677232504499345ad56fbad899093cd281eaf371d41941c638dc753"
|
||||
checksum = "1d364803b740d10140734eaa925af4ff4b3826e2bad29b18e477aeac3fdf016c"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"fltk-derive",
|
||||
|
@ -366,9 +366,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "fltk-sys"
|
||||
version = "1.1.0"
|
||||
version = "1.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b4d8037f9cea0c3ce53fe91c9b73950b559ae58c987647127450bae539014ca0"
|
||||
checksum = "158abaf04e1d5cdc08bb75cd3683e03be6f6b6e2fa3a0124e1a596c436417bcb"
|
||||
dependencies = [
|
||||
"cmake",
|
||||
"libc",
|
||||
|
@ -1313,6 +1313,7 @@ version = "0.1.0"
|
|||
dependencies = [
|
||||
"anyhow",
|
||||
"base64",
|
||||
"fltk",
|
||||
"futures-util",
|
||||
"quinn",
|
||||
"rcgen",
|
||||
|
|
|
@ -10,6 +10,7 @@ license = "AGPL-3.0"
|
|||
[dependencies]
|
||||
anyhow = "1.0.38"
|
||||
base64 = "0.13.0"
|
||||
fltk = "1.1.1"
|
||||
futures-util = "0.3.9"
|
||||
quinn = "0.7.2"
|
||||
rcgen = "0.8.11"
|
||||
|
|
|
@ -0,0 +1,118 @@
|
|||
use fltk::{
|
||||
app,
|
||||
button::Button,
|
||||
enums::CallbackTrigger,
|
||||
frame::Frame,
|
||||
input::*,
|
||||
prelude::*,
|
||||
window::Window
|
||||
};
|
||||
|
||||
#[derive (Clone, Copy)]
|
||||
enum Message {
|
||||
OpenPort,
|
||||
ClosePort,
|
||||
}
|
||||
|
||||
fn main () -> anyhow::Result <()> {
|
||||
tracing_subscriber::fmt::init ();
|
||||
let rt = tokio::runtime::Runtime::new ()?;
|
||||
|
||||
let (fltk_tx, fltk_rx) = app::channel::<Message> ();
|
||||
|
||||
let app = app::App::default();
|
||||
let mut wind = Window::new (100, 100, 800, 600, "PTTH client proxy");
|
||||
|
||||
let margin = 10;
|
||||
let h = 30;
|
||||
let mut x = margin;
|
||||
let mut y = margin;
|
||||
|
||||
let frame_status;
|
||||
|
||||
{
|
||||
frame_status = Frame::new (10, 10, 800 - 20, 30, "0 ports forwarded");
|
||||
}
|
||||
|
||||
y += h + margin;
|
||||
|
||||
{
|
||||
let w = 80;
|
||||
let frame_client_port = Frame::new (x, y, w, h, "Local port");
|
||||
x += w + margin;
|
||||
|
||||
let w = 120;
|
||||
let frame_server_id = Frame::new (x, y, w, h, "Server ID");
|
||||
x += w + margin;
|
||||
|
||||
let w = 80;
|
||||
let frame_server_port = Frame::new (x, y, 80, h, "Server port");
|
||||
x += w + margin;
|
||||
}
|
||||
|
||||
y += h + margin;
|
||||
|
||||
{
|
||||
let w = 80;
|
||||
let mut input_client_port = Input::new (10, y, w, h, "");
|
||||
x += w + margin;
|
||||
|
||||
let w = 120;
|
||||
let mut input_server_id = Input::new (100, y, w, h, "");
|
||||
x += w + margin;
|
||||
|
||||
let w = 80;
|
||||
let mut input_server_port = Input::new (230, y, w, h, "");
|
||||
x += w + margin;
|
||||
|
||||
let w = 80;
|
||||
let mut but_open = Button::new (320, y, w, h, "Open");
|
||||
x += w + margin;
|
||||
|
||||
let w = 80;
|
||||
let mut but_close = Button::new (410, y, w, h, "Close");
|
||||
x += w + margin;
|
||||
|
||||
input_client_port.set_value ("5901");
|
||||
input_server_id.set_value ("bogus_server");
|
||||
input_server_port.set_value ("5900");
|
||||
|
||||
but_open.set_trigger (CallbackTrigger::Changed);
|
||||
but_open.emit (fltk_tx, Message::OpenPort);
|
||||
but_close.set_trigger (CallbackTrigger::Changed);
|
||||
but_close.emit (fltk_tx, Message::ClosePort);
|
||||
|
||||
set_active (&mut but_open, true);
|
||||
set_active (&mut but_close, false);
|
||||
}
|
||||
|
||||
y += h + margin;
|
||||
|
||||
wind.end ();
|
||||
wind.show ();
|
||||
|
||||
|
||||
|
||||
while app.wait () {
|
||||
match fltk_rx.recv () {
|
||||
Some (Message::OpenPort) => {
|
||||
|
||||
},
|
||||
Some (Message::ClosePort) => {
|
||||
|
||||
},
|
||||
None => (),
|
||||
}
|
||||
}
|
||||
|
||||
Ok (())
|
||||
}
|
||||
|
||||
fn set_active <W: WidgetExt> (w: &mut W, b: bool) {
|
||||
if b {
|
||||
w.activate ();
|
||||
}
|
||||
else {
|
||||
w.deactivate ();
|
||||
}
|
||||
}
|
|
@ -11,10 +11,10 @@ struct Opt {
|
|||
#[structopt (long)]
|
||||
client_id: Option <PeerId>,
|
||||
#[structopt (long)]
|
||||
client_tcp_port: Option <u16>,
|
||||
#[structopt (long)]
|
||||
server_id: Option <PeerId>,
|
||||
#[structopt (long)]
|
||||
client_tcp_port: Option <u16>,
|
||||
#[structopt (long)]
|
||||
server_tcp_port: Option <u16>,
|
||||
}
|
||||
|
||||
|
@ -23,8 +23,6 @@ async fn main () -> anyhow::Result <()> {
|
|||
tracing_subscriber::fmt::init ();
|
||||
|
||||
let opt = Opt::from_args ();
|
||||
let client_tcp_port = opt.client_tcp_port.unwrap_or (30381);
|
||||
let server_tcp_port = opt.server_tcp_port.unwrap_or (30382);
|
||||
|
||||
let server_cert = tokio::fs::read ("quic_server.crt").await?;
|
||||
let relay_addr = opt.relay_addr.unwrap_or_else (|| String::from ("127.0.0.1:30380")).parse ()?;
|
||||
|
@ -39,12 +37,20 @@ async fn main () -> anyhow::Result <()> {
|
|||
..
|
||||
} = protocol::p2_connect_to_p3 (&endpoint, &relay_addr, &client_id).await?;
|
||||
|
||||
// End of per-client stuff
|
||||
// Beginning of per-port stuff
|
||||
|
||||
let server_id = opt.server_id.unwrap_or_else (|| "bogus_server".to_string ());
|
||||
|
||||
let client_tcp_port = opt.client_tcp_port.unwrap_or (30381);
|
||||
let server_tcp_port = opt.server_tcp_port.unwrap_or (30382);
|
||||
let listener = TcpListener::bind (("127.0.0.1", client_tcp_port)).await?;
|
||||
|
||||
trace! ("Accepting local TCP connections from P1");
|
||||
|
||||
// End of per-port stuff
|
||||
// Beginning of per-connection stuff
|
||||
|
||||
loop {
|
||||
let (tcp_socket, _) = listener.accept ().await?;
|
||||
let connection = connection.clone ();
|
||||
|
|
Loading…
Reference in New Issue