diff --git a/iroh-net/src/relay/iroh_relay.rs b/iroh-net/src/relay/iroh_relay.rs index 128a37ec10..b3b25a45ad 100644 --- a/iroh-net/src/relay/iroh_relay.rs +++ b/iroh-net/src/relay/iroh_relay.rs @@ -55,7 +55,7 @@ fn body_empty() -> BytesBody { } /// Configuration for the full Relay & STUN server. -#[derive(Debug)] +#[derive(Debug, Default)] pub struct ServerConfig { /// Configuration for the DERP server, disabled if `None`. pub relay: Option>, @@ -66,35 +66,6 @@ pub struct ServerConfig { pub metrics_addr: Option, } -impl ServerConfig { - /// Creates a new config. - pub fn new() -> Self { - Self { - relay: None, - stun: None, - metrics_addr: None, - } - } - - /// Validates the config for internal consistency. - pub fn validate(&self) -> Result<()> { - // todo: check all bind addrs are different. Though if done correctly the server - // will just fail to start and show an approriate error, so maybe we shouldn't be - // validating at all. - if self.relay.is_none() && self.stun.is_none() { - bail!("neither DERP nor STUN server configured"); - } - if let Some(derp) = &self.relay { - if let Some(tls) = &derp.tls { - if derp.http_bind_addr == tls.https_bind_addr { - bail!("derp port conflicts with captive portal port"); - } - } - } - Ok(()) - } -} - /// Configuration for the Relay HTTP and HTTPS server. /// /// This includes the HTTP services hosted by the Relay server, the Relay `/derp` HTTP @@ -205,7 +176,6 @@ impl Server { EC: fmt::Debug + 'static, EA: fmt::Debug + 'static, { - config.validate()?; let mut tasks = JoinSet::new(); #[cfg(feature = "metrics")] diff --git a/iroh-net/src/test_utils.rs b/iroh-net/src/test_utils.rs index 45b73d963c..3a2cd3c56f 100644 --- a/iroh-net/src/test_utils.rs +++ b/iroh-net/src/test_utils.rs @@ -58,7 +58,7 @@ pub async fn run_relay_server() -> Result<(RelayMap, RelayUrl, crate::relay::iro let server = crate::relay::iroh_relay::Server::spawn(config) .await .unwrap(); - let url: RelayUrl = format!("https://localhost:{}", server.https_addr().unwrap()) + let url: RelayUrl = format!("https://localhost:{}", server.https_addr().unwrap().port()) .parse() .unwrap(); let m = RelayMap::from_nodes([RelayNode {