mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-06-07 14:42:51 -04:00
Add interface argument
This commit is contained in:
parent
775a391be3
commit
05a86f251f
4 changed files with 23 additions and 2 deletions
|
@ -41,6 +41,10 @@ public class ArgumentParser {
|
||||||
parser.addArgument("-p", "--" + BOOTSTRAP_NODE_PORT_KEY)
|
parser.addArgument("-p", "--" + BOOTSTRAP_NODE_PORT_KEY)
|
||||||
.help("Seed node port");
|
.help("Seed node port");
|
||||||
|
|
||||||
|
// A custom network interface (needed at the moment for windows, but might be useful also later)
|
||||||
|
parser.addArgument("-i", "--" + NETWORK_INTERFACE_KEY)
|
||||||
|
.help("Network interface");
|
||||||
|
|
||||||
// Args for app config
|
// Args for app config
|
||||||
parser.addArgument("-n", "--" + APP_NAME_KEY)
|
parser.addArgument("-n", "--" + APP_NAME_KEY)
|
||||||
.help("Name to append to default application name");
|
.help("Name to append to default application name");
|
||||||
|
|
|
@ -79,6 +79,9 @@ public class Main extends Application {
|
||||||
if (argumentsNamespace.getString(BOOTSTRAP_NODE_PORT_KEY) != null)
|
if (argumentsNamespace.getString(BOOTSTRAP_NODE_PORT_KEY) != null)
|
||||||
properties.setProperty(BOOTSTRAP_NODE_PORT_KEY, argumentsNamespace.getString(BOOTSTRAP_NODE_PORT_KEY));
|
properties.setProperty(BOOTSTRAP_NODE_PORT_KEY, argumentsNamespace.getString(BOOTSTRAP_NODE_PORT_KEY));
|
||||||
|
|
||||||
|
if (argumentsNamespace.getString(NETWORK_INTERFACE_KEY) != null)
|
||||||
|
properties.setProperty(NETWORK_INTERFACE_KEY, argumentsNamespace.getString(NETWORK_INTERFACE_KEY));
|
||||||
|
|
||||||
Application.launch(Main.class, args);
|
Application.launch(Main.class, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,7 @@ public abstract class MessageModule extends BitsquareModule {
|
||||||
public static final String BOOTSTRAP_NODE_ID_KEY = "id";
|
public static final String BOOTSTRAP_NODE_ID_KEY = "id";
|
||||||
public static final String BOOTSTRAP_NODE_IP_KEY = "ip";
|
public static final String BOOTSTRAP_NODE_IP_KEY = "ip";
|
||||||
public static final String BOOTSTRAP_NODE_PORT_KEY = "port";
|
public static final String BOOTSTRAP_NODE_PORT_KEY = "port";
|
||||||
|
public static final String NETWORK_INTERFACE_KEY = "networkInterface";
|
||||||
|
|
||||||
protected MessageModule(Properties properties) {
|
protected MessageModule(Properties properties) {
|
||||||
super(properties);
|
super(properties);
|
||||||
|
@ -54,6 +55,10 @@ public abstract class MessageModule extends BitsquareModule {
|
||||||
.annotatedWith(Names.named("bootstrapNode"))
|
.annotatedWith(Names.named("bootstrapNode"))
|
||||||
.toInstance(bootstrapNode);
|
.toInstance(bootstrapNode);
|
||||||
|
|
||||||
|
bind(String.class)
|
||||||
|
.annotatedWith(Names.named("networkInterface"))
|
||||||
|
.toInstance(properties.getProperty(NETWORK_INTERFACE_KEY, ""));
|
||||||
|
|
||||||
doConfigure();
|
doConfigure();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,7 @@ import javafx.application.Platform;
|
||||||
import javafx.beans.property.ObjectProperty;
|
import javafx.beans.property.ObjectProperty;
|
||||||
import javafx.beans.property.SimpleObjectProperty;
|
import javafx.beans.property.SimpleObjectProperty;
|
||||||
|
|
||||||
|
import net.tomp2p.connection.Bindings;
|
||||||
import net.tomp2p.connection.ChannelClientConfiguration;
|
import net.tomp2p.connection.ChannelClientConfiguration;
|
||||||
import net.tomp2p.dht.PeerBuilderDHT;
|
import net.tomp2p.dht.PeerBuilderDHT;
|
||||||
import net.tomp2p.dht.PeerDHT;
|
import net.tomp2p.dht.PeerDHT;
|
||||||
|
@ -76,6 +77,7 @@ class BootstrappedPeerFactory {
|
||||||
private KeyPair keyPair;
|
private KeyPair keyPair;
|
||||||
private Storage storage;
|
private Storage storage;
|
||||||
private final Node bootstrapNode;
|
private final Node bootstrapNode;
|
||||||
|
private String networkInterface;
|
||||||
private final Persistence persistence;
|
private final Persistence persistence;
|
||||||
|
|
||||||
private final SettableFuture<PeerDHT> settableFuture = SettableFuture.create();
|
private final SettableFuture<PeerDHT> settableFuture = SettableFuture.create();
|
||||||
|
@ -89,9 +91,11 @@ class BootstrappedPeerFactory {
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public BootstrappedPeerFactory(Persistence persistence, @Named("bootstrapNode") Node bootstrapNode) {
|
public BootstrappedPeerFactory(Persistence persistence, @Named("bootstrapNode") Node bootstrapNode,
|
||||||
|
@Named("networkInterface") String networkInterface) {
|
||||||
this.persistence = persistence;
|
this.persistence = persistence;
|
||||||
this.bootstrapNode = bootstrapNode;
|
this.bootstrapNode = bootstrapNode;
|
||||||
|
this.networkInterface = networkInterface;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -122,7 +126,12 @@ class BootstrappedPeerFactory {
|
||||||
ChannelClientConfiguration cc = PeerBuilder.createDefaultChannelClientConfiguration();
|
ChannelClientConfiguration cc = PeerBuilder.createDefaultChannelClientConfiguration();
|
||||||
cc.maxPermitsTCP(100);
|
cc.maxPermitsTCP(100);
|
||||||
cc.maxPermitsUDP(100);
|
cc.maxPermitsUDP(100);
|
||||||
peer = new PeerBuilder(keyPair).ports(port).peerMap(pm).channelClientConfiguration(cc).start();
|
Bindings bindings = new Bindings();
|
||||||
|
if (!networkInterface.equals(""))
|
||||||
|
bindings.addInterface(networkInterface);
|
||||||
|
|
||||||
|
peer = new PeerBuilder(keyPair).ports(port).peerMap(pm).bindings(bindings)
|
||||||
|
.channelClientConfiguration(cc).start();
|
||||||
peerDHT = new PeerBuilderDHT(peer).storageLayer(new StorageLayer(storage)).start();
|
peerDHT = new PeerBuilderDHT(peer).storageLayer(new StorageLayer(storage)).start();
|
||||||
|
|
||||||
peer.peerBean().peerMap().addPeerMapChangeListener(new PeerMapChangeListener() {
|
peer.peerBean().peerMap().addPeerMapChangeListener(new PeerMapChangeListener() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue