12 releases

0.3.6 Dec 16, 2022
0.3.5 Jan 28, 2021
0.3.4 Dec 12, 2020
0.3.3 Sep 14, 2020
0.0.1 Nov 14, 2019

#921 in Network programming

Download history 128/week @ 2023-11-20 213/week @ 2023-11-27 78/week @ 2023-12-04 144/week @ 2023-12-11 101/week @ 2023-12-18 2/week @ 2023-12-25 132/week @ 2024-01-01 66/week @ 2024-01-08 67/week @ 2024-01-15 118/week @ 2024-01-22 156/week @ 2024-01-29 148/week @ 2024-02-05 181/week @ 2024-02-12 180/week @ 2024-02-19 144/week @ 2024-02-26 215/week @ 2024-03-04

726 downloads per month
Used in quick-serve

MIT license

68KB
1.5K SLoC

async-tftp

license crates.io docs

Executor agnostic async TFTP implementation, written with smol building blocks. Currently it implements only server side.

The following RFCs are implemented:

  • RFC 1350 - The TFTP Protocol (Revision 2).
  • RFC 2347 - TFTP Option Extension.
  • RFC 2348 - TFTP Blocksize Option.
  • RFC 2349 - TFTP Timeout Interval and Transfer Size Options.

Features:

  • Async implementation.
  • Works with any runtime/executor.
  • Serve read (RRQ) and write (WRQ) requests.
  • Unlimited transfer file size (block number roll-over).
  • You can set non-standard reply timeout. This is useful for faster file transfer in unstable environments.
  • You can set block size limit. This is useful if you are accessing client through a VPN.
  • You can implement your own Handler for more advance cases than just serving a directory. Check tftpd-targz.rs for an example.

Example

use async_tftp::server::TftpServerBuilder;
use async_tftp::Result;

fn main() -> Result<()> {
    smol::block_on(async { // or any other runtime/executor
        let tftpd = TftpServerBuilder::with_dir_ro(".")?.build().await?;
        tftpd.serve().await?;
        Ok(())
    })
}

Add in Cargo.toml:

[dependencies]
smol = "1" # or any other runtime/executor
async-tftp = "0.3"

Running examples with cargo

There are some examples included with this crate. You can run them from a source checkout with cargo:

$ cargo run --example tftpd-dir
TFTP directory: ...
Listening on: 0.0.0.0:6969
^C

$ cargo run --example tftpd-targz <archive-path>
Listening on: 0.0.0.0:6969
^C

License

MIT

Dependencies

~6–18MB
~224K SLoC