Skip to content

Commit

Permalink
refactor!: Remove no-igd feature
Browse files Browse the repository at this point in the history
Since `igd` is already an optional dependency, we already have an `igd`
feature which is enabled by default. To disable IGD, we can simply use
`default-features = false` or `--no-default-features`.

BREAKING CHANGE: The `no-igd` feature has been removed.
  • Loading branch information
Chris Connelly authored and bochaco committed Sep 10, 2021
1 parent 53b476b commit b5e2938
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,3 @@ tracing-subscriber = "0.2.19"

[features]
default = [ "igd" ]
no-igd = [ ]
6 changes: 3 additions & 3 deletions src/endpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -144,7 +144,7 @@ impl<I: ConnId> Endpoint<I> {
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,
Expand Down
8 changes: 4 additions & 4 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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),

Expand Down Expand Up @@ -69,7 +69,7 @@ impl From<quinn::EndpointError> for EndpointError {
}
}

#[cfg(not(feature = "no-igd"))]
#[cfg(feature = "igd")]
impl From<IgdError> for EndpointError {
fn from(error: IgdError) -> Self {
Self::Upnp(UpnpError(error))
Expand Down Expand Up @@ -466,7 +466,7 @@ pub enum StreamError {
pub struct UnsupportedStreamOperation(Box<dyn std::error::Error + Send + Sync>);

/// 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);
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
Expand Down

0 comments on commit b5e2938

Please sign in to comment.