Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# Sendme

This is an example to use [iroh-bytes](https://crates.io/crates/iroh-bytes) and
[iroh-net](https://crates.io/crates/iroh-net) to send files and directories over
the internet.
This is an example application using [iroh](https://crates.io/crates/iroh) with
the [iroh-blobs](https://crates.io/crates/iroh-blobs) protocol to send files and
directories over the internet.

It is also useful as a standalone tool for quick copy jobs.

Iroh-net will take case of hole punching and NAT traversal whenever possible,
Iroh will take case of hole punching and NAT traversal whenever possible,
and fall back to a relay if hole punching does not succeed.

Iroh-bytes will take care of [blake3](https://crates.io/crates/blake3) verified
Iroh-blobs will take care of [blake3](https://crates.io/crates/blake3) verified
streaming, including resuming interrupted downloads.

Sendme works with 256 bit node ids and therefore location transparent. A ticket
Sendme works with 256 bit node ids and is therefore location transparent. A ticket
will remain valid if the IP address changes. Connections are encrypted using
TLS.

Expand Down
15 changes: 14 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ use futures_lite::{future::Boxed, StreamExt};
use indicatif::{
HumanBytes, HumanDuration, MultiProgress, ProgressBar, ProgressDrawTarget, ProgressStyle,
};
use iroh::{Endpoint, NodeAddr, RelayMap, RelayMode, RelayUrl, SecretKey};
use iroh::{
discovery::{dns::DnsDiscovery, pkarr::PkarrPublisher},
Endpoint, NodeAddr, RelayMap, RelayMode, RelayUrl, SecretKey,
};
use iroh_blobs::{
format::collection::Collection,
get::{
Expand Down Expand Up @@ -582,6 +585,10 @@ async fn send(args: SendArgs) -> anyhow::Result<()> {
.alpns(vec![iroh_blobs::protocol::ALPN.to_vec()])
.secret_key(secret_key)
.relay_mode(args.common.relay.into());
if args.ticket_type == AddrInfoOptions::Id {
builder =
builder.add_discovery(|secret_key| Some(PkarrPublisher::n0_dns(secret_key.clone())));
}
if let Some(addr) = args.common.magic_ipv4_addr {
builder = builder.bind_addr_v4(addr);
}
Expand Down Expand Up @@ -779,6 +786,9 @@ async fn receive(args: ReceiveArgs) -> anyhow::Result<()> {
.secret_key(secret_key)
.relay_mode(args.common.relay.into());

if ticket.node_addr().relay_url.is_none() && ticket.node_addr().direct_addresses.is_empty() {
builder = builder.add_discovery(|_| Some(DnsDiscovery::n0_dns()));
}
if let Some(addr) = args.common.magic_ipv4_addr {
builder = builder.bind_addr_v4(addr);
}
Expand Down Expand Up @@ -875,6 +885,9 @@ async fn main() -> anyhow::Result<()> {
Commands::Send(args) => send(args).await,
Commands::Receive(args) => receive(args).await,
};
if let Err(e) = &res {
eprintln!("{e}");
}
match res {
Ok(()) => std::process::exit(0),
Err(_) => std::process::exit(1),
Expand Down
Loading