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` (#2441)

Split out from #2419 

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 11, 2024
1 parent a142c57 commit f4f1a89
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 @@ -202,12 +203,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 @@ -222,16 +225,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 @@ -620,7 +613,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);

debug!(%dial_url, "Dialing relay by websocket");

Expand Down Expand Up @@ -706,7 +699,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 f4f1a89

Please sign in to comment.