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

gday_file_transfer

Protocol to securely transfer files over an encrypted IO stream

4 releases (2 breaking)

0.3.0 Dec 2, 2024
0.2.1 Jul 12, 2024
0.2.0 Jul 8, 2024
0.1.1 Jun 7, 2024

#1725 in Network programming

Download history 19/week @ 2024-09-14 14/week @ 2024-09-21 6/week @ 2024-09-28 146/week @ 2024-11-30 19/week @ 2024-12-07

165 downloads per month
Used in gday

MIT license

36KB
563 lines

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:

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_async(offer_msg, &mut stream1).await?;

// Peer B responds to the offer
let offer_msg: FileOfferMsg = read_from_async(&mut stream2).await?;
let response_msg = FileResponseMsg::accept_only_new_and_interrupted(
    &offer_msg,
    Path::new("save/the/files/here/"),
)?;
write_to_async(response_msg, &mut stream2).await?;

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

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

Dependencies

~3–9.5MB
~86K SLoC