mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-03-14 18:06:34 -04:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
1fddf079b7
@ -45,6 +45,7 @@ public class BitSquare {
|
||||
|
||||
private static String appName = "Bitsquare";
|
||||
private static int clientPort;
|
||||
private static String interfaceHint;
|
||||
|
||||
public static String getAppName() {
|
||||
return appName;
|
||||
@ -70,6 +71,10 @@ public class BitSquare {
|
||||
appName = appName + "-" + namespace.getString(BitsquareArgumentParser.NAME_FLAG);
|
||||
}
|
||||
|
||||
if (namespace.getString(BitsquareArgumentParser.INFHINT_FLAG) != null) {
|
||||
interfaceHint = namespace.getString(BitsquareArgumentParser.INFHINT_FLAG);
|
||||
}
|
||||
|
||||
if (namespace.getBoolean(BitsquareArgumentParser.SEED_FLAG) == true) {
|
||||
Integer port = BitsquareArgumentParser.PORT_DEFAULT;
|
||||
if (namespace.getString(BitsquareArgumentParser.PORT_FLAG) != null) {
|
||||
@ -80,7 +85,7 @@ public class BitSquare {
|
||||
|
||||
ActorRef seedNode = actorSystem.actorOf(DHTManager.getProps(), DHTManager.SEED_NAME);
|
||||
Inbox inbox = Inbox.create(actorSystem);
|
||||
inbox.send(seedNode, new InitializePeer(Number160.createHash("localhost"), port, null));
|
||||
inbox.send(seedNode, new InitializePeer(Number160.createHash("localhost"), port, interfaceHint, null));
|
||||
|
||||
Thread seedNodeThread = new Thread(() -> {
|
||||
Boolean quit = false;
|
||||
|
@ -42,6 +42,6 @@ public class DHTSeedService extends ActorService {
|
||||
public void initializePeer(String id, Integer port) {
|
||||
|
||||
// TODO hard coded seed peer config for now, should read from config properties file
|
||||
send(new InitializePeer(Number160.createHash(id), port, null));
|
||||
send(new InitializePeer(Number160.createHash(id), port, null, null));
|
||||
}
|
||||
}
|
||||
|
@ -20,15 +20,13 @@ package io.bitsquare.msg.actor;
|
||||
import io.bitsquare.msg.actor.command.InitializePeer;
|
||||
import io.bitsquare.msg.actor.event.PeerInitialized;
|
||||
|
||||
import net.tomp2p.connection.Bindings;
|
||||
import net.tomp2p.dht.PeerBuilderDHT;
|
||||
import net.tomp2p.dht.PeerDHT;
|
||||
import net.tomp2p.nat.PeerBuilderNAT;
|
||||
import net.tomp2p.nat.PeerNAT;
|
||||
import net.tomp2p.p2p.Peer;
|
||||
import net.tomp2p.p2p.PeerBuilder;
|
||||
import net.tomp2p.relay.FutureRelay;
|
||||
import net.tomp2p.relay.RconRPC;
|
||||
import net.tomp2p.relay.RelayRPC;
|
||||
|
||||
import akka.actor.AbstractActor;
|
||||
import akka.actor.Props;
|
||||
@ -51,6 +49,7 @@ public class DHTManager extends AbstractActor {
|
||||
return Props.create(DHTManager.class);
|
||||
}
|
||||
|
||||
private Bindings bindings;
|
||||
private Peer peer;
|
||||
private PeerDHT peerDHT;
|
||||
private PeerNAT peerNAT;
|
||||
@ -61,7 +60,11 @@ public class DHTManager extends AbstractActor {
|
||||
log.debug("Received message: {}", ip);
|
||||
|
||||
try {
|
||||
peer = new PeerBuilder(ip.getPeerId()).ports(ip.getPort()).start();
|
||||
bindings = new Bindings();
|
||||
if (ip.getInterfaceHint() != null) {
|
||||
bindings.addInterface(ip.getInterfaceHint());
|
||||
}
|
||||
peer = new PeerBuilder(ip.getPeerId()).ports(ip.getPort()).bindings(bindings).start();
|
||||
|
||||
peerDHT = new PeerBuilderDHT(peer).start();
|
||||
peerNAT = new PeerBuilderNAT(peer).start();
|
||||
@ -84,6 +87,7 @@ public class DHTManager extends AbstractActor {
|
||||
peerDHT.shutdown();
|
||||
if (peerNAT != null)
|
||||
peerNAT.natUtils().shutdown();
|
||||
|
||||
super.postStop();
|
||||
}
|
||||
}
|
||||
|
@ -30,11 +30,15 @@ public class InitializePeer {
|
||||
|
||||
private final Number160 peerId;
|
||||
private final Integer port;
|
||||
private final String interfaceHint;
|
||||
|
||||
private final Collection<PeerAddress> bootstrapPeers;
|
||||
|
||||
public InitializePeer(Number160 peerId, Integer port, Collection<PeerAddress> bootstrapPeers) {
|
||||
public InitializePeer(Number160 peerId, Integer port, String interfaceHint,
|
||||
Collection<PeerAddress> bootstrapPeers) {
|
||||
this.peerId = peerId;
|
||||
this.port = port;
|
||||
this.interfaceHint = interfaceHint;
|
||||
this.bootstrapPeers = bootstrapPeers;
|
||||
}
|
||||
|
||||
@ -46,6 +50,10 @@ public class InitializePeer {
|
||||
return port;
|
||||
}
|
||||
|
||||
public String getInterfaceHint() {
|
||||
return interfaceHint;
|
||||
}
|
||||
|
||||
public Collection<PeerAddress> getBootstrapPeers() {
|
||||
return bootstrapPeers;
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ public class BitsquareArgumentParser {
|
||||
public static String SEED_FLAG = "seed";
|
||||
public static String PORT_FLAG = "port";
|
||||
public static Integer PORT_DEFAULT = 5000;
|
||||
public static String INFHINT_FLAG = "interface";
|
||||
public static String NAME_FLAG = "name";
|
||||
|
||||
private final ArgumentParser parser;
|
||||
@ -42,6 +43,8 @@ public class BitsquareArgumentParser {
|
||||
parser.addArgument("-p", "--"+PORT_FLAG)
|
||||
.setDefault(PORT_DEFAULT)
|
||||
.help("IP port to listen on.");
|
||||
parser.addArgument("-i", "--"+INFHINT_FLAG)
|
||||
.help("interface to listen on.");
|
||||
parser.addArgument("-n", "--"+NAME_FLAG)
|
||||
.help("Append name to application name.");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user