Dumb fixes, still needs two presses not clear why
This commit is contained in:
parent
de6607eb25
commit
9eb5565f66
2 changed files with 14 additions and 8 deletions
18
src/lib.rs
18
src/lib.rs
|
|
@ -105,14 +105,14 @@ async fn server_read<T: AsyncRead + Unpin>(
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
let ports = match refresh::get_entries() {
|
let ports = match refresh::get_entries() {
|
||||||
Ok(ports) => ports,
|
Ok(ports) => ports,
|
||||||
Err(_) => {
|
Err(_e) => {
|
||||||
// eprintln!("< Error scanning: {:?}", e);
|
// eprintln!("< Error scanning: {:?}", _e);
|
||||||
vec![]
|
vec![]
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if let Err(_) = writer.send(Message::Ports(ports)).await {
|
if let Err(_e) = writer.send(Message::Ports(ports)).await {
|
||||||
// Writer has been closed for some reason, we can just quit.... I hope everything is OK?
|
// Writer has been closed for some reason, we can just quit.... I hope everything is OK?
|
||||||
// eprintln!("< Warning: Error sending: {:?}", e);
|
// eprintln!("< Warning: Error sending: {:?}", _e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -227,10 +227,14 @@ async fn client_listen(
|
||||||
loop {
|
loop {
|
||||||
let listener = TcpListener::bind(SocketAddrV4::new(Ipv4Addr::LOCALHOST, port)).await?;
|
let listener = TcpListener::bind(SocketAddrV4::new(Ipv4Addr::LOCALHOST, port)).await?;
|
||||||
loop {
|
loop {
|
||||||
|
// eprintln!("LISTENING ON PORT {port}");
|
||||||
|
|
||||||
// The second item contains the IP and port of the new
|
// The second item contains the IP and port of the new
|
||||||
// connection, but we don't care.
|
// connection, but we don't care.
|
||||||
let (mut socket, _) = listener.accept().await?;
|
let (mut socket, _) = listener.accept().await?;
|
||||||
|
|
||||||
|
// eprintln!("GOT ONE!");
|
||||||
|
|
||||||
let (writer, connections) = (writer.clone(), connections.clone());
|
let (writer, connections) = (writer.clone(), connections.clone());
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
client_handle_connection(port, writer, connections, &mut socket).await;
|
client_handle_connection(port, writer, connections, &mut socket).await;
|
||||||
|
|
@ -298,8 +302,10 @@ async fn client_read<T: AsyncRead + Unpin>(
|
||||||
r = client_listen(port, writer, connections) => r,
|
r = client_listen(port, writer, connections) => r,
|
||||||
_ = stop => Ok(()),
|
_ = stop => Ok(()),
|
||||||
};
|
};
|
||||||
if let Err(_) = result {
|
if let Err(_e) = result {
|
||||||
// eprintln!("> Error listening on port {}: {:?}", port, e);
|
// eprintln!("> Error listening on port {port}: {_e:?}");
|
||||||
|
} else {
|
||||||
|
// eprintln!("> Stopped listening on port {port}");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ async fn run_ui_core(port_receiver: &mut mpsc::Receiver<Vec<PortDesc>>) -> Resul
|
||||||
let columns: usize = columns.into();
|
let columns: usize = columns.into();
|
||||||
let padding = 1;
|
let padding = 1;
|
||||||
let port_width = 5; // 5 characters for 16-bit number
|
let port_width = 5; // 5 characters for 16-bit number
|
||||||
let url_width = "http://localhost:/".len() + port_width;
|
let url_width = "http://127.0.0.1:/".len() + port_width;
|
||||||
|
|
||||||
let description_width = columns - (padding + port_width + padding + url_width + padding);
|
let description_width = columns - (padding + port_width + padding + url_width + padding);
|
||||||
|
|
||||||
|
|
@ -81,7 +81,7 @@ async fn run_ui_core(port_receiver: &mut mpsc::Receiver<Vec<PortDesc>>) -> Resul
|
||||||
print!(
|
print!(
|
||||||
" {:port_width$} {:url_width$} {:description_width$}\r\n",
|
" {:port_width$} {:url_width$} {:description_width$}\r\n",
|
||||||
port.port,
|
port.port,
|
||||||
format!("http://locahost:{}/", port.port),
|
format!("http://127.0.0.1:{}/", port.port),
|
||||||
port.desc
|
port.desc
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue