Compare commits
No commits in common. "6c5dff4685e01beede0b5375ce34485ff0187195" and "e6cf9e2b72066a029d10f979bd5acea1308a3334" have entirely different histories.
6c5dff4685
...
e6cf9e2b72
|
@ -48,7 +48,6 @@ struct GuiClient <'a> {
|
|||
rt: &'a Runtime,
|
||||
frame_status: Frame,
|
||||
ports: Vec <Port>,
|
||||
but_add_port: Button,
|
||||
}
|
||||
|
||||
struct Port {
|
||||
|
@ -57,11 +56,8 @@ struct Port {
|
|||
}
|
||||
|
||||
impl Port {
|
||||
pub fn open_port (
|
||||
&mut self,
|
||||
rt: &Runtime,
|
||||
connection_p2_p3: quinn::Connection,
|
||||
) -> anyhow::Result <()>
|
||||
pub fn open_port (&mut self, rt: &Runtime, connection_p2_p3: quinn::Connection)
|
||||
-> anyhow::Result <()>
|
||||
{
|
||||
let params = self.gui.get_params ()?;
|
||||
|
||||
|
@ -136,10 +132,6 @@ impl GuiClient <'_> {
|
|||
ports_col: &mut Flex,
|
||||
fltk_tx: fltk::app::Sender <Message>
|
||||
) {
|
||||
if self.ports.len () >= 5 {
|
||||
return;
|
||||
}
|
||||
|
||||
let mut gui = GuiPort::new (fltk_tx, self.ports.len ());
|
||||
ports_col.add (&gui.row);
|
||||
ports_col.set_size (&mut gui.row, 30);
|
||||
|
@ -150,10 +142,6 @@ impl GuiClient <'_> {
|
|||
};
|
||||
|
||||
self.ports.push (port);
|
||||
|
||||
if self.ports.len () >= 5 {
|
||||
self.but_add_port.deactivate ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -200,17 +188,10 @@ fn main () -> anyhow::Result <()> {
|
|||
|
||||
col.end ();
|
||||
|
||||
let relay_addr = opt.relay_addr.as_ref ()
|
||||
.map (|s| &s[..])
|
||||
.unwrap_or ("127.0.0.1:30380")
|
||||
.parse ()
|
||||
.context ("relay_addr should be like 127.0.0.1:30380")?;
|
||||
|
||||
let mut gui_client = GuiClient {
|
||||
rt: &rt,
|
||||
frame_status,
|
||||
ports: Default::default (),
|
||||
but_add_port,
|
||||
};
|
||||
|
||||
gui_client.add_port (&mut ports_col, fltk_tx);
|
||||
|
@ -227,6 +208,10 @@ fn main () -> anyhow::Result <()> {
|
|||
None => tokio::fs::read ("ptth_quic_output/quic_server.crt").await?.into (),
|
||||
};
|
||||
|
||||
let relay_addr = opt.relay_addr
|
||||
.unwrap_or_else (|| String::from ("127.0.0.1:30380"))
|
||||
.parse ()
|
||||
.context ("relay_addr should be like 127.0.0.1:30380")?;
|
||||
let endpoint = make_client_endpoint ("0.0.0.0:0".parse ()?, &[&server_cert])?;
|
||||
|
||||
trace! ("Connecting to relay server");
|
||||
|
@ -276,6 +261,7 @@ fn set_active <W: WidgetExt> (w: &mut W, b: bool) {
|
|||
|
||||
impl GuiPort {
|
||||
fn new (fltk_tx: fltk::app::Sender <Message>, port_idx: usize) -> Self {
|
||||
|
||||
let mut row = Flex::default ().row ();
|
||||
|
||||
let mut input_server_id = Input::default ();
|
||||
|
@ -322,6 +308,7 @@ impl GuiPort {
|
|||
let server_id = self.input_server_id.value ();
|
||||
|
||||
let client_tcp_port = PortInfo {
|
||||
relay_addr: "bogus_relay",
|
||||
server_id: &server_id,
|
||||
server_tcp_port,
|
||||
}.random_eph_port ();
|
||||
|
@ -351,7 +338,7 @@ impl GuiPort {
|
|||
|
||||
#[derive (serde::Serialize)]
|
||||
struct PortInfo <'a> {
|
||||
// relay_addr: SocketAddr,
|
||||
relay_addr: &'a str,
|
||||
server_id: &'a str,
|
||||
server_tcp_port: u16
|
||||
}
|
||||
|
@ -388,16 +375,14 @@ mod test {
|
|||
assert_eq! (port, 49408);
|
||||
|
||||
for (input, expected) in vec! [
|
||||
(("127.0.0.1:4000", "bogus_server", 22), 51168),
|
||||
// The relay address is explicitly excluded from the eph port
|
||||
// computation in case I want to support connecting to a server
|
||||
// across multiple relays
|
||||
(("127.0.0.1:30380", "bogus_server", 22), 51168),
|
||||
(("127.0.0.1:4000", "real_server", 22), 53873),
|
||||
(("127.0.0.1:4000", "bogus_server", 5900), 53844),
|
||||
(("bogus_relay", "bogus_server", 22), 62350),
|
||||
(("real_relay", "bogus_server", 22), 61081),
|
||||
(("bogus_relay", "real_server", 22), 50513),
|
||||
(("bogus_relay", "bogus_server", 5900), 60730),
|
||||
] {
|
||||
let (_relay_addr, server_id, server_tcp_port) = input;
|
||||
let (relay_addr, server_id, server_tcp_port) = input;
|
||||
let input = PortInfo {
|
||||
relay_addr,
|
||||
server_id,
|
||||
server_tcp_port,
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue