Skip to content
Merged
Show file tree
Hide file tree
Changes from 13 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
10 changes: 9 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ iroh-metrics = { path = "./iroh-metrics" }
iroh-test = { path = "./iroh-test" }
iroh-router = { path = "./iroh-router" }

iroh-blobs = { git = "https://github.com/n0-computer/iroh-blobs", branch = "main" }
# iroh-blobs = { git = "https://github.com/n0-computer/iroh-blobs", branch = "main" }
iroh-gossip = { git = "https://github.com/n0-computer/iroh-gossip", branch = "main" }
iroh-docs = { git = "https://github.com/n0-computer/iroh-docs", branch = "main" }
iroh-blobs = { git = "https://github.com/n0-computer/iroh-blobs", branch = "add-rpc" }
8 changes: 5 additions & 3 deletions iroh-cli/src/commands/blobs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use iroh::{
base::{node_addr::AddrInfoOptions, ticket::BlobTicket},
blobs::{
get::{db::DownloadProgress, progress::BlobProgress, Stats},
net_protocol::DownloadMode,
provider::AddProgress,
store::{
ConsistencyCheckProgress, ExportFormat, ExportMode, ReportLevel, ValidateProgress,
Expand All @@ -28,8 +29,7 @@ use iroh::{
},
client::{
blobs::{
BlobInfo, BlobStatus, CollectionInfo, DownloadMode, DownloadOptions,
IncompleteBlobInfo, WrapOption,
BlobInfo, BlobStatus, CollectionInfo, DownloadOptions, IncompleteBlobInfo, WrapOption,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will probably go away if docs are removed as well.

},
Iroh,
},
Expand Down Expand Up @@ -370,7 +370,9 @@ impl BlobCommands {
BlobFormat::Raw
};
let status = iroh.blobs().status(hash).await?;
let ticket = iroh.blobs().share(hash, format, addr_options).await?;
let mut addr: NodeAddr = iroh.net().node_addr().await?;
addr.apply_options(addr_options);
let ticket = BlobTicket::new(addr, hash, format)?;

let (blob_status, size) = match (status, format) {
(BlobStatus::Complete { size }, BlobFormat::Raw) => ("blob", size),
Expand Down
4 changes: 2 additions & 2 deletions iroh-dns-server/src/http/rate_limiting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ pub enum RateLimitConfig {
/// Disable rate limit for http server.
Disabled,
/// Enable rate limit for http server based on the connection peer IP address.
/// https://docs.rs/tower_governor/latest/tower_governor/key_extractor/struct.PeerIpKeyExtractor.html
/// <https://docs.rs/tower_governor/latest/tower_governor/key_extractor/struct.PeerIpKeyExtractor.html>
#[default]
Simple,
/// Enable rate limit for http server based on a smart logic for extracting the connection original IP address, useful for reverse proxies.
/// https://docs.rs/tower_governor/latest/tower_governor/key_extractor/struct.SmartIpKeyExtractor.html
/// <https://docs.rs/tower_governor/latest/tower_governor/key_extractor/struct.SmartIpKeyExtractor.html>
Smart,
}

Expand Down
13 changes: 4 additions & 9 deletions iroh/examples/collection-provide.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//! run this example from the project root:
//! $ cargo run --example collection-provide
use iroh::blobs::{format::collection::Collection, util::SetTagOption, BlobFormat};
use iroh_base::node_addr::AddrInfoOptions;
use iroh_base::{node_addr::AddrInfoOptions, ticket::BlobTicket};
use tracing_subscriber::{prelude::*, EnvFilter};

// set the RUST_LOG env var to one of {debug,info,warn} to see logging info
Expand Down Expand Up @@ -44,14 +44,9 @@ async fn main() -> anyhow::Result<()> {

// create a ticket
// tickets wrap all details needed to get a collection
let ticket = node
.blobs()
.share(
hash,
BlobFormat::HashSeq,
AddrInfoOptions::RelayAndAddresses,
)
.await?;
let mut addr = node.net().node_addr().await?;
addr.apply_options(AddrInfoOptions::RelayAndAddresses);
let ticket = BlobTicket::new(addr, hash, BlobFormat::HashSeq)?;

// print some info about the node
println!("serving hash: {}", ticket.hash());
Expand Down
2 changes: 1 addition & 1 deletion iroh/examples/custom-protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ async fn main() -> Result<()> {

// Print out our query results.
for hash in hashes {
read_and_print(node.blobs(), hash).await?;
read_and_print(&node.blobs(), hash).await?;
}
}
}
Expand Down
9 changes: 4 additions & 5 deletions iroh/examples/hello-world-provide.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//! This is using an in memory database and a random node id.
//! run this example from the project root:
//! $ cargo run --example hello-world-provide
use iroh_base::node_addr::AddrInfoOptions;
use iroh_base::{node_addr::AddrInfoOptions, ticket::BlobTicket};
use tracing_subscriber::{prelude::*, EnvFilter};

// set the RUST_LOG env var to one of {debug,info,warn} to see logging info
Expand All @@ -27,10 +27,9 @@ async fn main() -> anyhow::Result<()> {
let res = node.blobs().add_bytes("Hello, world!").await?;

// create a ticket
let ticket = node
.blobs()
.share(res.hash, res.format, AddrInfoOptions::RelayAndAddresses)
.await?;
let mut addr = node.net().node_addr().await?;
addr.apply_options(AddrInfoOptions::RelayAndAddresses);
let ticket = BlobTicket::new(addr, res.hash, res.format)?;

// print some info about the node
println!("serving hash: {}", ticket.hash());
Expand Down
12 changes: 4 additions & 8 deletions iroh/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use std::collections::BTreeMap;

use anyhow::Result;
use futures_lite::{Stream, StreamExt};
use quic_rpc::client::BoxedServiceConnection;
use ref_cast::RefCast;

use crate::rpc_protocol::node::{CounterStats, ShutdownRequest, StatsRequest, StatusRequest};
Expand All @@ -24,9 +23,6 @@ pub mod docs;
pub mod net;
pub mod tags;

/// Iroh rpc connection - boxed so that we can have a concrete type.
pub(crate) type RpcConnection = BoxedServiceConnection<RpcService>;

// Keep this type exposed, otherwise every occurrence of `RpcClient` in the API
// will show up as `RpcClient<RpcService, Connection<RpcService>>` in the docs.
/// Iroh rpc client - boxed so that we can have a concrete type.
Expand Down Expand Up @@ -60,8 +56,8 @@ impl Iroh {
}

/// Returns the blobs client.
pub fn blobs(&self) -> &blobs::Client {
blobs::Client::ref_cast(&self.rpc)
pub fn blobs(&self) -> blobs::Client {
blobs::Client::new(self.rpc.clone().map())
}

/// Returns the docs client.
Expand All @@ -75,8 +71,8 @@ impl Iroh {
}

/// Returns the tags client.
pub fn tags(&self) -> &tags::Client {
tags::Client::ref_cast(&self.rpc)
pub fn tags(&self) -> tags::Client {
tags::Client::new(self.rpc.clone().map())
}

/// Returns the gossip client.
Expand Down
Loading
Loading