diff options
| -rw-r--r-- | src/tftp.rs | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/tftp.rs b/src/tftp.rs index becaa65..681d036 100644 --- a/src/tftp.rs +++ b/src/tftp.rs | |||
| @@ -267,7 +267,8 @@ pub fn parse_packet(buf: &[u8]) -> Result<TftpPacket> { | |||
| 267 | } | 267 | } |
| 268 | } | 268 | } |
| 269 | 269 | ||
| 270 | pub fn serve(dir: &Path) -> Result<()> { | 270 | pub fn serve(dir: impl AsRef<Path>) -> Result<()> { |
| 271 | let dir = dir.as_ref(); | ||
| 271 | let socket = UdpSocket::bind(format!("0.0.0.0:{PORT}"))?; | 272 | let socket = UdpSocket::bind(format!("0.0.0.0:{PORT}"))?; |
| 272 | 273 | ||
| 273 | // TODO: this needs to be done per addr | 274 | // TODO: this needs to be done per addr |
| @@ -357,8 +358,10 @@ pub fn serve(dir: &Path) -> Result<()> { | |||
| 357 | 358 | ||
| 358 | if let Some(response) = response { | 359 | if let Some(response) = response { |
| 359 | let mut writer = Cursor::new(&mut buf[..]); | 360 | let mut writer = Cursor::new(&mut buf[..]); |
| 361 | println!("Sending to {addr}: {response:#?}"); | ||
| 360 | response.write(&mut writer).unwrap(); | 362 | response.write(&mut writer).unwrap(); |
| 361 | let (response, _) = writer.split(); | 363 | let (response, _) = writer.split(); |
| 364 | println!("Sending {} bytes to {addr}: {response:#?}", response.len()); | ||
| 362 | socket.send_to(&response, addr).unwrap(); | 365 | socket.send_to(&response, addr).unwrap(); |
| 363 | } | 366 | } |
| 364 | } | 367 | } |
