mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-07-26 00:15:18 -04:00
Allow command-line configuration of local node id and port
This change does away with the notion of "clientPort" and replaces it, simply, with "port". There are only two ports we care about in Bitsquare: 1. The port that the local node (i.e. a Bitsquare UI running on your laptop) listens on. This value is now specified with `--port` 2. The port of the bootstrap node that the local node will connect to on its first run. This value is specified with `--bootstrap.node.port` So, for example, the following is a valid commandline invocation: java -jar bitsquare.jar --port 1234 --bootstrap.node.port=9876 Both of these values default to Node.DEFAULT_PORT (currently 7366) This commit also introduces the --id flag for configuring the ID of the local node.
This commit is contained in:
parent
cb0e214a28
commit
2ae5949448
6 changed files with 38 additions and 43 deletions
|
@ -304,8 +304,7 @@ public class TomP2PTests {
|
|||
assertEquals("pong", futureDirect.object());
|
||||
}
|
||||
|
||||
private Peer bootstrapDirectConnection(String clientId, int clientPort) {
|
||||
final String id = clientId + clientPort;
|
||||
private Peer bootstrapDirectConnection(String clientId, int port) {
|
||||
Peer peer = null;
|
||||
try {
|
||||
Number160 peerId = Number160.createHash(clientId);
|
||||
|
@ -315,7 +314,7 @@ public class TomP2PTests {
|
|||
cc.maxPermitsTCP(100);
|
||||
cc.maxPermitsUDP(100);
|
||||
peer = new PeerBuilder(peerId).bindings(getBindings()).channelClientConfiguration(cc).peerMap(pm)
|
||||
.ports(clientPort).start();
|
||||
.ports(port).start();
|
||||
FutureDiscover futureDiscover = peer.discover().peerAddress(BOOTSTRAP_NODE_ADDRESS).start();
|
||||
futureDiscover.awaitUninterruptibly();
|
||||
if (futureDiscover.isSuccess()) {
|
||||
|
@ -347,12 +346,11 @@ public class TomP2PTests {
|
|||
}
|
||||
}
|
||||
|
||||
private Peer bootstrapWithPortForwarding(String clientId, int clientPort) {
|
||||
final String id = clientId + clientPort;
|
||||
private Peer bootstrapWithPortForwarding(String clientId, int port) {
|
||||
Peer peer = null;
|
||||
try {
|
||||
peer = new PeerBuilder(Number160.createHash(clientId)).bindings(getBindings()).behindFirewall()
|
||||
.ports(clientPort).start();
|
||||
.ports(port).start();
|
||||
|
||||
PeerNAT peerNAT = new PeerBuilderNAT(peer).start();
|
||||
FutureDiscover futureDiscover = peer.discover().peerAddress(BOOTSTRAP_NODE_ADDRESS).start();
|
||||
|
@ -401,13 +399,11 @@ public class TomP2PTests {
|
|||
}
|
||||
}
|
||||
|
||||
private Peer bootstrapInRelayMode(String clientId, int clientPort) {
|
||||
final String id = clientId + clientPort;
|
||||
|
||||
private Peer bootstrapInRelayMode(String clientId, int port) {
|
||||
Peer peer = null;
|
||||
try {
|
||||
peer = new PeerBuilder(Number160.createHash(clientId)).bindings(getBindings()).behindFirewall()
|
||||
.ports(clientPort).start();
|
||||
.ports(port).start();
|
||||
|
||||
PeerNAT peerNAT = new PeerBuilderNAT(peer).start();
|
||||
FutureDiscover futureDiscover = peer.discover().peerAddress(BOOTSTRAP_NODE_ADDRESS).start();
|
||||
|
@ -444,19 +440,19 @@ public class TomP2PTests {
|
|||
}
|
||||
}
|
||||
|
||||
private Peer bootstrapInUnknownMode(String clientId, int clientPort) {
|
||||
private Peer bootstrapInUnknownMode(String clientId, int port) {
|
||||
resolvedConnectionType = ConnectionType.DIRECT;
|
||||
Peer peer = bootstrapDirectConnection(clientId, clientPort);
|
||||
Peer peer = bootstrapDirectConnection(clientId, port);
|
||||
if (peer != null)
|
||||
return peer;
|
||||
|
||||
resolvedConnectionType = ConnectionType.NAT;
|
||||
peer = bootstrapWithPortForwarding(clientId, clientPort);
|
||||
peer = bootstrapWithPortForwarding(clientId, port);
|
||||
if (peer != null)
|
||||
return peer;
|
||||
|
||||
resolvedConnectionType = ConnectionType.RELAY;
|
||||
peer = bootstrapInRelayMode(clientId, clientPort);
|
||||
peer = bootstrapInRelayMode(clientId, port);
|
||||
if (peer != null)
|
||||
return peer;
|
||||
else
|
||||
|
@ -466,19 +462,19 @@ public class TomP2PTests {
|
|||
return peer;
|
||||
}
|
||||
|
||||
private PeerDHT getDHTPeer(String clientId, int clientPort) {
|
||||
private PeerDHT getDHTPeer(String clientId, int port) {
|
||||
Peer peer;
|
||||
if (FORCED_CONNECTION_TYPE == ConnectionType.DIRECT) {
|
||||
peer = bootstrapDirectConnection(clientId, clientPort);
|
||||
peer = bootstrapDirectConnection(clientId, port);
|
||||
}
|
||||
else if (FORCED_CONNECTION_TYPE == ConnectionType.NAT) {
|
||||
peer = bootstrapWithPortForwarding(clientId, clientPort);
|
||||
peer = bootstrapWithPortForwarding(clientId, port);
|
||||
}
|
||||
else if (FORCED_CONNECTION_TYPE == ConnectionType.RELAY) {
|
||||
peer = bootstrapInRelayMode(clientId, clientPort);
|
||||
peer = bootstrapInRelayMode(clientId, port);
|
||||
}
|
||||
else {
|
||||
peer = bootstrapInUnknownMode(clientId, clientPort);
|
||||
peer = bootstrapInUnknownMode(clientId, port);
|
||||
}
|
||||
|
||||
if (peer == null)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue