diff --git a/Cargo.toml b/Cargo.toml index 8604da51..faa41d8e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -74,4 +74,3 @@ tracing-subscriber = "0.2.19" [features] default = [ "igd" ] -no-igd = [ ] diff --git a/src/endpoint.rs b/src/endpoint.rs index 4f276c8a..944833c4 100644 --- a/src/endpoint.rs +++ b/src/endpoint.rs @@ -9,7 +9,7 @@ use crate::connection_pool::ConnId; -#[cfg(not(feature = "no-igd"))] +#[cfg(feature = "igd")] use super::igd::{forward_port, IgdError}; use super::wire_msg::WireMsg; use super::{ @@ -38,7 +38,7 @@ use tracing::{debug, error, info, trace, warn}; const CERT_SERVER_NAME: &str = "MaidSAFE.net"; // Number of seconds before timing out the IGD request to forward a port. -#[cfg(not(feature = "no-igd"))] +#[cfg(feature = "igd")] const PORT_FORWARD_TIMEOUT: Duration = Duration::from_secs(30); // Number of seconds before timing out the echo service query. @@ -144,7 +144,7 @@ impl Endpoint { let contact = endpoint.connect_to_any(contacts).await; let public_addr = endpoint.resolve_public_addr(contact).await?; - #[cfg(not(feature = "no-igd"))] + #[cfg(feature = "igd")] if endpoint.config.forward_port { timeout( PORT_FORWARD_TIMEOUT, diff --git a/src/error.rs b/src/error.rs index 24ef9839..398b7d54 100644 --- a/src/error.rs +++ b/src/error.rs @@ -9,7 +9,7 @@ use super::wire_msg::WireMsg; use crate::config::ConfigError; -#[cfg(not(feature = "no-igd"))] +#[cfg(feature = "igd")] use crate::igd::IgdError; use bytes::Bytes; use std::{fmt, io, net::SocketAddr}; @@ -38,7 +38,7 @@ pub enum EndpointError { }, /// Failed to establish UPnP port forwarding. - #[cfg(not(feature = "no-igd"))] + #[cfg(feature = "igd")] #[error(transparent)] Upnp(#[from] UpnpError), @@ -69,7 +69,7 @@ impl From for EndpointError { } } -#[cfg(not(feature = "no-igd"))] +#[cfg(feature = "igd")] impl From for EndpointError { fn from(error: IgdError) -> Self { Self::Upnp(UpnpError(error)) @@ -466,7 +466,7 @@ pub enum StreamError { pub struct UnsupportedStreamOperation(Box); /// Failed to establish UPnP port forwarding. -#[cfg(not(feature = "no-igd"))] +#[cfg(feature = "igd")] #[derive(Debug, Error)] #[error("Failed to establish UPnP port forwarding")] pub struct UpnpError(#[source] IgdError); diff --git a/src/lib.rs b/src/lib.rs index fb32febf..320ecf71 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -53,7 +53,7 @@ mod connection_pool; mod connections; mod endpoint; mod error; -#[cfg(not(feature = "no-igd"))] +#[cfg(feature = "igd")] mod igd; mod utils; mod wire_msg; @@ -62,7 +62,7 @@ pub use config::{Config, ConfigError}; pub use connection_pool::ConnId; pub use connections::{DisconnectionEvents, RecvStream, SendStream}; pub use endpoint::{Endpoint, IncomingConnections, IncomingMessages}; -#[cfg(not(feature = "no-igd"))] +#[cfg(feature = "igd")] pub use error::UpnpError; pub use error::{ ClientEndpointError, Close, ConnectionError, EndpointError, InternalConfigError, RecvError,