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

refactor(iroh-net): Switch to new iroh-relay route /relay instead of /derp #2489

Merged
merged 10 commits into from
Jul 18, 2024
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 @@ -629,7 +622,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 @@ -720,7 +713,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
Loading