[repo] Lab relay: compile fixes after the first build (clippy, fmt); 28 unit tests pass

This commit is contained in:
2026-11-25 13:08:46 +01:00
parent ab5404b0cf
commit fd1c141ca8
6 changed files with 48 additions and 26 deletions
+15 -9
View File
@@ -53,7 +53,13 @@ pub fn serve(config: Arc<Config>, spec: PortSpec, rec: Arc<Recorder>) -> io::Res
let up = Arc::new(UdpSocket::bind(SocketAddr::new(config.listen, 0))?);
up.connect(upstream_addr)?;
let conn = rec.new_connection();
rec.log(Kind::Open, spec.protocol, Direction::None, conn, format!("{from} -> {upstream_addr}").as_bytes());
rec.log(
Kind::Open,
spec.protocol,
Direction::None,
conn,
format!("{from} -> {upstream_addr}").as_bytes(),
);
spawn_return_path(Arc::clone(&up), Arc::clone(&listen), from, spec, Arc::clone(&rec), conn);
map.insert(from, (Arc::clone(&up), conn));
Some((up, conn))
@@ -61,10 +67,10 @@ pub fn serve(config: Arc<Config>, spec: PortSpec, rec: Arc<Recorder>) -> io::Res
};
let Some((up, conn)) = flow else { continue };
rec.log(Kind::Data, spec.protocol, Direction::ClientToHost, conn, &buf[..n]);
if let Err(e) = up.send(&buf[..n]) {
if !transient(&e) {
rec.note(spec.protocol, conn, &format!("send to host failed: {e}"));
}
if let Err(e) = up.send(&buf[..n])
&& !transient(&e)
{
rec.note(spec.protocol, conn, &format!("send to host failed: {e}"));
}
}
}
@@ -83,10 +89,10 @@ fn spawn_return_path(
match up.recv(&mut buf) {
Ok(n) => {
rec.log(Kind::Data, spec.protocol, Direction::HostToClient, conn, &buf[..n]);
if let Err(e) = listen.send_to(&buf[..n], client) {
if !transient(&e) {
rec.note(spec.protocol, conn, &format!("send to client failed: {e}"));
}
if let Err(e) = listen.send_to(&buf[..n], client)
&& !transient(&e)
{
rec.note(spec.protocol, conn, &format!("send to client failed: {e}"));
}
}
Err(e) if transient(&e) => {}