forked from Qortal/qortal
Attempt to open the listen port (default 12392) using UPnP, if the local network supports it.
This commit is contained in:
parent
5842b1272d
commit
8de606588c
@ -1,5 +1,6 @@
|
||||
package org.qortal.network;
|
||||
|
||||
import com.dosse.upnp.UPnP;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.bouncycastle.crypto.params.Ed25519PrivateKeyParameters;
|
||||
@ -183,6 +184,11 @@ public class Network {
|
||||
}
|
||||
}
|
||||
|
||||
// Attempt to set up UPnP. All errors are ignored.
|
||||
if (Settings.getInstance().isuPnPEnabled()) {
|
||||
UPnP.openPortTCP(Settings.getInstance().getListenPort());
|
||||
}
|
||||
|
||||
// Start up first networking thread
|
||||
networkEPC.start();
|
||||
}
|
||||
|
@ -181,6 +181,8 @@ public class Settings {
|
||||
private boolean isTestNet = false;
|
||||
/** Port number for inbound peer-to-peer connections. */
|
||||
private Integer listenPort;
|
||||
/** Whether to attempt to open the listen port via UPnP */
|
||||
private boolean uPnPEnabled = true;
|
||||
/** Minimum number of peers to allow block minting / synchronization. */
|
||||
private int minBlockchainPeers = 5;
|
||||
/** Target number of outbound connections to peers we should make. */
|
||||
@ -629,6 +631,10 @@ public class Settings {
|
||||
return this.bindAddress;
|
||||
}
|
||||
|
||||
public boolean isuPnPEnabled() {
|
||||
return this.uPnPEnabled;
|
||||
}
|
||||
|
||||
public int getMinBlockchainPeers() {
|
||||
return this.minBlockchainPeers;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user