Skip to content

Commit

Permalink
refactor(iroh-net): Switch to new iroh-relay route /relay instead o…
Browse files Browse the repository at this point in the history
…f `/derp` (#2489)

Split out from #2419, copy of #2441, because I forgot to switch the base
branch 🙃

Splitting this out means we can deploy the relay changes one release in
advance to the changes in the client.

Otherwise, we'd need to update the relays ASAP when we release 0.20, as
clients will expect to be able to connect to the `/relay` route (which
may not be deployed immediately after the release).

## Description

- Switches the client to connect to `/relay` instead of `/derp`.

## Breaking Changes

None

## Notes & open questions

Also a PR related to #2378 

I allowed myself to add in another `derive_more::Debug` instance instead
of a custom, outdated `impl Debug`, if that's okay with you 😁

## Change checklist

- [X] Self-review.
- [X] Documentation updates if relevant.
- [X] Tests if relevant.
- [X] All breaking changes documented.
  • Loading branch information
matheus23 authored Jul 18, 2024
1 parent 7e50bc3 commit b7b493d
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions iroh-net/src/relay/http/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ use crate::key::{PublicKey, SecretKey};
use crate::relay::client::{ConnReader, ConnWriter};
use crate::relay::codec::DerpCodec;
use crate::relay::http::streams::{downcast_upgrade, MaybeTlsStream};
use crate::relay::http::RELAY_PATH;
use crate::relay::RelayUrl;
use crate::relay::{
client::Client as RelayClient, client::ClientBuilder as RelayClientBuilder,
Expand Down Expand Up @@ -203,12 +204,14 @@ impl PingTracker {
}

/// Build a Client.
#[derive(derive_more::Debug)]
pub struct ClientBuilder {
/// Default is false
can_ack_pings: bool,
/// Default is false
is_preferred: bool,
/// Default is None
#[debug("address family selector callback")]
address_family_selector: Option<Box<dyn Fn() -> BoxFuture<bool> + Send + Sync + 'static>>,
/// Default is false
is_prober: bool,
Expand All @@ -225,16 +228,6 @@ pub struct ClientBuilder {
proxy_url: Option<Url>,
}

impl std::fmt::Debug for ClientBuilder {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let address_family_selector_txt = match self.address_family_selector {
Some(_) => "Some(Box<dyn Fn() -> BoxFuture<'static, bool> + Send + Sync + 'static>)",
None => "None",
};
write!(f, "ClientBuilder {{ can_ack_pings: {}, is_preferred: {}, address_family_selector: {address_family_selector_txt} }}", self.can_ack_pings, self.is_preferred)
}
}

impl ClientBuilder {
/// Create a new [`ClientBuilder`]
pub fn new(url: impl Into<RelayUrl>) -> Self {
Expand Down Expand Up @@ -636,7 +629,7 @@ impl Actor {

async fn connect_ws(&self) -> Result<(ConnReader, ConnWriter), ClientError> {
let mut dial_url = (*self.url).clone();
dial_url.set_path("/derp");
dial_url.set_path(RELAY_PATH);
// The relay URL is exchanged with the http(s) scheme in tickets and similar.
// We need to use the ws:// or wss:// schemes when connecting with websockets, though.
dial_url
Expand Down Expand Up @@ -727,7 +720,7 @@ impl Actor {
);
debug!("Sending upgrade request");
let req = Request::builder()
.uri("/derp")
.uri(RELAY_PATH)
.header(UPGRADE, Protocol::Relay.upgrade_header())
.body(http_body_util::Empty::<hyper::body::Bytes>::new())?;
request_sender.send_request(req).await.map_err(From::from)
Expand Down

0 comments on commit b7b493d

Please sign in to comment.