diff --git a/iroh-net/src/relay/http/client.rs b/iroh-net/src/relay/http/client.rs index b2c544fed3f..045213012d3 100644 --- a/iroh-net/src/relay/http/client.rs +++ b/iroh-net/src/relay/http/client.rs @@ -178,7 +178,6 @@ struct Actor { ping_tasks: JoinSet<()>, dns_resolver: DnsResolver, proxy_url: Option, - relay_path: &'static str, } #[derive(Default, Debug)] @@ -224,8 +223,6 @@ pub struct ClientBuilder { insecure_skip_cert_verify: bool, /// HTTP Proxy proxy_url: Option, - /// Default is "/relay" - relay_path: &'static str, } impl ClientBuilder { @@ -241,7 +238,6 @@ impl ClientBuilder { #[cfg(any(test, feature = "test-utils"))] insecure_skip_cert_verify: false, proxy_url: None, - relay_path: RELAY_HTTP_PATH, } } @@ -299,15 +295,6 @@ impl ClientBuilder { self } - /// Set the relay endpoint path used for making connections. - /// - /// Private for now, as it's only used in tests so far. - #[cfg(test)] - pub(crate) fn relay_path(mut self, relay_path: &'static str) -> Self { - self.relay_path = relay_path; - self - } - /// Build the [`Client`] pub fn build(self, key: SecretKey, dns_resolver: DnsResolver) -> (Client, ClientReceiver) { // TODO: review TLS config @@ -350,7 +337,6 @@ impl ClientBuilder { tls_connector, dns_resolver, proxy_url: self.proxy_url, - relay_path: self.relay_path, }; let (msg_sender, inbox) = mpsc::channel(64); @@ -627,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(self.relay_path); + dial_url.set_path(RELAY_HTTP_PATH); debug!(%dial_url, "Dialing relay by websocket"); diff --git a/iroh-net/src/relay/iroh_relay.rs b/iroh-net/src/relay/iroh_relay.rs index 6cd4f698cd0..b16095bb6a8 100644 --- a/iroh-net/src/relay/iroh_relay.rs +++ b/iroh-net/src/relay/iroh_relay.rs @@ -703,9 +703,10 @@ mod tests { use std::time::Duration; use bytes::Bytes; + use http::header::UPGRADE; use iroh_base::node_addr::RelayUrl; - use crate::relay::http::ClientBuilder; + use crate::relay::http::{ClientBuilder, HTTP_UPGRADE_PROTOCOL}; use self::relay::ReceivedMessage; @@ -797,17 +798,18 @@ mod tests { async fn test_relay_client_legacy_route() { let _guard = iroh_test::logging::setup(); let server = spawn_local_relay().await.unwrap(); - let relay_url = format!("http://{}", server.http_addr().unwrap()); - let relay_url: RelayUrl = relay_url.parse().unwrap(); + // We're testing the legacy endpoint at `/derp` + let endpoint_url = format!("http://{}/derp", server.http_addr().unwrap()); - // set up client a - let secret_key = SecretKey::generate(); - let resolver = crate::dns::default_resolver().clone(); - let (client, _) = ClientBuilder::new(relay_url) - .relay_path("/derp") // Try the legacy relay path for backwards compatibility - .build(secret_key, resolver); + let client = reqwest::Client::new(); + let result = client + .get(endpoint_url) + .header(UPGRADE, HTTP_UPGRADE_PROTOCOL) + .send() + .await + .unwrap(); - client.ping().await.unwrap(); + assert_eq!(result.status(), StatusCode::SWITCHING_PROTOCOLS); } #[tokio::test]