#file-transfer #io-stream #peer #encryption #protocols #offers #securely

gday_file_transfer

Protocol to securely transfer files over an encrypted IO stream

3 unstable releases

0.2.1 Jul 12, 2024
0.2.0 Jul 8, 2024
0.1.1 Jun 7, 2024

#1523 in Network programming

39 downloads per month
Used in gday

MIT license

31KB
483 lines

Note: this crate is still in early-development, so expect breaking changes.

gday_file_transfer

Crates.io Version docs.rs

This library lets you offer and transfer files to another peer, assuming you already have a connection established.

See the documentation.

Used by

  • gday - Command line tool for sending files.

lib.rs:

Note: this crate is still in early-development, so expect breaking changes.

This library lets you offer and transfer files to another peer, assuming you already have a reliable connection established.

Example

The peers first establish a direct TCP connection using gday_hole_punch, and encrypt it with gday_encryption.

Peer A and peer B are on different computers in this example.

#
// Peer A offers files and folders they'd like to send
let paths_to_send = ["folder/to/send/".into(), "a/file.txt".into()];
let files_to_send = get_file_metas(&paths_to_send)?;
let offer_msg = FileOfferMsg::from(files_to_send.clone());
write_to(offer_msg, &mut stream)?;

// Peer B responds to the offer
let offer_msg: FileOfferMsg = read_from(&mut stream)?;
let response_msg = FileResponseMsg::accept_only_new_and_interrupted(
    &offer_msg,
    Path::new("save/the/files/here/"),
)?;
write_to(response_msg, &mut stream)?;

// Peer A sends the accepted files
let response_msg: FileResponseMsg = read_from(&mut stream)?;
send_files(&files_to_send, &response_msg, &mut stream, |progress| {})?;

// Peer B receives the accepted files
let save_path = Path::new("save/the/files/here/");
receive_files(&offer_msg, &response_msg, save_path, &mut stream, |progress| {})?;
#

Dependencies

~1.1–2MB
~43K SLoC