Skip to content

Commit

Permalink
Add a proper usage string
Browse files Browse the repository at this point in the history
  • Loading branch information
ruuda committed Jul 22, 2024
1 parent 66bc93a commit 745dcb9
Showing 1 changed file with 30 additions and 5 deletions.
35 changes: 30 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,35 @@ use std::time::Instant;
use borsh::BorshDeserialize;
use borsh::BorshSerialize;

const USAGE: &'static str = "Fastsync -- Transfer files over multiple TCP streams.
Usage:
fastsync send <listen-addr> <in-files...>
fastsync recv <server-addr> <num-streams>
Sender options:
<listen-addr> Address (IP and port) for the sending side to bind to and
listen for receivers. This should be the address of a
Wireguard interface if you care about confidentiality.
E.g. '100.71.154.83:7999'.
<in-files...> Paths of files to send. Input file paths need to be relative.
This is a safety measure to make it harder to accidentally
overwrite files in /etc and the like on the receiving end.
Receiver options:
<server-addr> The address (IP and port) that the sender is listening on.
E.g. '100.71.154.83:7999'.
<num-streams> The number of TCP streams to open. For a value of 1, Fastsync
behaves very similar to 'netcat'. With higher values,
Fastsync leverages the fact that file chunks don't need to
arrive in order to avoid the head-of-line blocking of a
single connection. You should experiment to find the best
value, going from 1 to 4 is usually helpful, going from 16
to 32 is probably overkill.
";

const MAX_CHUNK_LEN: u64 = 4096 * 64;

/// Metadata about all the files we want to transfer.
Expand Down Expand Up @@ -89,11 +118,7 @@ fn main() {
let n_conn = &args[2];
main_recv(addr, n_conn).expect("Failed to receive.");
}
_ => {
eprintln!("Usage:");
eprintln!(" fastsync send <listen-addr> <in-files...>");
eprintln!(" fastsync recv <server-addr> <num-connections>");
}
_ => eprintln!("{}", USAGE),
}
}

Expand Down

0 comments on commit 745dcb9

Please sign in to comment.