Skip to content

Commit db6fc81

Browse files
authored
Merge pull request #22 from n0-computer/content-discovery
Content discovery
2 parents ad0c2b5 + dfbbbc4 commit db6fc81

File tree

25 files changed

+247
-138
lines changed

25 files changed

+247
-138
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ env:
1313
RUSTFLAGS: -Dwarnings
1414
RUSTDOCFLAGS: -Dwarnings
1515
MSRV: "1.72"
16-
RS_EXAMPLES_LIST: "iroh-mainline-content-discovery,iroh-ipfs,dumbpipe-web,iroh-pkarr-node-discovery"
16+
RS_EXAMPLES_LIST: "content-discovery,iroh-ipfs,dumbpipe-web,iroh-pkarr-node-discovery"
1717
GO_EXAMPLES_LIST: "dall_e_worker"
1818

1919
jobs:
File renamed without changes.

iroh-mainline-content-discovery/Cargo.lock renamed to content-discovery/Cargo.lock

Lines changed: 35 additions & 49 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

iroh-mainline-content-discovery/Cargo.toml renamed to content-discovery/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[workspace]
22
members = [
33
"iroh-mainline-content-discovery",
4+
"iroh-mainline-content-discovery-cli",
45
"iroh-mainline-tracker",
56
]
67
resolver = "2"

iroh-mainline-content-discovery/README.md renamed to content-discovery/README.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
# Iroh content discovery
22

3-
This library provides global content discovery for iroh.
3+
This rust workspace provides global content discovery for iroh.
4+
5+
*iroh-mainline-content-discovery* is a library that provides a discovery protocol,
6+
a client implementation, and a client command line utility.
7+
8+
*iroh-mainline-tracker* is a server implementation for the content discovery
9+
protocol.
410

511
## Building from source
612

@@ -9,12 +15,12 @@ Make sure you have an up to date version of [rust](https://www.rust-lang.org/) i
915
`cargo` for your platform.
1016

1117
Then run `cargo build --release` from the root directory. The resulting binary
12-
will be in `target/release/tracker`
18+
will be in `target/release/iroh-mainline-tracker`
1319

1420
## Running the tracker
1521

1622
```sh
17-
tracker server
23+
iroh-mainline-tracker
1824
```
1925

2026
Will run the server with a persistent node id and announce information.
@@ -24,7 +30,7 @@ Will run the server with a persistent node id and announce information.
2430
When announcing content, you can give either iroh tickets or content hashes.
2531

2632
```sh
27-
tracker announce \
33+
iroh-mainline-content-discovery announce \
2834
--tracker t3od3nblvk6csozc3oe7rjum7oebnnwwfkebolbxf2o66clzdyha \
2935
blob:ealcoyhcjxyklzee4manl3b5see3k3nwekf6npw5oollcsflrsduiaicaiafetezhwjouayaycuadbes5ibqaq7qasiyqmqo74ijal7k7ec4pni5htntx4tpoawgvmbhaa3txa4uaa
3036
```
@@ -36,7 +42,7 @@ When querying content, you can use tickets, hashes, or hash and format.
3642
When using tickets, the address part of the ticket will be ignored.
3743

3844
```sh
39-
tracker query \
45+
iroh-mainline-content-discovery query \
4046
--tracker t3od3nblvk6csozc3oe7rjum7oebnnwwfkebolbxf2o66clzdyha \
4147
blob:ealcoyhcjxyklzee4manl3b5see3k3nwekf6npw5oollcsflrsduiaicaiafetezhwjouayaycuadbes5ibqaq7qasiyqmqo74ijal7k7ec4pni5htntx4tpoawgvmbhaa3txa4uaa
4248
```
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
[package]
2+
name = "iroh-mainline-content-discovery-cli"
3+
version = "0.3.0"
4+
edition = "2021"
5+
description = "Content discovery for iroh, using the bittorrent mainline DHT"
6+
license = "MIT OR Apache-2.0"
7+
8+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
9+
10+
[dependencies]
11+
iroh-net = "0.12.0"
12+
iroh-bytes = "0.12.0"
13+
iroh-mainline-content-discovery = { path = "../iroh-mainline-content-discovery" }
14+
quinn = { version = "0.10" }
15+
iroh-pkarr-node-discovery = { version = "0.1.2" }
16+
mainline = { version = "1.0.0" }
17+
anyhow = { version = "1", features = ["backtrace"] }
18+
futures = { version = "0.3.25" }
19+
clap = { version = "4", features = ["derive"] }
20+
tempfile = { version = "3.4" }
21+
derive_more = { version = "1.0.0-beta.1", features = ["debug", "display", "from", "try_into"] }
22+
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
23+
tokio = { version = "1", features = ["io-util", "rt"] }

iroh-mainline-content-discovery/iroh-mainline-content-discovery/src/args.rs renamed to content-discovery/iroh-mainline-content-discovery-cli/src/args.rs

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ pub struct Args {
1515
pub enum Commands {
1616
Announce(AnnounceArgs),
1717
Query(QueryArgs),
18+
QueryDht(QueryDhtArgs),
1819
}
1920

2021
/// Various ways to specify content.
@@ -80,10 +81,6 @@ pub struct AnnounceArgs {
8081
#[clap(long)]
8182
pub tracker: NodeId,
8283

83-
/// the port to use for announcing
84-
#[clap(long)]
85-
pub port: Option<u16>,
86-
8784
/// The host to announce. Not needed if content is a ticket.
8885
#[clap(long)]
8986
pub host: Option<NodeId>,
@@ -98,17 +95,36 @@ pub struct AnnounceArgs {
9895
/// Announce that the peer has only partial data.
9996
#[clap(long)]
10097
pub partial: bool,
98+
99+
/// the port to use for announcing
100+
#[clap(long)]
101+
pub magic_port: Option<u16>,
101102
}
102103

103104
#[derive(Parser, Debug)]
104105
pub struct QueryArgs {
106+
/// the tracker to query
105107
#[clap(long)]
106108
pub tracker: TrackerId,
107109

110+
/// The content to find hosts for.
111+
pub content: ContentArg,
112+
113+
/// Ask for hosts that were announced as having just partial data
114+
#[clap(long)]
115+
pub partial: bool,
116+
117+
/// Ask for hosts that were recently checked and found to have some data
118+
#[clap(long)]
119+
pub verified: bool,
120+
108121
/// the port to use for querying
109122
#[clap(long)]
110-
pub port: Option<u16>,
123+
pub magic_port: Option<u16>,
124+
}
111125

126+
#[derive(Parser, Debug)]
127+
pub struct QueryDhtArgs {
112128
/// The content to find hosts for.
113129
pub content: ContentArg,
114130

@@ -119,4 +135,12 @@ pub struct QueryArgs {
119135
/// Ask for hosts that were recently checked and found to have some data
120136
#[clap(long)]
121137
pub verified: bool,
138+
139+
/// Parallelism for querying the dht
140+
#[clap(long)]
141+
pub query_parallelism: Option<usize>,
142+
143+
/// the port to use for querying
144+
#[clap(long)]
145+
pub quinn_port: Option<u16>,
122146
}

0 commit comments

Comments
 (0)