altugbakan / rs-tftpd Goto Github PK
View Code? Open in Web Editor NEWTFTP Server Daemon implemented in Rust
Home Page: https://crates.io/crates/tftpd
License: MIT License
TFTP Server Daemon implemented in Rust
Home Page: https://crates.io/crates/tftpd
License: MIT License
Now the rust-tftpd not support uploading files with the same name that already exist.
if uploading the file that already exist, the client will receive one error: Error code 6: requested file already exists
Could you help to add one option to support this feature?
The tsize
option can be used to verify the size of the received file after the transfer is complete. If the tsize
does not match the number of octets received then the error packet can be sent as a response to the last data packet.
This is a second verification apart from ACK that the data received is complete.
I can contribute the changes if you think it is appropriate to include this.
Hi: Thank you so much for the excellent work on rs-tftpd! Your project was very helpful for troubleshooting a strange TFTP Timeout problem on a RISC-V SBC (Star64), I wrote about it below. Thanks again! :-)
hi, Have you noticed that the download speed of the new version of tftp has become very slow?
I tested it, download 10M file, speet 30s
The version is v0.2.8
Updating crates.io index
Downloaded tftpd v0.2.8
Downloaded 1 crate (15.2 KB) in 3.34s
Installing tftpd v0.2.8
Updating crates.io index
Compiling tftpd v0.2.8
Finished release [optimized] target(s) in 8.76s
Replacing /home/jinxsong/.cargo/bin/tftpd
Replaced package tftpd v0.2.6
with tftpd v0.2.8
(executable tftpd
)
Can we add parameters in config (directoryupload, directorydownload)?
If both directoryupload and directorydownload are set, then tftp download from directorydownload and tftp upload to directoryupload.
This issue is visible with single socket case when you send READ request with option(s).
accept_request & check_response:
After sending OACK server starts to wait ACK as response from client, but in single socket case recv_with_size() waits data from mpsc channel. I guess a problem is that listen() which is maybe supposed to receive ACK and send data to channel don't get run. I.e. we don't have worker yet (or thread) to handle ACK response for OACK. So basically in impl Socket for ServerSocket
function fn recv_with_size(&self, _size: usize) -> Result<Packet, Box<dyn Error>>
hangs on if let Ok(packet) = receiver.recv_timeout(self.timeout)
until timeout occurs.
When running the tests with cargo test (in Fedora 37), window::tests::fills_and_removes_from_window fails.
RUST_BACKTRACE=1 cargo test
Finished test [unoptimized + debuginfo] target(s) in 0.00s
Running unittests src/lib.rs (target/debug/deps/tftpd-bc4c52d8dbe9f884)
running 28 tests
test config::tests::parses_full_config ... ok
test config::tests::parses_some_config ... ok
test config::tests::returns_error_on_invalid_directory ... ok
test config::tests::returns_error_on_invalid_port ... ok
test config::tests::returns_error_on_invalid_ip ... ok
test convert::tests::converts_to_string ... ok
test convert::tests::converts_to_string_with_index ... ok
test convert::tests::converts_to_u16 ... ok
test convert::tests::returns_error_on_short_array ... ok
test packet::tests::parses_ack ... ok
test packet::tests::parses_data ... ok
test packet::tests::parses_error ... ok
test packet::tests::parses_error_without_message ... ok
test packet::tests::parses_read_request ... ok
test packet::tests::parses_read_request_with_options ... ok
test packet::tests::parses_write_request ... ok
test packet::tests::parses_write_request_with_options ... ok
test packet::tests::serializes_ack ... ok
test packet::tests::serializes_data ... ok
test packet::tests::serializes_error ... ok
test packet::tests::serializes_oack ... ok
test server::tests::parses_default_options ... ok
test server::tests::parses_read_options ... ok
test server::tests::parses_write_options ... ok
test server::tests::validates_file_path ... ok
test socket::tests::test_recv ... ok
test window::tests::adds_to_and_empties_window ... ok
test window::tests::fills_and_removes_from_window ... FAILED
failures:
---- window::tests::fills_and_removes_from_window stdout ----
thread 'window::tests::fills_and_removes_from_window' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 17, kind: AlreadyExists, message: "File exists" }', src/window.rs:194:38
stack backtrace:
0: rust_begin_unwind
at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/std/src/panicking.rs:575:5
1: core::panicking::panic_fmt
at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/core/src/panicking.rs:65:14
2: core::result::unwrap_failed
at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/core/src/result.rs:1791:5
3: core::result::Result<T,E>::unwrap
at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/core/src/result.rs:1113:23
4: tftpd::window::tests::initialize
at ./src/window.rs:194:13
5: tftpd::window::tests::fills_and_removes_from_window
at ./src/window.rs:132:24
6: tftpd::window::tests::fills_and_removes_from_window::{{closure}}
at ./src/window.rs:129:5
7: core::ops::function::FnOnce::call_once
at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/core/src/ops/function.rs:251:5
8: core::ops::function::FnOnce::call_once
at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/core/src/ops/function.rs:251:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
failures:
window::tests::fills_and_removes_from_window
test result: FAILED. 27 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.01s
error: test failed, to rerun pass `--lib`
I was able to fix this by ignoring the error
diff --git a/src/window.rs b/src/window.rs
index 7aad4f1..2a40ade 100644
--- a/src/window.rs
+++ b/src/window.rs
@@ -191,7 +191,8 @@ mod tests {
fn initialize(file_name: &str) -> File {
let file_name = DIR_NAME.to_string() + "/" + file_name;
if !Path::new(DIR_NAME).is_dir() {
- fs::create_dir(DIR_NAME).unwrap();
+ if fs::create_dir(DIR_NAME).is_err() {
+ }
}
if File::open(&file_name).is_ok() {
But I don't know if it's the correct fix.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.