From ad21b8b1ba36dbab4883a6b99e52463c754fd135 Mon Sep 17 00:00:00 2001 From: Patrick Date: Wed, 1 Jan 2025 21:02:07 +0100 Subject: [PATCH] fix: splice --- flake.nix | 1 + src/main.rs | 7 +++---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/flake.nix b/flake.nix index a2efa44..a126949 100644 --- a/flake.nix +++ b/flake.nix @@ -89,6 +89,7 @@ drvConfig = { mkDerivation = { nativeBuildInputs = [ pkgs.pkg-config ]; + meta.mainProgram = "mdns-relay"; }; }; }; diff --git a/src/main.rs b/src/main.rs index 19176eb..781b52f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -115,15 +115,14 @@ fn main() -> Result<()> { let socket: UdpSocket = socket.into(); loop { match socket.recv_from(&mut buf) { - Ok((l, from)) => { - let buf = &buf[0..l]; + Ok((_l, from)) => { if interfaces .iter() .any(|x| x.iface.ips.iter().any(|y| y.ip() == from.ip())) { continue; } - let packet = Packet::parse(buf)?; + let packet = Packet::parse(&buf)?; let iface = match get_iface(&from, &interfaces) { Err(_) => { error!("Invalid packet received from {}", from); @@ -152,7 +151,7 @@ fn main() -> Result<()> { if out.contains(&i.iface.name) { debug!("sending packet on {}", i.iface.name); let sock_addr = SocketAddrV4::new(ADDR, 5353).into(); - i.socket.send_to(buf, &sock_addr)?; + i.socket.send_to(&buf, &sock_addr)?; } } }