Introduce io.bitsquare.network.Node#DEFAULT_PORT

This commit is contained in:
Chris Beams 2014-11-06 09:35:51 +01:00
parent ce5155ebdc
commit da163bcc97
No known key found for this signature in database
GPG key ID: 3D214F8F5BC5ED73
4 changed files with 14 additions and 7 deletions

View file

@ -18,6 +18,7 @@
package io.bitsquare.app; package io.bitsquare.app;
import io.bitsquare.network.BootstrapNode; import io.bitsquare.network.BootstrapNode;
import io.bitsquare.network.Node;
import net.sourceforge.argparse4j.ArgumentParsers; import net.sourceforge.argparse4j.ArgumentParsers;
import net.sourceforge.argparse4j.inf.ArgumentParserException; import net.sourceforge.argparse4j.inf.ArgumentParserException;
@ -37,9 +38,7 @@ public class ArgumentParser {
public static final String PORT_FLAG = "port"; public static final String PORT_FLAG = "port";
public static final String INTERFACE_HINT_FLAG = "interface"; public static final String INTERFACE_HINT_FLAG = "interface";
public static final String NAME_FLAG = "name"; public static final String NAME_FLAG = "name";
public static final String PEER_ID_DEFAULT = BootstrapNode.DIGITAL_OCEAN1.getId();
private static final Integer PORT_DEFAULT = 5000;
private static final String PEER_ID_DEFAULT = BootstrapNode.DIGITAL_OCEAN1.getId();
private final net.sourceforge.argparse4j.inf.ArgumentParser parser; private final net.sourceforge.argparse4j.inf.ArgumentParser parser;
@ -51,7 +50,7 @@ public class ArgumentParser {
.setDefault(PEER_ID_DEFAULT) .setDefault(PEER_ID_DEFAULT)
.help("Seed peer ID."); .help("Seed peer ID.");
parser.addArgument("-p", "--" + PORT_FLAG) parser.addArgument("-p", "--" + PORT_FLAG)
.setDefault(PORT_DEFAULT) .setDefault(Node.DEFAULT_PORT)
.help("IP port to listen on."); .help("IP port to listen on.");
parser.addArgument("-i", "--" + INTERFACE_HINT_FLAG) parser.addArgument("-i", "--" + INTERFACE_HINT_FLAG)
.help("Network interface to listen on."); .help("Network interface to listen on.");

View file

@ -18,13 +18,17 @@
package io.bitsquare.network; package io.bitsquare.network;
public enum BootstrapNode implements Node { public enum BootstrapNode implements Node {
LOCALHOST("localhost", "127.0.0.1", 5000), LOCALHOST("localhost", "127.0.0.1"),
DIGITAL_OCEAN1("digitalocean1.bitsquare.io", "188.226.179.109", 5000); DIGITAL_OCEAN1("digitalocean1.bitsquare.io", "188.226.179.109");
private final String id; private final String id;
private final String ip; private final String ip;
private final int port; private final int port;
BootstrapNode(String id, String ip) {
this(id, ip, DEFAULT_PORT);
}
BootstrapNode(String id, String ip, int port) { BootstrapNode(String id, String ip, int port) {
this.id = id; this.id = id;
this.ip = ip; this.ip = ip;

View file

@ -19,6 +19,8 @@ package io.bitsquare.network;
public interface Node { public interface Node {
public static final int DEFAULT_PORT = 5000;
String getId(); String getId();
String getIp(); String getIp();

View file

@ -17,6 +17,8 @@
package io.bitsquare.msg; package io.bitsquare.msg;
import io.bitsquare.network.Node;
import net.tomp2p.dht.PeerBuilderDHT; import net.tomp2p.dht.PeerBuilderDHT;
import net.tomp2p.dht.PeerDHT; import net.tomp2p.dht.PeerDHT;
import net.tomp2p.nat.PeerBuilderNAT; import net.tomp2p.nat.PeerBuilderNAT;
@ -37,7 +39,7 @@ public class SeedNodeForTesting {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
// Define your seed node IP and port // Define your seed node IP and port
// "127.0.0.1" for localhost or SEED_ID_WAN_1 // "127.0.0.1" for localhost or SEED_ID_WAN_1
new SeedNodeForTesting().startSeedNode("localhost", 5000); new SeedNodeForTesting().startSeedNode("localhost", Node.DEFAULT_PORT);
} }
public Thread startSeedNode(String seedNodeId, int seedNodePort) { public Thread startSeedNode(String seedNodeId, int seedNodePort) {