Skip to content

Commit

Permalink
Switched the 'upnp' variable to 'disable_upnp'. It is now apparent th…
Browse files Browse the repository at this point in the history
…at UPnP is enabled by default and can be deactivated using this flag.
  • Loading branch information
biryukovmaxim committed Oct 1, 2023
1 parent ae5bb77 commit a6b2158
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
7 changes: 6 additions & 1 deletion components/addressmanager/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,15 @@ impl AddressManager {
info!("Non-publicly routable external ip {} not added to store", local_net_address);
None
}
None if self.config.upnp => {
None if !self.config.disable_upnp => {
let gateway = igd::search_gateway(Default::default()).ok()?;
let ip = IpAddress::new(gateway.get_external_ip().ok()?);
if !ip.is_publicly_routable() {
info!("Non-publicly routable external ip from gateway using upnp {} not added to store", ip);
return None;
}
info!("Get external ip from gateway using upnp: {ip}");

let default_port = self.config.default_p2p_port();

let normalized_p2p_listen_address = self.config.p2p_listen_address.normalize(default_port);
Expand Down
4 changes: 2 additions & 2 deletions consensus/core/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pub struct Config {

#[cfg(feature = "devnet-prealloc")]
pub initial_utxo_set: Arc<UtxoCollection>,
pub upnp: bool,
pub disable_upnp: bool,
}

impl Config {
Expand All @@ -86,7 +86,7 @@ impl Config {

#[cfg(feature = "devnet-prealloc")]
initial_utxo_set: Default::default(),
upnp: false,
disable_upnp: false,
}
}

Expand Down
10 changes: 5 additions & 5 deletions kaspad/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ pub struct Args {
#[cfg(feature = "devnet-prealloc")]
pub prealloc_amount: u64,

pub upnp: bool,
pub disable_upnp: bool,
}

impl Default for Args {
Expand Down Expand Up @@ -108,15 +108,15 @@ impl Default for Args {
#[cfg(feature = "devnet-prealloc")]
prealloc_amount: 1_000_000,

upnp: false,
disable_upnp: false,
}
}
}

impl Args {
pub fn apply_to_config(&self, config: &mut Config) {
config.utxoindex = self.utxoindex;
config.upnp = self.upnp;
config.disable_upnp = self.disable_upnp;
config.unsafe_rpc = self.unsafe_rpc;
config.enable_unsynced_mining = self.enable_unsynced_mining;
config.is_archival = self.archival;
Expand Down Expand Up @@ -311,7 +311,7 @@ pub fn cli() -> Command {
.require_equals(true)
.value_parser(clap::value_parser!(u64))
.help("Interval in seconds for performance metrics collection."),
).arg(arg!(--upnp "Enable upnp"));
).arg(arg!(--disable-upnp "Disable upnp"));

#[cfg(feature = "devnet-prealloc")]
let cmd = cmd
Expand Down Expand Up @@ -368,7 +368,7 @@ pub fn parse_args() -> Args {
prealloc_address: m.get_one::<String>("prealloc-address").cloned(),
#[cfg(feature = "devnet-prealloc")]
prealloc_amount: m.get_one::<u64>("prealloc-amount").cloned().unwrap_or(defaults.prealloc_amount),
upnp: m.get_one::<bool>("upnp").cloned().unwrap_or(defaults.upnp),
disable_upnp: m.get_one::<bool>("upnp").cloned().unwrap_or(defaults.disable_upnp),
}
}

Expand Down

0 comments on commit a6b2158

Please sign in to comment.