altugbakan / rs-tftpd

TFTP Server Daemon implemented in Rust
https://crates.io/crates/tftpd
MIT License
51 stars 14 forks source link

Fix single port RRQ with options fail #17

Closed kjyrinki-unikie closed 6 months ago

kjyrinki-unikie commented 6 months ago

When running tftpd with -s single port argument and Read Request with options are provided ACK for OACK is not properly received.

The problem is that code is waiting MPSC channel response, but there is no thread for receiving data from UDP socket and MPSC receive will timeout.

Fix is to move waiting of ACK response for OACK into worker thread in the beginning of file sending. I.e. File send is started with receiving ACK when there were options and OACK was sent in the accept_request().

Fixes issue #16

altugbakan commented 6 months ago

I think this is a good start, but can we solve this problem by creating a new method called recv_raw for the Socket trait, which is just recv for the UdpSocket, but on ServerSocket, uses the internal UdpSocket to get the data? This way we can put recv_raw inside the check_response function, and it will use the provided Socket to get the data for each case.

kjyrinki-unikie commented 6 months ago

Not 100% sure if I got your idea, but I think approach you proposed might have issue in single port case if some other client tries to connect while the check_response() is waiting the ACK for OACK from the previous client in this new recv.