Skip to content
Merged
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
22 changes: 18 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,9 @@ async fn export(db: &Store, collection: Collection, mp: &mut MultiProgress) -> a
"target {} already exists. Export stopped.",
target.display()
);
eprintln!("You can remove the file or directory and try again. The download will not be repeated.");
eprintln!(
"You can remove the file or directory and try again. The download will not be repeated."
);
anyhow::bail!("target {} already exists", target.display());
}
let mut stream = db
Expand Down Expand Up @@ -632,10 +634,11 @@ async fn send(args: SendArgs) -> anyhow::Result<()> {
eprintln!("using secret key {secret_key}");
}
// create a magicsocket endpoint
let relay_mode: RelayMode = args.common.relay.into();
let mut builder = Endpoint::builder()
.alpns(vec![iroh_blobs::protocol::ALPN.to_vec()])
.secret_key(secret_key)
.relay_mode(args.common.relay.into());
.relay_mode(relay_mode.clone());
if args.ticket_type == AddrInfoOptions::Id {
builder = builder.add_discovery(PkarrPublisher::n0_dns());
}
Expand All @@ -647,7 +650,7 @@ async fn send(args: SendArgs) -> anyhow::Result<()> {
}

// use a flat store - todo: use a partial in mem store instead
let suffix = rand::thread_rng().gen::<[u8; 16]>();
let suffix = rand::thread_rng().r#gen::<[u8; 16]>();
let cwd = std::env::current_dir()?;
let blobs_data_dir = cwd.join(format!(".sendme-send-{}", HEXLOWER.encode(&suffix)));
if blobs_data_dir.exists() {
Expand Down Expand Up @@ -705,8 +708,19 @@ async fn send(args: SendArgs) -> anyhow::Result<()> {
let router = iroh::protocol::Router::builder(endpoint)
.accept(iroh_blobs::ALPN, blobs.clone())
.spawn();

// wait for the endpoint to figure out its address before making a ticket
let _ = router.endpoint().home_relay().initialized().await;
let ep = router.endpoint();
tokio::time::timeout(Duration::from_secs(30), async move {
if matches!(relay_mode, RelayMode::Disabled) {
// no relay will arrive, as we disabled it, so wait for general init
let _ = ep.node_addr().initialized().await;
} else {
let _ = ep.home_relay().initialized().await;
}
})
.await?;

anyhow::Ok((router, import_result, dt))
};
let (router, (temp_tag, size, collection), dt) = select! {
Expand Down
Loading