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
293 changes: 171 additions & 122 deletions Cargo.lock

Large diffs are not rendered by default.

23 changes: 11 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ anyhow = "1"
async-channel = "2.3.1"
blake3 = "1.8"
bytes = { version = "1.7", features = ["serde"] }
derive_more = { version = "1.0.0", features = [
derive_more = { version = "2.0.1", features = [
"debug",
"deref",
"display",
Expand All @@ -26,17 +26,17 @@ derive_more = { version = "1.0.0", features = [
"into",
"as_ref",
] }
ed25519-dalek = { version = "2.0.0", features = ["serde", "rand_core"] }
ed25519-dalek = { version = "3.0.0-pre.1", features = ["serde", "rand_core"] }
futures-buffered = "0.2.4"
futures-lite = "2.3.0"
futures-util = { version = "0.3.25" }
hex = "0.4"
iroh = { version = "0.92" }
iroh-base = { version = "0.92", features = ["ticket"] }
iroh-blobs = { version = "0.94" }
iroh-gossip = { version = "0.92", features = ["net"] }
iroh-metrics = { version = "0.35", default-features = false }
irpc = { version = "0.8.0" }
iroh = { version = "0.93" }
iroh-base = { version = "0.93", features = ["ticket"] }
iroh-blobs = { version = "0.95" }
iroh-gossip = { version = "0.93", features = ["net"] }
iroh-metrics = { version = "0.36", default-features = false }
irpc = { version = "0.9.0" }
n0-future = "0.1.3"
num_enum = "0.7"
postcard = { version = "1", default-features = false, features = [
Expand All @@ -45,8 +45,7 @@ postcard = { version = "1", default-features = false, features = [
"experimental-derive",
] }
quinn = { package = "iroh-quinn", version = "0.14.0" }
rand = "0.8.5"
rand_core = "0.6.4"
rand = "0.9.2"
redb = { version = "2.0.0" }
redb_v1 = { package = "redb", version = "1.5.1" }
self_cell = "1.0.3"
Expand All @@ -62,11 +61,11 @@ tracing = "0.1"

[dev-dependencies]
data-encoding = "2.6.0"
iroh = { version = "0.92", features = ["test-utils"] }
iroh = { version = "0.93", features = ["test-utils"] }
nested_enum_utils = "0.1.0"
parking_lot = "0.12.3"
proptest = "1.2.0"
rand_chacha = "0.3.1"
rand_chacha = "0.9"
tempfile = "3.4"
test-strategy = "0.4"
testdir = "0.7"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ async fn main() -> anyhow::Result<()> {

// setup router
let _router = builder
.accept(BLOBS_ALPN, BlobsProtocol::new(&blobs, endpoint.clone(), None))
.accept(BLOBS_ALPN, BlobsProtocol::new(&blobs, None))
.accept(GOSSIP_ALPN, gossip)
.accept(DOCS_ALPN, docs)
.spawn();
Expand Down
62 changes: 30 additions & 32 deletions deny.toml
Original file line number Diff line number Diff line change
@@ -1,43 +1,41 @@
[advisories]
ignore = [
"RUSTSEC-2024-0370",
"RUSTSEC-2024-0384",
"RUSTSEC-2024-0436",
"RUSTSEC-2023-0089",
]

[bans]
multiple-versions = "allow"
deny = [
"aws-lc",
"aws-lc-rs",
"aws-lc-sys",
"native-tls",
"openssl",
"aws-lc",
"aws-lc-rs",
"aws-lc-sys",
"native-tls",
"openssl",
]
multiple-versions = "allow"

[licenses]
allow = [
"Apache-2.0",
"Apache-2.0 WITH LLVM-exception",
"BSD-2-Clause",
"BSD-3-Clause",
"BSL-1.0", # BOSL license
"CDLA-Permissive-2.0",
"ISC",
"MIT",
"Zlib",
"MPL-2.0", # https://fossa.com/blog/open-source-software-licenses-101-mozilla-public-license-2-0/
"Unicode-3.0",
"Unlicense" # https://unlicense.org/
"Apache-2.0",
"Apache-2.0 WITH LLVM-exception",
"BSD-2-Clause",
"BSD-3-Clause",
"BSL-1.0",
"CDLA-Permissive-2.0",
"ISC",
"MIT",
"Zlib",
"MPL-2.0",
"Unicode-3.0",
"Unlicense",
]

[[licenses.clarify]]
name = "ring"
expression = "MIT AND ISC AND OpenSSL"
license-files = [
{ path = "LICENSE", hash = 0xbd0eed23 },
]

[advisories]
ignore = [
"RUSTSEC-2024-0370", # unmaintained, no upgrade available
"RUSTSEC-2024-0384", # unmaintained, no upgrade available
"RUSTSEC-2024-0436", # paste
"RUSTSEC-2023-0089", # unmainatined: postcard -> heapless -> atomic-polyfill
]
name = "ring"

[sources]
allow-git = []
[[licenses.clarify.license-files]]
hash = 3171872035
path = "LICENSE"
5 changes: 1 addition & 4 deletions examples/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ async fn main() -> anyhow::Result<()> {

// setup router
let _router = builder
.accept(
BLOBS_ALPN,
BlobsProtocol::new(&blobs, endpoint.clone(), None),
)
.accept(BLOBS_ALPN, BlobsProtocol::new(&blobs, None))
.accept(GOSSIP_ALPN, gossip)
.accept(DOCS_ALPN, docs)
.spawn();
Expand Down
2 changes: 1 addition & 1 deletion src/actor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1061,7 +1061,7 @@ mod tests {
async fn open_close() -> anyhow::Result<()> {
let store = store::Store::memory();
let sync = SyncHandle::spawn(store, None, "foo".into());
let namespace = NamespaceSecret::new(&mut rand::rngs::OsRng {});
let namespace = NamespaceSecret::new(&mut rand::rng());
let id = namespace.id();
sync.import_namespace(namespace.into()).await?;
sync.open(id, Default::default()).await?;
Expand Down
62 changes: 32 additions & 30 deletions src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,35 +81,37 @@ impl DocsApi {
.context("cannot listen on remote API")?;
let handler: Handler<DocsProtocol> = Arc::new(move |msg, _rx, tx| {
let local = local.clone();
Box::pin(match msg {
DocsProtocol::Open(msg) => local.send((msg, tx)),
DocsProtocol::Close(msg) => local.send((msg, tx)),
DocsProtocol::Status(msg) => local.send((msg, tx)),
DocsProtocol::List(msg) => local.send((msg, tx)),
DocsProtocol::Create(msg) => local.send((msg, tx)),
DocsProtocol::Drop(msg) => local.send((msg, tx)),
DocsProtocol::Import(msg) => local.send((msg, tx)),
DocsProtocol::Set(msg) => local.send((msg, tx)),
DocsProtocol::SetHash(msg) => local.send((msg, tx)),
DocsProtocol::Get(msg) => local.send((msg, tx)),
DocsProtocol::GetExact(msg) => local.send((msg, tx)),
// DocsProtocol::ImportFile(msg) => local.send((msg, tx)),
// DocsProtocol::ExportFile(msg) => local.send((msg, tx)),
DocsProtocol::Del(msg) => local.send((msg, tx)),
DocsProtocol::StartSync(msg) => local.send((msg, tx)),
DocsProtocol::Leave(msg) => local.send((msg, tx)),
DocsProtocol::Share(msg) => local.send((msg, tx)),
DocsProtocol::Subscribe(msg) => local.send((msg, tx)),
DocsProtocol::GetDownloadPolicy(msg) => local.send((msg, tx)),
DocsProtocol::SetDownloadPolicy(msg) => local.send((msg, tx)),
DocsProtocol::GetSyncPeers(msg) => local.send((msg, tx)),
DocsProtocol::AuthorList(msg) => local.send((msg, tx)),
DocsProtocol::AuthorCreate(msg) => local.send((msg, tx)),
DocsProtocol::AuthorGetDefault(msg) => local.send((msg, tx)),
DocsProtocol::AuthorSetDefault(msg) => local.send((msg, tx)),
DocsProtocol::AuthorImport(msg) => local.send((msg, tx)),
DocsProtocol::AuthorExport(msg) => local.send((msg, tx)),
DocsProtocol::AuthorDelete(msg) => local.send((msg, tx)),
Box::pin(async move {
match msg {
DocsProtocol::Open(msg) => local.send((msg, tx)).await,
DocsProtocol::Close(msg) => local.send((msg, tx)).await,
DocsProtocol::Status(msg) => local.send((msg, tx)).await,
DocsProtocol::List(msg) => local.send((msg, tx)).await,
DocsProtocol::Create(msg) => local.send((msg, tx)).await,
DocsProtocol::Drop(msg) => local.send((msg, tx)).await,
DocsProtocol::Import(msg) => local.send((msg, tx)).await,
DocsProtocol::Set(msg) => local.send((msg, tx)).await,
DocsProtocol::SetHash(msg) => local.send((msg, tx)).await,
DocsProtocol::Get(msg) => local.send((msg, tx)).await,
DocsProtocol::GetExact(msg) => local.send((msg, tx)).await,
// DocsProtocol::ImportFile(msg) => local.send((msg, tx)).await,
// DocsProtocol::ExportFile(msg) => local.send((msg, tx)).await,
DocsProtocol::Del(msg) => local.send((msg, tx)).await,
DocsProtocol::StartSync(msg) => local.send((msg, tx)).await,
DocsProtocol::Leave(msg) => local.send((msg, tx)).await,
DocsProtocol::Share(msg) => local.send((msg, tx)).await,
DocsProtocol::Subscribe(msg) => local.send((msg, tx)).await,
DocsProtocol::GetDownloadPolicy(msg) => local.send((msg, tx)).await,
DocsProtocol::SetDownloadPolicy(msg) => local.send((msg, tx)).await,
DocsProtocol::GetSyncPeers(msg) => local.send((msg, tx)).await,
DocsProtocol::AuthorList(msg) => local.send((msg, tx)).await,
DocsProtocol::AuthorCreate(msg) => local.send((msg, tx)).await,
DocsProtocol::AuthorGetDefault(msg) => local.send((msg, tx)).await,
DocsProtocol::AuthorSetDefault(msg) => local.send((msg, tx)).await,
DocsProtocol::AuthorImport(msg) => local.send((msg, tx)).await,
DocsProtocol::AuthorExport(msg) => local.send((msg, tx)).await,
DocsProtocol::AuthorDelete(msg) => local.send((msg, tx)).await,
}
})
});
let join_handle = task::spawn(irpc::rpc::listen(endpoint, handler));
Expand Down Expand Up @@ -634,7 +636,7 @@ impl Stream for ImportFileProgress {
.take()
.expect("AddProgressItem::Done may be emitted only once");
let size = size.expect("Size must be emitted before done");
let hash = *tag.hash();
let hash = tag.hash();
*this = Self(ImportInner::Entry(Box::pin(async move {
doc.set_hash(author, key.clone(), hash, size).await?;
Ok(ImportFileOutcome { hash, size, key })
Expand Down
9 changes: 4 additions & 5 deletions src/api/actor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use std::sync::Arc;

use anyhow::anyhow;
use futures_lite::StreamExt;
use iroh::Watcher;
use irpc::{channel::mpsc, LocalSender, WithChannels};
use n0_future::task::{self};
use tokio::sync::mpsc as tokio_mpsc;
Expand Down Expand Up @@ -241,7 +240,7 @@ impl RpcActor {
_req: AuthorCreateRequest,
) -> RpcResult<AuthorCreateResponse> {
// TODO: pass rng
let author = Author::new(&mut rand::rngs::OsRng {});
let author = Author::new(&mut rand::rng());
self.sync
.import_author(author.clone())
.await
Expand Down Expand Up @@ -322,7 +321,7 @@ impl RpcActor {
}

pub(super) async fn doc_create(&self, _req: CreateRequest) -> RpcResult<CreateResponse> {
let namespace = NamespaceSecret::new(&mut rand::rngs::OsRng {});
let namespace = NamespaceSecret::new(&mut rand::rng());
let id = namespace.id();
self.sync
.import_namespace(namespace.into())
Expand Down Expand Up @@ -390,7 +389,7 @@ impl RpcActor {
mode,
addr_options,
} = req;
let me = self.endpoint.node_addr().initialized().await;
let me = self.endpoint.node_addr();
let me = addr_options.apply(&me);

let capability = match mode {
Expand Down Expand Up @@ -498,7 +497,7 @@ impl RpcActor {
.await
.map_err(|e| RpcError::new(&e))?;
self.sync
.insert_local(doc_id, author_id, key.clone(), *tag.hash(), len as u64)
.insert_local(doc_id, author_id, key.clone(), tag.hash(), len as u64)
.await
.map_err(|e| RpcError::new(&*e))?;
let entry = self
Expand Down
6 changes: 3 additions & 3 deletions src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ impl Engine {
protect_cb: Option<ProtectCallbackHandler>,
) -> anyhow::Result<Self> {
let (live_actor_tx, to_live_actor_recv) = mpsc::channel(ACTOR_CHANNEL_CAP);
let me = endpoint.node_id().fmt_short();
let me = endpoint.node_id().fmt_short().to_string();

let content_status_cb: ContentStatusCallback = {
let blobs = bao_store.blobs().clone();
Expand Down Expand Up @@ -368,7 +368,7 @@ impl DefaultAuthorStorage {
pub async fn load(&self, docs_store: &SyncHandle) -> anyhow::Result<AuthorId> {
match self {
Self::Mem => {
let author = Author::new(&mut rand::thread_rng());
let author = Author::new(&mut rand::rng());
let author_id = author.id();
docs_store.import_author(author).await?;
Ok(author_id)
Expand All @@ -392,7 +392,7 @@ impl DefaultAuthorStorage {
}
Ok(author_id)
} else {
let author = Author::new(&mut rand::thread_rng());
let author = Author::new(&mut rand::rng());
let author_id = author.id();
docs_store.import_author(author).await?;
// Make sure to write the default author to the store
Expand Down
4 changes: 2 additions & 2 deletions src/engine/live.rs
Original file line number Diff line number Diff line change
Expand Up @@ -971,10 +971,10 @@ impl Subscribers {

fn fmt_accept_peer(res: &Result<SyncFinished, AcceptError>) -> String {
match res {
Ok(res) => res.peer.fmt_short(),
Ok(res) => res.peer.fmt_short().to_string(),
Err(err) => err
.peer()
.map(|x| x.fmt_short())
.map(|x| x.fmt_short().to_string())
.unwrap_or_else(|| "unknown".to_string()),
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use std::{cmp::Ordering, fmt, str::FromStr};

use ed25519_dalek::{Signature, SignatureError, Signer, SigningKey, VerifyingKey};
use rand_core::CryptoRngCore;
use rand::CryptoRng;
use serde::{Deserialize, Serialize};

use crate::store::PublicKeyStore;
Expand All @@ -17,7 +17,7 @@ pub struct Author {
}
impl Author {
/// Create a new [`Author`] with a random key.
pub fn new<R: CryptoRngCore + ?Sized>(rng: &mut R) -> Self {
pub fn new<R: CryptoRng>(rng: &mut R) -> Self {
let signing_key = SigningKey::generate(rng);
Author { signing_key }
}
Expand Down Expand Up @@ -93,7 +93,7 @@ pub struct NamespaceSecret {

impl NamespaceSecret {
/// Create a new [`NamespaceSecret`] with a random key.
pub fn new<R: CryptoRngCore + ?Sized>(rng: &mut R) -> Self {
pub fn new<R: CryptoRng>(rng: &mut R) -> Self {
let signing_key = SigningKey::generate(rng);

NamespaceSecret { signing_key }
Expand Down
6 changes: 3 additions & 3 deletions src/net/codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ mod tests {
use anyhow::Result;
use iroh::SecretKey;
use iroh_blobs::Hash;
use rand_core::{CryptoRngCore, SeedableRng};
use rand::{CryptoRng, SeedableRng};
use tracing_test::traced_test;

use super::*;
Expand All @@ -308,7 +308,7 @@ mod tests {

#[tokio::test]
async fn test_sync_simple() -> Result<()> {
let mut rng = rand::thread_rng();
let mut rng = rand::rng();
let alice_peer_id = SecretKey::from_bytes(&[1u8; 32]).public();
let bob_peer_id = SecretKey::from_bytes(&[2u8; 32]).public();

Expand Down Expand Up @@ -439,7 +439,7 @@ mod tests {
type Message = (AuthorId, Vec<u8>, Hash);

fn insert_messages(
mut rng: impl CryptoRngCore,
mut rng: impl CryptoRng,
replica: &mut crate::sync::Replica,
num_authors: usize,
msgs_per_author: usize,
Expand Down
Loading
Loading