Skip to content

feat!: add iroh-relay crate #2873

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

Merged
merged 63 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
5186991
add iroh-relay member
divagant-martian Oct 30, 2024
6ac64d8
move relay files around
divagant-martian Oct 30, 2024
9e88f02
copy deps
divagant-martian Oct 30, 2024
ed44489
fix the easy imports and defaults
divagant-martian Oct 30, 2024
5a658da
move defaults to file
divagant-martian Oct 30, 2024
9b94f56
copy over utils mod
divagant-martian Oct 30, 2024
c5b491b
util instead of utils
divagant-martian Oct 30, 2024
94a0523
use util
divagant-martian Oct 31, 2024
8ae963a
migrate dns lookup code
divagant-martian Oct 31, 2024
38c6bab
lookup both ipv4 and ipv6
divagant-martian Oct 31, 2024
0d8edd5
cleanup defaults
divagant-martian Oct 31, 2024
fd467ce
remove MaybeFuture
divagant-martian Oct 31, 2024
de4d030
flatten util::chain into util
divagant-martian Oct 31, 2024
4fda530
propagate change
divagant-martian Oct 31, 2024
5ed2dac
unexpectedly need to allow imports for tests
divagant-martian Oct 31, 2024
575ed1d
move crate::relay to crate under --all-features
divagant-martian Oct 31, 2024
77a7996
more import fixes; temp enable iroh-relay feature
divagant-martian Oct 31, 2024
2f6efe8
fix more imports
divagant-martian Oct 31, 2024
eb3fa2b
move stun into relay
divagant-martian Nov 7, 2024
70749cb
relay compiles
divagant-martian Nov 7, 2024
2038374
progress in working out imports
divagant-martian Nov 7, 2024
a0f19ce
fix more imports
divagant-martian Nov 7, 2024
70ca378
fix more before moving the bin
divagant-martian Nov 7, 2024
0c61cc3
move relay bin
divagant-martian Nov 7, 2024
efeedba
remove bin from toml
divagant-martian Nov 7, 2024
296374b
toom any changes, can't remember all I did
divagant-martian Nov 7, 2024
c281af7
move more imports and feats
divagant-martian Nov 7, 2024
43c3579
fix remaining imports
divagant-martian Nov 8, 2024
e4a03ed
fix stun utils
divagant-martian Nov 8, 2024
e42f0ec
dns is only for testing
divagant-martian Nov 8, 2024
fc79de0
remove relay defaults from iroh-net
divagant-martian Nov 8, 2024
b67ac63
remove unused function
divagant-martian Nov 8, 2024
5c58e93
remove chain from utils
divagant-martian Nov 8, 2024
3457409
massive fmt
divagant-martian Nov 8, 2024
aef15fb
move relay map and mode to iroh-net
divagant-martian Nov 8, 2024
a0c869d
fix docs
divagant-martian Nov 8, 2024
291c681
move util to client, where it's exclusively used
divagant-martian Nov 8, 2024
26dfa9f
put client behind feature flag
divagant-martian Nov 8, 2024
becb128
make iroh-relay non optional
divagant-martian Nov 8, 2024
05106f9
fix example
divagant-martian Nov 8, 2024
a8ccd6f
SpEeellingG
divagant-martian Nov 8, 2024
1169fdf
first udeps pass
divagant-martian Nov 8, 2024
98a6d2b
move force_staging_infra
divagant-martian Nov 9, 2024
37c7735
adjust some feature flags for now
divagant-martian Nov 9, 2024
4a8bf41
refer to Relay metrics directly from iroh-relay
divagant-martian Nov 11, 2024
28c7a0d
add to workflows
divagant-martian Nov 11, 2024
b82ccb9
attempt to remove iroh-relay feature flag usage
divagant-martian Nov 11, 2024
0365fd5
removing more stuff
divagant-martian Nov 11, 2024
4a68d74
remove more stuff
divagant-martian Nov 11, 2024
15538b5
self review
divagant-martian Nov 11, 2024
bdeba5c
remove/address TODOs
divagant-martian Nov 11, 2024
e58b621
add README.md
divagant-martian Nov 11, 2024
90ef72c
downgrade version, fix ipv5->6
divagant-martian Nov 11, 2024
dc2387a
improve crate docs based on README plus existing credits
divagant-martian Nov 12, 2024
4da0989
improve the docs of the client mod
divagant-martian Nov 12, 2024
c450ecc
allow unmaintained instant
divagant-martian Nov 12, 2024
5464964
fix deny.toml
divagant-martian Nov 12, 2024
236d31a
restore deny.toml to main
divagant-martian Nov 12, 2024
f257292
make attribution just a comment
divagant-martian Nov 12, 2024
eef541b
fmt
divagant-martian Nov 12, 2024
3ba7ff5
Merge branch 'main' into iroh-relay-intro
divagant-martian Nov 12, 2024
33fe8c3
include in ci.yaml
divagant-martian Nov 12, 2024
a54621a
add rust version
divagant-martian Nov 12, 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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ jobs:
# uses: obi1kenobi/cargo-semver-checks-action@v2
uses: n0-computer/cargo-semver-checks-action@feat-baseline
with:
package: iroh, iroh-base, iroh-cli, iroh-dns-server, iroh-metrics, iroh-net, iroh-net-bench, iroh-router, netwatch, portmapper
package: iroh, iroh-base, iroh-cli, iroh-dns-server, iroh-metrics, iroh-net, iroh-net-bench, iroh-router, netwatch, portmapper, iroh-relay
baseline-rev: ${{ env.HEAD_COMMIT_SHA }}
use-cache: false

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ env:
RUSTFLAGS: -Dwarnings
RUSTDOCFLAGS: -Dwarnings
SCCACHE_CACHE_SIZE: "50G"
CRATES_LIST: "iroh,iroh-metrics,iroh-net,iroh-net-bench,iroh-test,iroh-cli,iroh-dns-server,iroh-router,netwatch,portmapper"
CRATES_LIST: "iroh,iroh-metrics,iroh-net,iroh-net-bench,iroh-test,iroh-cli,iroh-dns-server,iroh-router,netwatch,portmapper,iroh-relay"
IROH_FORCE_STAGING_RELAYS: "1"

jobs:
Expand Down
70 changes: 65 additions & 5 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ members = [
"iroh-test",
"iroh-net/bench",
"iroh-cli",
"iroh-relay",
"iroh-router",
"net-tools/netwatch",
"net-tools/portmapper",
Expand Down
2 changes: 1 addition & 1 deletion iroh-cli/src/commands/blobs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use iroh::{
},
Iroh,
},
net::{key::PublicKey, relay::RelayUrl, NodeAddr},
net::{key::PublicKey, NodeAddr, RelayUrl},
};
use tokio::io::AsyncWriteExt;

Expand Down
3 changes: 1 addition & 2 deletions iroh-cli/src/commands/doctor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@ use iroh::{
key::{PublicKey, SecretKey},
metrics::MagicsockMetrics,
netcheck,
relay::{RelayMap, RelayMode, RelayUrl},
ticket::NodeTicket,
Endpoint, NodeAddr, NodeId,
Endpoint, NodeAddr, NodeId, RelayMap, RelayMode, RelayUrl,
},
util::{path::IrohPaths, progress::ProgressWriter},
};
Expand Down
3 changes: 1 addition & 2 deletions iroh-cli/src/commands/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ use iroh::{
client::Iroh,
net::{
endpoint::{DirectAddrInfo, RemoteInfo},
relay::RelayUrl,
NodeAddr, NodeId,
NodeAddr, NodeId, RelayUrl,
},
};

Expand Down
2 changes: 1 addition & 1 deletion iroh-cli/src/commands/start.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use anyhow::Result;
use colored::Colorize;
use indicatif::{ProgressBar, ProgressDrawTarget, ProgressStyle};
use iroh::{
net::relay::{RelayMap, RelayMode},
net::{RelayMap, RelayMode},
node::{Node, RpcStatus, DEFAULT_RPC_ADDR},
};
use tracing::{info_span, trace, Instrument};
Expand Down
2 changes: 1 addition & 1 deletion iroh-cli/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use anyhow::{anyhow, bail, Context, Result};
use iroh::{
client::Iroh,
docs::{AuthorId, NamespaceId},
net::relay::{RelayMap, RelayNode},
net::{RelayMap, RelayNode},
node::GcPolicy,
};
use parking_lot::RwLock;
Expand Down
33 changes: 7 additions & 26 deletions iroh-net/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ workspace = true
cc = "=1.1.31" # enforce cc version, because of https://github.com/rust-lang/cc-rs/issues/1278

anyhow = { version = "1" }
axum = { version = "0.7.4", optional = true }
backoff = "0.4.0"
base64 = "0.22.1"
bytes = "1.7"
clap = { version = "4", features = ["derive"], optional = true }
der = { version = "0.7", features = ["alloc", "derive"] }
derive_more = { version = "1.0.0", features = ["debug", "display", "from", "try_into", "deref"] }
futures-buffered = "0.2.8"
Expand All @@ -40,6 +42,7 @@ hyper = { version = "1", features = ["server", "client", "http1"] }
hyper-util = "0.1.1"
igd-next = { version = "0.15.1", features = ["aio_tokio"] }
iroh-base = { version = "0.28.0", features = ["key"] }
iroh-relay = { version = "0.28", path = "../iroh-relay" }
libc = "0.2.139"
netdev = "0.30.0"
netwatch = { version = "0.1.0", path = "../net-tools/netwatch" }
Expand All @@ -55,6 +58,7 @@ quinn-proto = { package = "iroh-quinn-proto", version = "0.12.0" }
quinn-udp = { package = "iroh-quinn-udp", version = "0.5.5" }
rand = "0.8"
rcgen = "0.12"
regex = { version = "1.7.1", optional = true }
reqwest = { version = "0.12", default-features = false, features = ["rustls-tls"] }
ring = "0.17"
rustls = { version = "0.23", default-features = false, features = ["ring"] }
Expand All @@ -72,6 +76,7 @@ tokio-tungstenite = "0.21"
tokio-tungstenite-wasm = "0.3"
tokio-util = { version = "0.7.12", features = ["io-util", "io", "codec", "rt"] }
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter"], optional = true }
tungstenite = "0.21"
url = { version = "2.4", features = ["serde"] }
watchable = "1.1.2"
Expand All @@ -80,15 +85,6 @@ webpki-roots = "0.26"
x509-parser = "0.16"
z32 = "1.0.3"

# iroh-relay
axum = { version = "0.7.4", optional = true }
clap = { version = "4", features = ["derive"], optional = true }
regex = { version = "1.7.1", optional = true }
rustls-pemfile = { version = "2.1", optional = true }
toml = { version = "0.8", optional = true }
tracing-subscriber = { version = "0.3", features = ["env-filter"], optional = true }
tokio-rustls-acme = { version = "0.4", optional = true }

# metrics
iroh-metrics = { version = "0.28.0", default-features = false }
strum = { version = "0.26.2", features = ["derive"] }
Expand All @@ -114,14 +110,12 @@ axum = { version = "0.7.4" }
clap = { version = "4", features = ["derive"] }
criterion = "0.5.1"
crypto_box = { version = "0.9.1", features = ["serde", "chacha20"] }
ntest = "0.9"
pretty_assertions = "1.4"
proptest = "1.2.0"
rand_chacha = "0.3.1"
tokio = { version = "1", features = ["io-util", "sync", "rt", "net", "fs", "macros", "time", "test-util"] }
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
iroh-test = "0.28.0"
iroh-net = { path = ".", features = ["iroh-relay"] }
iroh-net = { path = "." }
serde_json = "1.0.107"
testresult = "0.4.0"
mainline = "2.0.1"
Expand All @@ -135,24 +129,11 @@ duct = "0.13.6"

[features]
default = ["metrics", "discovery-pkarr-dht"]
iroh-relay = [
"dep:tokio-rustls-acme",
"dep:axum",
"dep:clap",
"dep:toml",
"dep:rustls-pemfile",
"dep:regex",
"dep:tracing-subscriber"
]
metrics = ["iroh-metrics/metrics"]
test-utils = ["iroh-relay"]
test-utils = ["iroh-relay/test-utils", "iroh-relay/server", "dep:axum"]
discovery-local-network = ["dep:swarm-discovery"]
discovery-pkarr-dht = ["pkarr/dht", "dep:genawaiter"]

[[bin]]
name = "iroh-relay"
required-features = ["iroh-relay"]

[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "iroh_docsrs"]
Expand Down
3 changes: 1 addition & 2 deletions iroh-net/bench/src/iroh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ use bytes::Bytes;
use futures_lite::StreamExt as _;
use iroh_net::{
endpoint::{Connection, ConnectionError, RecvStream, SendStream, TransportConfig},
relay::{RelayMap, RelayMode, RelayUrl},
Endpoint, NodeAddr,
Endpoint, NodeAddr, RelayMap, RelayMode, RelayUrl,
};
use tracing::{trace, warn};

Expand Down
6 changes: 1 addition & 5 deletions iroh-net/examples/connect-unreliable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@ use std::net::SocketAddr;
use anyhow::Context;
use clap::Parser;
use futures_lite::StreamExt;
use iroh_net::{
key::SecretKey,
relay::{RelayMode, RelayUrl},
Endpoint, NodeAddr,
};
use iroh_net::{key::SecretKey, Endpoint, NodeAddr, RelayMode, RelayUrl};
use tracing::info;

// An example ALPN that we are using to communicate over the `Endpoint`
Expand Down
6 changes: 1 addition & 5 deletions iroh-net/examples/connect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@ use std::net::SocketAddr;
use anyhow::Context;
use clap::Parser;
use futures_lite::StreamExt;
use iroh_net::{
key::SecretKey,
relay::{RelayMode, RelayUrl},
Endpoint, NodeAddr,
};
use iroh_net::{key::SecretKey, Endpoint, NodeAddr, RelayMode, RelayUrl};
use tracing::info;

// An example ALPN that we are using to communicate over the `Endpoint`
Expand Down
2 changes: 1 addition & 1 deletion iroh-net/examples/listen-unreliable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//! $ cargo run --example listen-unreliable
use anyhow::Context;
use futures_lite::StreamExt;
use iroh_net::{key::SecretKey, relay::RelayMode, Endpoint};
use iroh_net::{key::SecretKey, Endpoint, RelayMode};
use tracing::{info, warn};

// An example ALPN that we are using to communicate over the `Endpoint`
Expand Down
2 changes: 1 addition & 1 deletion iroh-net/examples/listen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::time::Duration;

use anyhow::Context;
use futures_lite::StreamExt;
use iroh_net::{endpoint::ConnectionError, key::SecretKey, relay::RelayMode, Endpoint};
use iroh_net::{endpoint::ConnectionError, key::SecretKey, Endpoint, RelayMode};
use tracing::{debug, info, warn};

// An example ALPN that we are using to communicate over the `Endpoint`
Expand Down
28 changes: 1 addition & 27 deletions iroh-net/src/defaults.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use url::Url;

use crate::relay::{RelayMap, RelayNode};
use crate::{RelayMap, RelayNode};

/// The default STUN port used by the Relay server.
///
Expand Down Expand Up @@ -164,30 +164,4 @@ pub(crate) mod timeouts {

/// Default Pinger timeout
pub(crate) const DEFAULT_PINGER_TIMEOUT: Duration = Duration::from_secs(5);

/// Timeouts specifically used in the iroh-relay
pub(crate) mod relay {
use super::*;

/// Timeout used by the relay client while connecting to the relay server,
/// using `TcpStream::connect`
pub(crate) const DIAL_NODE_TIMEOUT: Duration = Duration::from_millis(1500);
/// Timeout for expecting a pong from the relay server
pub(crate) const PING_TIMEOUT: Duration = Duration::from_secs(5);
/// Timeout for the entire relay connection, which includes dns, dialing
/// the server, upgrading the connection, and completing the handshake
pub(crate) const CONNECT_TIMEOUT: Duration = Duration::from_secs(10);
/// Timeout for our async dns resolver
pub(crate) const DNS_TIMEOUT: Duration = Duration::from_secs(1);

/// Maximum time the client will wait to receive on the connection, since
/// the last message. Longer than this time and the client will consider
/// the connection dead.
pub(crate) const CLIENT_RECV_TIMEOUT: Duration = Duration::from_secs(120);

/// Maximum time the server will attempt to get a successful write to the connection.
#[cfg(feature = "iroh-relay")]
#[cfg_attr(iroh_docsrs, doc(cfg(feature = "iroh-relay")))]
pub(crate) const SERVER_WRITE_TIMEOUT: Duration = Duration::from_secs(2);
}
}
Loading
Loading