Skip to content

Commit

Permalink
tests pass again
Browse files Browse the repository at this point in the history
  • Loading branch information
flub committed Jun 7, 2024
1 parent 0fac430 commit 2ee232f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 32 deletions.
32 changes: 1 addition & 31 deletions iroh-net/src/relay/iroh_relay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ fn body_empty() -> BytesBody {
}

/// Configuration for the full Relay & STUN server.
#[derive(Debug)]
#[derive(Debug, Default)]
pub struct ServerConfig<EC: fmt::Debug, EA: fmt::Debug = EC> {
/// Configuration for the DERP server, disabled if `None`.
pub relay: Option<RelayConfig<EC, EA>>,
Expand All @@ -66,35 +66,6 @@ pub struct ServerConfig<EC: fmt::Debug, EA: fmt::Debug = EC> {
pub metrics_addr: Option<SocketAddr>,
}

impl<EC: fmt::Debug, EA: fmt::Debug> ServerConfig<EC, EA> {
/// 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
Expand Down Expand Up @@ -205,7 +176,6 @@ impl Server {
EC: fmt::Debug + 'static,
EA: fmt::Debug + 'static,
{
config.validate()?;
let mut tasks = JoinSet::new();

#[cfg(feature = "metrics")]
Expand Down
2 changes: 1 addition & 1 deletion iroh-net/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 2ee232f

Please sign in to comment.