Skip to content

Commit

Permalink
Changed receive to get.
Browse files Browse the repository at this point in the history
  • Loading branch information
manforowicz committed Jul 11, 2024
1 parent 6b6b118 commit 0513aef
Show file tree
Hide file tree
Showing 14 changed files with 45 additions and 148 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/Cargo.lock
/target
/target
tmp
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@ Note: this project is still in early-development, so expect breaking changes.
# gday
[![Crates.io Version](https://img.shields.io/crates/v/gday_server)](https://crates.io/crates/gday_server)

A command line tool for sending files.
Command line tool to securely send files (without a relay or port forwarding).

<pre>
<b style="color:lime;">peer_1:</b> gday send msg.txt image.jpg
<i>&lt;Asks for confirmation&gt;</i>
Tell your mate to run "gday receive <b>1.188T.W3H.E</b>".
Tell your mate to run "gday get <b>1.188T.W3H.E</b>".
<b>Transfer complete.</b>
</pre>

<pre>
<b style="color:lime;">peer_2:</b> gday receive <b>1.188T.W3H.E</b>
<b style="color:lime;">peer_2:</b> gday get <b>1.188T.W3H.E</b>
<i>&lt;Asks for confirmation&gt;</i>
<b>Transfer complete.</b>
</pre>

[![asciicast](https://asciinema.org/a/662397.svg)](https://asciinema.org/a/662397)
[![asciicast](https://asciinema.org/a/1jjPVyccHweqgwA5V3un4tCnU.svg)](https://asciinema.org/a/1jjPVyccHweqgwA5V3un4tCnU)

## Installation

Expand All @@ -32,11 +32,11 @@ and download the correct file for your platform.

### Cargo

`cargo install gday`
If you have `cargo`, run `cargo install gday`.

### Brew

`brew install manforowicz/tap/gday`
If you have `brew`, run `brew install manforowicz/tap/gday`.

## Features
- File transfer is always direct, without relays.
Expand All @@ -63,14 +63,14 @@ Note: This may not work on networks with very restrictive
Usage: gday [OPTIONS] <COMMAND>
Commands:
send Send files
receive Receive files. Input the code your peer told you
help Print this message or the help of the given subcommand(s)
send Send files and/or directories
get Receive files
help Print this message or the help of the given subcommand(s)
Options:
-s, --server <SERVER> Use a custom gday server with this domain name
-p, --port <PORT> Which server port to connect to
-u, --unencrypted Use unencrypted TCP instead of TLS to the custom server
-p, --port <PORT> Connect to a custom server port
-u, --unencrypted Use raw TCP without TLS
-v, --verbosity <VERBOSITY> Verbosity. (trace, debug, info, warn, error) [default: warn]
-h, --help Print help
-V, --version Print version
Expand All @@ -82,7 +82,7 @@ Options:
<tr>
<th></th>
<th>No relays</th>
<th>Works beyond most LAN</th>
<th>Works beyond LAN</th>
<th>Works through very strict <a href="https://en.wikipedia.org/wiki/Network_address_translation">NATs</a></th>
<th>No port forwarding</th>
<th>Encrypted</th>
Expand Down
18 changes: 9 additions & 9 deletions gday/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@ Note: this project is still in early-development, so expect breaking changes.
# gday
[![Crates.io Version](https://img.shields.io/crates/v/gday_server)](https://crates.io/crates/gday_server)

A command line tool for sending files.
Command line tool to securely send files (without a relay or port forwarding).

<pre>
<b style="color:lime;">peer_1:</b> gday send msg.txt image.jpg
<i>&lt;Asks for confirmation&gt;</i>
Tell your mate to run "gday receive <b>1.188T.W3H.E</b>".
Tell your mate to run "gday get <b>1.188T.W3H.E</b>".
<b>Transfer complete.</b>
</pre>

<pre>
<b style="color:lime;">peer_2:</b> gday receive <b>1.188T.W3H.E</b>
<b style="color:lime;">peer_2:</b> gday get <b>1.188T.W3H.E</b>
<i>&lt;Asks for confirmation&gt;</i>
<b>Transfer complete.</b>
</pre>

[![asciicast](https://asciinema.org/a/662397.svg)](https://asciinema.org/a/662397)
[![asciicast](https://asciinema.org/a/1jjPVyccHweqgwA5V3un4tCnU.svg)](https://asciinema.org/a/1jjPVyccHweqgwA5V3un4tCnU)

## Installation

Expand Down Expand Up @@ -63,14 +63,14 @@ Note: This may not work on networks with very restrictive
Usage: gday [OPTIONS] <COMMAND>
Commands:
send Send files
receive Receive files. Input the code your peer told you
help Print this message or the help of the given subcommand(s)
send Send files and/or directories
get Receive files
help Print this message or the help of the given subcommand(s)
Options:
-s, --server <SERVER> Use a custom gday server with this domain name
-p, --port <PORT> Which server port to connect to
-u, --unencrypted Use unencrypted TCP instead of TLS to the custom server
-p, --port <PORT> Connect to a custom server port
-u, --unencrypted Use raw TCP without TLS
-v, --verbosity <VERBOSITY> Verbosity. (trace, debug, info, warn, error) [default: warn]
-h, --help Print help
-V, --version Print version
Expand Down
13 changes: 4 additions & 9 deletions gday/src/dialog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use indicatif::HumanBytes;
use owo_colors::OwoColorize;
use std::{io::Write, path::Path};

/// Confirms that the user wants to send these files.
/// Confirms that the user wants to send these `files``.
///
/// If not, returns false.
pub fn confirm_send(files: &FileOfferMsg) -> std::io::Result<bool> {
Expand Down Expand Up @@ -35,19 +35,14 @@ pub fn confirm_send(files: &FileOfferMsg) -> std::io::Result<bool> {
}
}

/// Asks the user which of these offered `files` to accept.
/// Asks the user which of the files in `offer` to accept.
///
/// `save_dir` is the directory where the files will later be saved.
///
/// Returns a `Vec<Option<u64>>`, where each
/// - `None` represents rejecting the file at this index,
/// - `Some(0)` represents fully accepting the file at this index,
/// - `Some(x)` represents resuming with the first `x` bytes skipped.
pub fn ask_receive(
offer: &FileOfferMsg,
save_dir: &Path,
) -> Result<FileResponseMsg, gday_file_transfer::Error> {
println!("{}", "Your mate wants to send you:".bold(),);
println!("{}", "Your mate wants to send you:".bold());

// Print all the offered files.
for file in &offer.files {
Expand All @@ -60,7 +55,7 @@ pub fn ask_receive(

print!(
" {} {} {}",
"PARTIALLY DOWNLOADED.".red().bold(),
"CAN RESUME DOWNLOAD.".red().bold(),
HumanBytes(remaining_len).red().bold(),
"REMAINING".red().bold()
);
Expand Down
9 changes: 3 additions & 6 deletions gday/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ enum Command {
},

/// Receive files.
Receive {
Get {
/// Directory where to save the files.
/// By default, saves them in the current directory.
#[arg(short, long, default_value = ".")]
Expand Down Expand Up @@ -157,10 +157,7 @@ fn run(args: crate::Args) -> Result<(), Box<dyn std::error::Error>> {

info!("Your contact is:\n{my_contact}");

println!(
"Tell your mate to run \"gday receive {}\"",
peer_code.bold()
);
println!("Tell your mate to run \"gday get {}\"", peer_code.bold());

// get peer's contact
let peer_contact = contact_sharer.get_peer_contact()?;
Expand Down Expand Up @@ -208,7 +205,7 @@ fn run(args: crate::Args) -> Result<(), Box<dyn std::error::Error>> {
}

// receiving files
crate::Command::Receive { path, code } => {
crate::Command::Get { path, code } => {
let code = PeerCode::from_str(&code)?;
let (contact_sharer, my_contact) =
ContactSharer::join_room(&mut server_connection, code.room_code)?;
Expand Down
2 changes: 1 addition & 1 deletion gday_hole_punch/src/hole_puncher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const RETRY_INTERVAL: Duration = Duration::from_millis(200);
/// Tries to establish a TCP connection with the other peer by using
/// [TCP hole punching](https://en.wikipedia.org/wiki/TCP_hole_punching).
///
/// - `local_contact` should be the `private` field of your [`FullContact`]
/// - `local_contact` should be the `local` field of your [`FullContact`]
/// that [`crate::ContactSharer`] returned when you created or joined a room.
/// Panics if both `v4` and `v6` are `None`.
/// - `peer_contact` should be the [`FullContact`] returned by [`crate::ContactSharer::get_peer_contact()`].
Expand Down
2 changes: 1 addition & 1 deletion gday_hole_punch/src/server_connector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub use gday_contact_exchange_protocol::DEFAULT_TLS_PORT;
///
/// Having many server options helps make Gday decentralized!
/// - Submit an issue on Gday's GitHub if you'd like to add your own!
/// - All of these serve with encrypted TLS over port 443.
/// - All of these serve encrypted TLS over port 443.
pub const DEFAULT_SERVERS: &[ServerInfo] = &[ServerInfo {
domain_name: "gday.manforowicz.com",
id: 1,
Expand Down
7 changes: 4 additions & 3 deletions gday_server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Note: this crate is still in early-development, so expect breaking changes.

# gday_server
[![Crates.io Version](https://img.shields.io/crates/v/gday_server)](https://crates.io/crates/gday_server)
[![docs.rs](https://img.shields.io/docsrs/gday_server)](https://docs.rs/gday_server/)

A server that runs the [gday_contact_exchange_protocol](https://docs.rs/gday_contact_exchange_protocol/).

Expand Down Expand Up @@ -31,8 +32,8 @@ Options:
-k, --key <KEY> PEM file of private TLS server key
-c, --certificate <CERTIFICATE> PEM file of signed TLS server certificate
-u, --unencrypted Use unencrypted TCP instead of TLS
-a, --address <ADDRESS> Custom socket address on which to listen. [default: `[::]:443` for TLS, `[::]:80` when --unencrypted]
-t, --timeout <TIMEOUT> Number of seconds before a new room is deleted [default: 600]
-a, --address <ADDRESS> Custom socket address on which to listen. [default: `[::]:2311` for TLS, `[::]:2310` when --unencrypted]
-t, --timeout <TIMEOUT> Number of seconds before a new room is deleted [default: 3600]
-r, --request-limit <REQUEST_LIMIT> Max number of requests an IP address can send in a minute before they're rejected [default: 60]
-v, --verbosity <VERBOSITY> Log verbosity. (trace, debug, info, warn, error) [default: info]
-h, --help Print help
Expand All @@ -57,7 +58,7 @@ Here's how:
9. Submit an [issue](https://github.com/manforowicz/gday/issues), asking for your server to be added to the [default server list](https://docs.rs/gday_hole_punch/latest/gday_hole_punch/server_connector/constant.DEFAULT_SERVERS.html).

## Related
- [gday](https://crates.io/crates/gday_server) - Command line tool for sending files.
- [gday](https://crates.io/crates/gday) - Command line tool for sending files.

## Depends on
- [gday_contact_exchange_protocol](https://docs.rs/gday_contact_exchange_protocol/) - Library with protocol for two peers to share their socket addresses via a server.
17 changes: 9 additions & 8 deletions other/demo/demo.sh → other/demo.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
#!/usr/bin/env bash

# Custom script for starting a tmux 2-pane
# asciinema recording.
# Custom script for starting a tmux 2-pane asciinema recording.
# Intended for recording gday demos.

# Requires: asciinema, tmux,
# and 2 subdirectories called 'peer_1', 'peer_2'

# Add gday to path using cargo install.

# Requires: asciinema, tmux
# Use ctrl+b <arrow key> to switch between panes.
# Use ctrl+d to end the recording.

# Create the demo folders if they don't exist yet.
mkdir tmp
cd tmp
mkdir peer_1
mkdir peer_2

# Start a new session detached
tmux new-session -d -s demo_session
Expand Down
Loading

0 comments on commit 0513aef

Please sign in to comment.