🐛 bug (ptth_quic_client_gui): display the correct number of forwarded ports

main
_ 2021-10-10 18:00:20 +00:00
parent 11ee6292ba
commit de4da749f3
1 changed files with 14 additions and 3 deletions

View File

@ -59,8 +59,7 @@ impl GuiClient <'_> {
)); ));
self.gui_ports [port_idx].set_forwarding (true); self.gui_ports [port_idx].set_forwarding (true);
self.sync_status ();
self.frame_status.set_label ("Forwarding 1 port");
Ok (()) Ok (())
} }
@ -71,10 +70,22 @@ impl GuiClient <'_> {
} }
self.gui_ports [port_idx].set_forwarding (false); self.gui_ports [port_idx].set_forwarding (false);
self.frame_status.set_label ("Forwarding 0 ports"); self.sync_status ();
Ok (()) Ok (())
} }
fn open_ports (&self) -> usize {
self.forwarding_instances.iter ()
.map (|x| if x.is_some () { 1 } else { 0 })
.sum ()
}
fn sync_status (&mut self) {
let open_ports = self.open_ports ();
self.frame_status.set_label (&format! ("Forwarding {} ports", open_ports));
}
} }
fn main () -> anyhow::Result <()> { fn main () -> anyhow::Result <()> {