-
Notifications
You must be signed in to change notification settings - Fork 235
feat(iroh-relay): Make the client side of iroh-relay
compile & run in browsers
#3119
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
Conversation
iroh-relay
compile & run in browsersiroh-relay
compile & run in browsers
Documentation for this PR has been generated and is available at: https://n0-computer.github.io/iroh/pr/3119/docs/iroh/ Last updated: 2025-01-28T15:09:34Z |
687d7bb
to
d3c1753
Compare
…d `Encoder` deps correctly
let roots = rustls::RootCertStore { | ||
roots: webpki_roots::TLS_SERVER_ROOTS.to_vec(), | ||
}; | ||
let mut config = rustls::client::ClientConfig::builder_with_provider(Arc::new( | ||
rustls::crypto::ring::default_provider(), | ||
)) | ||
.with_safe_default_protocol_versions() | ||
.expect("protocols supported by ring") | ||
.with_root_certificates(roots) | ||
.with_no_client_auth(); | ||
#[cfg(any(test, feature = "test-utils"))] | ||
if self.insecure_skip_cert_verify { | ||
warn!("Insecure config: SSL certificates from relay servers not verified"); | ||
config | ||
.dangerous() | ||
.set_certificate_verifier(Arc::new(NoCertVerifier)); | ||
} | ||
config.resumption = Resumption::default(); | ||
let tls_connector: tokio_rustls::TlsConnector = Arc::new(config).into(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of immediately constructing the tls_connector
in connect
, and then either using it or discarding it depending on whether we use connect_ws
or connect_relay
, I've moved it into connect_relay
.
@@ -211,94 +185,6 @@ impl ClientBuilder { | |||
Ok(conn) | |||
} | |||
|
|||
async fn connect_relay( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
connect_relay
and all of its call graph dependencies are now moved into a submodule iroh_relay::client::connect_relay
, this makes cfg-ing out much easier.
other than my comments this is looking pretty good |
Self::Relay { ref mut conn } => Pin::new(conn).poll_flush(cx).map_err(Into::into), | ||
Self::Ws { ref mut conn, .. } => Pin::new(conn).poll_flush(cx).map_err(Into::into), | ||
} | ||
} | ||
|
||
fn poll_close(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> { | ||
match *self { | ||
#[cfg(not(wasm_browser))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just noting this down: it's really unfortunate we have to do this on all the branches, but I don't have a better idea
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I think we can remove them, once/if we go websocket connections only.
Description
Allows compiling and running
iroh-relay
in browsers (as long as theserver
feature is disabled).By default uses websockets to connect to relays when compiling for the
wasm32-unknown-unknown
target.If configured to
Protocol::Relay
specifically, it'll error out.Test it yourself:
cargo rustc -p iroh-relay --no-default-features --target=wasm32-unknown-unknown --crate-type=cdylib
Breaking Changes
iroh-quinn
re-exports are now updated from version 0.12 to version 0.13Notes & open questions
Note: This updates all crate's versions to
iroh-quinn
0.13!(Because we need them to be consistent between crates in this workspace.)
TODO
(import "env" ...)
-freeiroh-quinn
with my browser PR inBlocking this from merging: Need a newit's already relaxednetwatch
release with thequinn-udp = "0.5.5"
version bound relaxedChange checklist