forked from Qortal/qortal
Use default testnet/mainnet listen port as appropriate when peer addresses are given without port
This commit is contained in:
parent
a154a7c073
commit
b9737372d9
@ -563,7 +563,7 @@ public class Peer extends Thread {
|
|||||||
// HostAndPort doesn't try to validate host so we do extra checking here
|
// HostAndPort doesn't try to validate host so we do extra checking here
|
||||||
InetAddress address = InetAddresses.forString(hostAndPort.getHost());
|
InetAddress address = InetAddresses.forString(hostAndPort.getHost());
|
||||||
|
|
||||||
return new InetSocketAddress(address, hostAndPort.getPortOrDefault(Settings.DEFAULT_LISTEN_PORT));
|
return new InetSocketAddress(address, hostAndPort.getPortOrDefault(Settings.getInstance().getDefaultListenPort()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns true if address is loopback/link-local/site-local, false otherwise. */
|
/** Returns true if address is loopback/link-local/site-local, false otherwise. */
|
||||||
|
@ -70,7 +70,7 @@ public class PeerAddress {
|
|||||||
boolean isBracketed = addressString.startsWith("[");
|
boolean isBracketed = addressString.startsWith("[");
|
||||||
|
|
||||||
// Attempt to parse string into host and port
|
// Attempt to parse string into host and port
|
||||||
HostAndPort hostAndPort = HostAndPort.fromString(addressString).withDefaultPort(Settings.DEFAULT_LISTEN_PORT).requireBracketsForIPv6();
|
HostAndPort hostAndPort = HostAndPort.fromString(addressString).withDefaultPort(Settings.getInstance().getDefaultListenPort()).requireBracketsForIPv6();
|
||||||
|
|
||||||
String host = hostAndPort.getHost();
|
String host = hostAndPort.getHost();
|
||||||
if (host.isEmpty())
|
if (host.isEmpty())
|
||||||
|
@ -25,14 +25,14 @@ import org.qora.block.BlockChain;
|
|||||||
@XmlAccessorType(XmlAccessType.FIELD)
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
public class Settings {
|
public class Settings {
|
||||||
|
|
||||||
public static final int DEFAULT_LISTEN_PORT = 9084;
|
private static final int MAINNET_LISTEN_PORT = 9084;
|
||||||
public static final int TESTNET_LISTEN_PORT = 9184;
|
private static final int TESTNET_LISTEN_PORT = 9184;
|
||||||
|
|
||||||
public static final int DEFAULT_API_PORT = 9085;
|
private static final int MAINNET_API_PORT = 9085;
|
||||||
public static final int TESTNET_API_PORT = 9185;
|
private static final int TESTNET_API_PORT = 9185;
|
||||||
|
|
||||||
public static final int DEFAULT_UI_PORT = 9080;
|
private static final int MAINNET_UI_PORT = 9080;
|
||||||
public static final int TESTNET_UI_PORT = 9180;
|
private static final int TESTNET_UI_PORT = 9180;
|
||||||
|
|
||||||
private static final Logger LOGGER = LogManager.getLogger(Settings.class);
|
private static final Logger LOGGER = LogManager.getLogger(Settings.class);
|
||||||
private static final String SETTINGS_FILENAME = "settings.json";
|
private static final String SETTINGS_FILENAME = "settings.json";
|
||||||
@ -206,7 +206,7 @@ public class Settings {
|
|||||||
if (this.uiPort != null)
|
if (this.uiPort != null)
|
||||||
return this.uiPort;
|
return this.uiPort;
|
||||||
|
|
||||||
return this.isTestNet ? TESTNET_UI_PORT : DEFAULT_UI_PORT;
|
return this.isTestNet ? TESTNET_UI_PORT : MAINNET_UI_PORT;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String[] getUiWhitelist() {
|
public String[] getUiWhitelist() {
|
||||||
@ -221,7 +221,7 @@ public class Settings {
|
|||||||
if (this.apiPort != null)
|
if (this.apiPort != null)
|
||||||
return this.apiPort;
|
return this.apiPort;
|
||||||
|
|
||||||
return this.isTestNet ? TESTNET_API_PORT : DEFAULT_API_PORT;
|
return this.isTestNet ? TESTNET_API_PORT : MAINNET_API_PORT;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String[] getApiWhitelist() {
|
public String[] getApiWhitelist() {
|
||||||
@ -261,7 +261,11 @@ public class Settings {
|
|||||||
if (this.listenPort != null)
|
if (this.listenPort != null)
|
||||||
return this.listenPort;
|
return this.listenPort;
|
||||||
|
|
||||||
return this.isTestNet ? TESTNET_LISTEN_PORT : DEFAULT_LISTEN_PORT;
|
return this.isTestNet ? TESTNET_LISTEN_PORT : MAINNET_LISTEN_PORT;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getDefaultListenPort() {
|
||||||
|
return this.isTestNet ? TESTNET_LISTEN_PORT : MAINNET_LISTEN_PORT;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getBindAddress() {
|
public String getBindAddress() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user