Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Publish self-announces as pkarr signed packets through the derper #2052

Open
wants to merge 66 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
09a7973
feat: combine discovery services
Frando Mar 4, 2024
a088781
refactor: impl from iterator for combined discovery
Frando Mar 6, 2024
42f1f3b
tests: add tests for combined discovery
Frando Mar 6, 2024
8bd2ea3
chore: fmt
Frando Mar 6, 2024
6008c66
chore: fix doc link
Frando Mar 6, 2024
5a0fd66
chore: clippy
Frando Mar 6, 2024
4c81604
refactor: better controls for discovery tasks
Frando Mar 7, 2024
19e9ae7
cleanup
Frando Mar 7, 2024
2db91c8
docs and cleanup
Frando Mar 7, 2024
ed52ced
more docs
Frando Mar 7, 2024
25c847b
chore: clippy & doclinks
Frando Mar 7, 2024
b5f9728
better tracing logs
Frando Mar 7, 2024
adbc41f
fix instrumentation
Frando Mar 7, 2024
9d62fea
refactor: do not require static lifetime on discovery streams
Frando Mar 7, 2024
b5d5d55
chore: clippy
Frando Mar 7, 2024
b380b19
rename to ConcurrentDiscovery
Frando Mar 7, 2024
9383427
chore: doc link
Frando Mar 7, 2024
646de44
feat: add iroh-dns crate
Frando Feb 27, 2024
ae3e0e7
feat: discover nodes over DNS by default
Frando Feb 27, 2024
89fffc9
fix: only republish if derp url changes
Frando Feb 27, 2024
8f26558
fix(iroh-dns): do not log secret key
Frando Feb 27, 2024
58ad6f5
feat: allow to connect via node id only
Frando Feb 27, 2024
04611f2
fix: feature flags
Frando Feb 27, 2024
6ee0f97
chore: fmt
Frando Feb 27, 2024
aa4cd94
chore: fmt and clippy
Frando Feb 27, 2024
3839856
chore: remove obsolete files
Frando Feb 27, 2024
d257c0b
refactor: use z32 encoding for pkarr domain names
Frando Feb 28, 2024
b4b85de
refactor: cleanup
Frando Mar 4, 2024
1389d44
refactor: move iroh-dns into iroh-net, add docs, cleanup
Frando Mar 7, 2024
785c79b
Merge remote-tracking branch 'origin/main' into feat/dns
Frando Mar 18, 2024
9f21f40
fix: make NodeDiscoveryConfig pub
Frando Mar 18, 2024
44c5cc6
chore: fmt
Frando Mar 18, 2024
be08b9b
cleanup: better namings
Frando Mar 18, 2024
e0012b5
fix Cargo.lock after rebase
Frando Mar 18, 2024
d339b5c
Merge branch 'main' into feat/dns
Frando Mar 18, 2024
6c17aea
Merge branch 'main' into feat/dns
Frando Mar 21, 2024
0c47f28
tests: add tests for DNS discovery
Frando Mar 21, 2024
3531449
refactor: cleanup dns tests
Frando Mar 21, 2024
1932c5c
chore: clippy
Frando Mar 21, 2024
443285b
refactor: make pkarr relay client reusable for derper
Frando Mar 21, 2024
c819958
Merge remote-tracking branch 'origin/main' into feat/dns
Frando Mar 21, 2024
e519f8d
rebase fixup
Frando Mar 21, 2024
7ccae59
chore: clippy & doclinks
Frando Mar 21, 2024
c3e8f0a
Merge remote-tracking branch 'origin/main' into feat/dns
Frando Mar 25, 2024
f798084
refactor: use DNS resolver from MagicEndpoint
Frando Mar 25, 2024
a7f8ea0
Merge remote-tracking branch 'origin/main' into feat/dns
Frando Mar 25, 2024
ce48317
tests: add end-to-end test
Frando Mar 25, 2024
d1465f7
fixup
Frando Mar 25, 2024
c7cab05
Merge remote-tracking branch 'origin/main' into feat/dns
Frando Mar 25, 2024
536e3bd
cleanup
Frando Mar 25, 2024
9e5759d
cleanup
Frando Mar 25, 2024
180a651
chore: clippy
Frando Mar 25, 2024
877de7e
chore: clippy
Frando Mar 25, 2024
5d9df01
tests: improve dns discovery tests
Frando Mar 25, 2024
428f811
tests: increase timeout because windows is slow
Frando Mar 26, 2024
a21eadf
remove debug leftovers
Frando Mar 26, 2024
e12180a
Merge remote-tracking branch 'origin/main' into feat/dns
Frando Mar 26, 2024
c3252b6
Update iroh-net/src/discovery/dns.rs
Frando Mar 28, 2024
3d14417
Merge remote-tracking branch 'origin/main' into feat/dns
Frando Apr 2, 2024
c472a2f
feat: publish pkarr self-announces through the derper
Frando Mar 1, 2024
5161341
fix and test after rebase
Frando Mar 25, 2024
1371c06
fix and test after rebase
Frando Mar 25, 2024
1db876d
wait enough
Frando Mar 25, 2024
a8e3bf6
tests: improve dns discovery tests
Frando Mar 25, 2024
db0f8cd
tests: fix after rebase
Frando Mar 25, 2024
d9dc571
tests: increase timeout because windows is slow
Frando Mar 26, 2024
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
131 changes: 126 additions & 5 deletions Cargo.lock

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

12 changes: 12 additions & 0 deletions iroh-base/src/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,12 @@ impl From<VerifyingKey> for PublicKey {
}
}

impl From<PublicKey> for VerifyingKey {
fn from(value: PublicKey) -> Self {
value.public()
}
}

impl Debug for PublicKey {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "PublicKey({})", base32::fmt_short(self.as_bytes()))
Expand Down Expand Up @@ -391,6 +397,12 @@ impl From<SigningKey> for SecretKey {
}
}

impl From<SecretKey> for SigningKey {
fn from(secret: SecretKey) -> Self {
secret.secret
}
}

impl From<[u8; 32]> for SecretKey {
fn from(value: [u8; 32]) -> Self {
Self::from_bytes(&value)
Expand Down
14 changes: 13 additions & 1 deletion iroh-base/src/node_addr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use anyhow::Context;
use serde::{Deserialize, Serialize};
use url::Url;

use crate::key::PublicKey;
use crate::key::{NodeId, PublicKey};

/// A peer and it's addressing information.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
Expand Down Expand Up @@ -63,6 +63,12 @@ impl From<(PublicKey, Option<RelayUrl>, &[SocketAddr])> for NodeAddr {
}
}

impl From<NodeId> for NodeAddr {
fn from(node_id: NodeId) -> Self {
NodeAddr::new(node_id)
}
}

/// Addressing information to connect to a peer.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Default)]
pub struct AddrInfo {
Expand Down Expand Up @@ -142,6 +148,12 @@ impl FromStr for RelayUrl {
}
}

impl From<RelayUrl> for Url {
fn from(value: RelayUrl) -> Self {
value.0
}
}

/// Dereference to the wrapped [`Url`].
///
/// Note that [`DerefMut`] is not implemented on purpose, so this type has more flexibility
Expand Down
5 changes: 0 additions & 5 deletions iroh-cli/src/commands/blob.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,11 +236,6 @@ impl BlobCommands {
return Err(anyhow::anyhow!("The input arguments refer to a collection of blobs and output is set to STDOUT. Only single blobs may be passed in this case."));
}

if node_addr.info.is_empty() {
return Err(anyhow::anyhow!(
"no relay url provided and no direct addresses provided"
));
}
let tag = match tag {
Some(tag) => SetTagOption::Named(Tag::from(tag)),
None => SetTagOption::Auto,
Expand Down
6 changes: 5 additions & 1 deletion iroh-net/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ flume = "0.11"
futures = "0.3.25"
governor = "0.6.0"
hex = "0.4.3"
hickory-proto = "0.24.0"
hickory-resolver = "0.24.0"
hostname = "0.3.1"
http = "1"
http-body-util = "0.1.0"
Expand All @@ -40,6 +42,7 @@ libc = "0.2.139"
num_enum = "0.7"
once_cell = "1.18.0"
parking_lot = "0.12.1"
pkarr = { version = "1.1.3", default-features = false, features = ["async", "relay"] }
postcard = { version = "1", default-features = false, features = ["alloc", "use-std", "experimental-derive"] }
quinn = "0.10"
quinn-proto = "0.10.5"
Expand All @@ -65,12 +68,12 @@ tokio-rustls = { version = "0.24" }
tokio-rustls-acme = { version = "0.2" }
tokio-util = { version = "0.7", features = ["io-util", "io", "codec"] }
tracing = "0.1"
hickory-resolver = "0.24.0"
url = { version = "2.4", features = ["serde"] }
watchable = "1.1.2"
webpki = { package = "rustls-webpki", version = "0.101.4", features = ["std"] }
webpki-roots = "0.25"
x509-parser = "0.15"
z32 = "1.0.3"

# iroh-relay
clap = { version = "4", features = ["derive"], optional = true }
Expand Down Expand Up @@ -106,6 +109,7 @@ tokio = { version = "1", features = ["io-util", "sync", "rt", "net", "fs", "macr
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
iroh-test = { path = "../iroh-test" }
serde_json = "1.0.107"
axum = "0.7.4"

[[bench]]
name = "key"
Expand Down
8 changes: 8 additions & 0 deletions iroh-net/src/bin/iroh-relay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ use tracing::{debug, debug_span, error, info, info_span, trace, warn, Instrument
use tracing_subscriber::{prelude::*, EnvFilter};

use metrics::StunMetrics;
use url::Url;

type BytesBody = http_body_util::Full<hyper::body::Bytes>;
type HyperError = Box<dyn std::error::Error + Send + Sync>;
Expand Down Expand Up @@ -199,6 +200,8 @@ struct Config {
#[cfg(feature = "metrics")]
/// Metrics serve address. If not set, metrics are not served.
metrics_addr: Option<SocketAddr>,
/// Pkarr relay to publish node announces to
pkarr_relay: Option<Url>,
}

#[derive(Serialize, Deserialize)]
Expand Down Expand Up @@ -249,6 +252,7 @@ impl Default for Config {
limits: None,
#[cfg(feature = "metrics")]
metrics_addr: None,
pkarr_relay: None,
}
}
}
Expand Down Expand Up @@ -451,6 +455,10 @@ async fn run(
Box::new(serve_no_content_handler),
);
}

if let Some(pkarr_relay) = cfg.pkarr_relay {
builder = builder.pkarr_relay(pkarr_relay);
}
let relay_server = builder.spawn().await?;

// captive portal detections must be served over HTTP
Expand Down
Loading
Loading