Add Nat PMP method to P2P module (#11210)
* Add Nat PMP method to P2P module * Add test fn * Use closure * print richer error messages. * reformat long code line * remove closures
This commit is contained in:
@@ -53,7 +53,7 @@ use export_hardcoded_sync::ExportHsyncCmd;
|
||||
use presale::ImportWallet;
|
||||
use account::{AccountCmd, NewAccount, ListAccounts, ImportAccounts, ImportFromGethAccounts};
|
||||
use snapshot_cmd::{self, SnapshotCommand};
|
||||
use network::{IpFilter};
|
||||
use network::{IpFilter, NatType};
|
||||
|
||||
const DEFAULT_MAX_PEERS: u16 = 50;
|
||||
const DEFAULT_MIN_PEERS: u16 = 25;
|
||||
@@ -743,7 +743,13 @@ impl Configuration {
|
||||
|
||||
fn net_config(&self) -> Result<NetworkConfiguration, String> {
|
||||
let mut ret = NetworkConfiguration::new();
|
||||
ret.nat_enabled = self.args.arg_nat == "any" || self.args.arg_nat == "upnp";
|
||||
ret.nat_enabled = self.args.arg_nat == "any" || self.args.arg_nat == "upnp" || self.args.arg_nat == "natpmp";
|
||||
ret.nat_type = match &self.args.arg_nat[..] {
|
||||
"any" => NatType::Any,
|
||||
"upnp" => NatType::UPnP,
|
||||
"natpmp" => NatType::NatPMP,
|
||||
_ => NatType::Nothing,
|
||||
};
|
||||
ret.boot_nodes = to_bootnodes(&self.args.arg_bootnodes)?;
|
||||
let (listen, public) = self.net_addresses()?;
|
||||
ret.listen_address = Some(format!("{}", listen));
|
||||
|
||||
@@ -202,6 +202,7 @@ pub fn to_bootnodes(bootnodes: &Option<String>) -> Result<Vec<String>, String> {
|
||||
|
||||
#[cfg(test)]
|
||||
pub fn default_network_config() -> ::sync::NetworkConfiguration {
|
||||
use network::NatType;
|
||||
use sync::{NetworkConfiguration};
|
||||
use super::network::IpFilter;
|
||||
NetworkConfiguration {
|
||||
@@ -211,6 +212,7 @@ pub fn default_network_config() -> ::sync::NetworkConfiguration {
|
||||
public_address: None,
|
||||
udp_port: None,
|
||||
nat_enabled: true,
|
||||
nat_type: NatType::Any,
|
||||
discovery_enabled: true,
|
||||
boot_nodes: Vec::new(),
|
||||
use_secret: None,
|
||||
|
||||
Reference in New Issue
Block a user