mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-12-14 15:36:27 -05:00
Add network info screen
This commit is contained in:
parent
60102661ff
commit
526727134f
8 changed files with 163 additions and 18 deletions
|
|
@ -25,6 +25,6 @@
|
||||||
xmlns:fx="http://javafx.com/fxml">
|
xmlns:fx="http://javafx.com/fxml">
|
||||||
|
|
||||||
<Tab fx:id="applicationTab" text="Application preferences" closable="false"/>
|
<Tab fx:id="applicationTab" text="Application preferences" closable="false"/>
|
||||||
<Tab fx:id="networkTab" text="Network preferences" closable="false"/>
|
<Tab fx:id="networkTab" text="Network" closable="false"/>
|
||||||
|
|
||||||
</TabPane>
|
</TabPane>
|
||||||
|
|
|
||||||
|
|
@ -29,13 +29,13 @@
|
||||||
xmlns:fx="http://javafx.com/fxml">
|
xmlns:fx="http://javafx.com/fxml">
|
||||||
|
|
||||||
<padding>
|
<padding>
|
||||||
<Insets bottom="-10.0" left="25.0" top="30.0" right="25"/>
|
<Insets bottom="10.0" left="25.0" top="30.0" right="25"/>
|
||||||
</padding>
|
</padding>
|
||||||
|
|
||||||
<TitledGroupBg text="General application preferences" GridPane.rowSpan="8"/>
|
<TitledGroupBg text="General application preferences" GridPane.rowSpan="8"/>
|
||||||
|
|
||||||
<Label text="Bitcoin denomination" GridPane.rowIndex="0">
|
<Label text="Bitcoin denomination:" GridPane.rowIndex="0">
|
||||||
<GridPane.margin>
|
<GridPane.margin>
|
||||||
<Insets top="10"/>
|
<Insets top="10"/>
|
||||||
</GridPane.margin>
|
</GridPane.margin>
|
||||||
</Label>
|
</Label>
|
||||||
|
|
@ -51,9 +51,17 @@
|
||||||
<CheckBox fx:id="useAnimationsCheckBox"
|
<CheckBox fx:id="useAnimationsCheckBox"
|
||||||
GridPane.columnIndex="1" GridPane.rowIndex="1"/>
|
GridPane.columnIndex="1" GridPane.rowIndex="1"/>
|
||||||
|
|
||||||
<Label text="Use effects:" GridPane.rowIndex="2"/>
|
<Label text="Use effects:" GridPane.rowIndex="2">
|
||||||
|
<GridPane.margin>
|
||||||
|
<Insets bottom="-15"/>
|
||||||
|
</GridPane.margin>
|
||||||
|
</Label>
|
||||||
<CheckBox fx:id="useEffectsCheckBox"
|
<CheckBox fx:id="useEffectsCheckBox"
|
||||||
GridPane.columnIndex="1" GridPane.rowIndex="2"/>
|
GridPane.columnIndex="1" GridPane.rowIndex="2">
|
||||||
|
<GridPane.margin>
|
||||||
|
<Insets bottom="-15"/>
|
||||||
|
</GridPane.margin>
|
||||||
|
</CheckBox>
|
||||||
|
|
||||||
<columnConstraints>
|
<columnConstraints>
|
||||||
<ColumnConstraints hgrow="SOMETIMES" halignment="RIGHT" minWidth="200.0"/>
|
<ColumnConstraints hgrow="SOMETIMES" halignment="RIGHT" minWidth="200.0"/>
|
||||||
|
|
|
||||||
|
|
@ -17,9 +17,19 @@
|
||||||
|
|
||||||
package io.bitsquare.gui.main.preferences.network;
|
package io.bitsquare.gui.main.preferences.network;
|
||||||
|
|
||||||
|
import io.bitsquare.BitsquareException;
|
||||||
import io.bitsquare.gui.UIModel;
|
import io.bitsquare.gui.UIModel;
|
||||||
|
import io.bitsquare.msg.tomp2p.BootstrappedPeerFactory;
|
||||||
|
import io.bitsquare.msg.tomp2p.TomP2PNode;
|
||||||
|
import io.bitsquare.network.BootstrapState;
|
||||||
|
import io.bitsquare.network.Node;
|
||||||
|
|
||||||
|
import org.bitcoinj.core.NetworkParameters;
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
|
import com.google.inject.name.Named;
|
||||||
|
|
||||||
|
import net.tomp2p.peers.PeerSocketAddress;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
@ -27,13 +37,55 @@ import org.slf4j.LoggerFactory;
|
||||||
class NetworkPreferencesModel extends UIModel {
|
class NetworkPreferencesModel extends UIModel {
|
||||||
private static final Logger log = LoggerFactory.getLogger(NetworkPreferencesModel.class);
|
private static final Logger log = LoggerFactory.getLogger(NetworkPreferencesModel.class);
|
||||||
|
|
||||||
|
final String bitcoinNetworkType;
|
||||||
|
final String p2pNetworkConnection;
|
||||||
|
final String p2pNetworkAddress;
|
||||||
|
final String bootstrapAddress;
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Constructor
|
// Constructor
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
NetworkPreferencesModel() {
|
NetworkPreferencesModel(NetworkParameters networkParameters,
|
||||||
|
BootstrappedPeerFactory bootstrappedPeerFactory,
|
||||||
|
TomP2PNode tomP2PNode,
|
||||||
|
@Named(BootstrappedPeerFactory.BOOTSTRAP_NODE_KEY) Node bootstrapNode) {
|
||||||
|
|
||||||
|
switch (networkParameters.getId()) {
|
||||||
|
case NetworkParameters.ID_REGTEST:
|
||||||
|
bitcoinNetworkType = "Regtest";
|
||||||
|
break;
|
||||||
|
case NetworkParameters.ID_TESTNET:
|
||||||
|
bitcoinNetworkType = "Testnet";
|
||||||
|
break;
|
||||||
|
case NetworkParameters.ID_MAINNET:
|
||||||
|
bitcoinNetworkType = "Mainnet";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
bitcoinNetworkType = "Undefined";
|
||||||
|
throw new BitsquareException("Invalid networkParameters " + networkParameters.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
PeerSocketAddress socketAddress = tomP2PNode.getPeerDHT().peerAddress().peerSocketAddress();
|
||||||
|
p2pNetworkAddress = "IP: " + socketAddress.inetAddress().getHostAddress()
|
||||||
|
+ ", TCP port: " + socketAddress.tcpPort()
|
||||||
|
+ ", UDP port: " + socketAddress.udpPort();
|
||||||
|
|
||||||
|
bootstrapAddress = "ID: " + bootstrapNode.getName()
|
||||||
|
+ ", IP: " + bootstrapNode.getIp()
|
||||||
|
+ ", Port: " + bootstrapNode.getPortAsString();
|
||||||
|
|
||||||
|
BootstrapState state = bootstrappedPeerFactory.bootstrapState.get();
|
||||||
|
if (state == BootstrapState.DIRECT_SUCCESS)
|
||||||
|
p2pNetworkConnection = "Direct connection";
|
||||||
|
else if (state == BootstrapState.NAT_SUCCESS)
|
||||||
|
p2pNetworkConnection = "Connected with automatic port forwarding";
|
||||||
|
else if (state == BootstrapState.RELAY_SUCCESS)
|
||||||
|
p2pNetworkConnection = "Relayed by other peers";
|
||||||
|
else
|
||||||
|
throw new BitsquareException("Invalid BootstrapState " + state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -41,22 +93,22 @@ class NetworkPreferencesModel extends UIModel {
|
||||||
// Lifecycle
|
// Lifecycle
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
@SuppressWarnings("EmptyMethod")
|
||||||
@Override
|
@Override
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
|
|
||||||
super.initialize();
|
super.initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("EmptyMethod")
|
||||||
@Override
|
@Override
|
||||||
public void activate() {
|
public void activate() {
|
||||||
super.activate();
|
super.activate();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("EmptyMethod")
|
||||||
@Override
|
@Override
|
||||||
public void deactivate() {
|
public void deactivate() {
|
||||||
super.deactivate();
|
super.deactivate();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("EmptyMethod")
|
@SuppressWarnings("EmptyMethod")
|
||||||
|
|
|
||||||
|
|
@ -42,12 +42,13 @@ public class NetworkPreferencesPM extends PresentationModel<NetworkPreferencesMo
|
||||||
// Lifecycle
|
// Lifecycle
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
@SuppressWarnings("EmptyMethod")
|
||||||
@Override
|
@Override
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
|
|
||||||
super.initialize();
|
super.initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("EmptyMethod")
|
||||||
@Override
|
@Override
|
||||||
public void activate() {
|
public void activate() {
|
||||||
super.activate();
|
super.activate();
|
||||||
|
|
@ -75,7 +76,22 @@ public class NetworkPreferencesPM extends PresentationModel<NetworkPreferencesMo
|
||||||
// Getters
|
// Getters
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
String bitcoinNetworkType() {
|
||||||
|
return model.bitcoinNetworkType;
|
||||||
|
}
|
||||||
|
|
||||||
|
String p2pNetworkConnection() {
|
||||||
|
return model.p2pNetworkConnection;
|
||||||
|
}
|
||||||
|
|
||||||
|
String p2pNetworkAddress() {
|
||||||
|
return model.p2pNetworkAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
String bootstrapAddress() {
|
||||||
|
return model.bootstrapAddress;
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Private
|
// Private
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
||||||
|
|
@ -17,10 +17,65 @@
|
||||||
~ along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
~ along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
<?import io.bitsquare.gui.components.TitledGroupBg?>
|
||||||
|
<?import javafx.geometry.Insets?>
|
||||||
|
<?import javafx.scene.control.*?>
|
||||||
<?import javafx.scene.layout.*?>
|
<?import javafx.scene.layout.*?>
|
||||||
<AnchorPane fx:id="root" fx:controller="io.bitsquare.gui.main.preferences.network.NetworkPreferencesViewCB"
|
<GridPane fx:id="root" fx:controller="io.bitsquare.gui.main.preferences.network.NetworkPreferencesViewCB"
|
||||||
xmlns:fx="http://javafx.com/fxml">
|
hgap="5.0" vgap="5.0"
|
||||||
|
AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
|
||||||
|
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"
|
||||||
|
xmlns:fx="http://javafx.com/fxml">
|
||||||
|
|
||||||
|
<padding>
|
||||||
|
<Insets bottom="10.0" left="25.0" top="30.0" right="25"/>
|
||||||
|
</padding>
|
||||||
|
|
||||||
|
<TitledGroupBg text="Network information" GridPane.rowSpan="8"/>
|
||||||
|
|
||||||
|
<Label text="Bitcoin network type:" GridPane.rowIndex="0">
|
||||||
|
<GridPane.margin>
|
||||||
|
<Insets top="10"/>
|
||||||
|
</GridPane.margin>
|
||||||
|
</Label>
|
||||||
|
<TextField fx:id="bitcoinNetworkType" GridPane.rowIndex="0" GridPane.columnIndex="1"
|
||||||
|
mouseTransparent="true" editable="false" focusTraversable="false">
|
||||||
|
<GridPane.margin>
|
||||||
|
<Insets top="10"/>
|
||||||
|
</GridPane.margin>
|
||||||
|
</TextField>
|
||||||
|
|
||||||
|
<Label text="P2P network connection:" GridPane.rowIndex="1"/>
|
||||||
|
<TextField fx:id="p2pNetworkConnection" GridPane.rowIndex="1" GridPane.columnIndex="1"
|
||||||
|
mouseTransparent="true" editable="false" focusTraversable="false"/>
|
||||||
|
|
||||||
|
<Label text="My external visible P2P network address:" GridPane.rowIndex="2"/>
|
||||||
|
<TextField fx:id="p2pNetworkAddress" GridPane.rowIndex="2" GridPane.columnIndex="1"
|
||||||
|
mouseTransparent="true" editable="false" focusTraversable="false"/>
|
||||||
|
|
||||||
|
<Label text="P2P bootstrap node address:" GridPane.rowIndex="3">
|
||||||
|
<GridPane.margin>
|
||||||
|
<Insets bottom="-15"/>
|
||||||
|
</GridPane.margin>
|
||||||
|
</Label>
|
||||||
|
<TextField fx:id="bootstrapAddress" GridPane.rowIndex="3" GridPane.columnIndex="1"
|
||||||
|
mouseTransparent="true" editable="false" focusTraversable="false">
|
||||||
|
<GridPane.margin>
|
||||||
|
<Insets bottom="-15"/>
|
||||||
|
</GridPane.margin>
|
||||||
|
</TextField>
|
||||||
|
|
||||||
|
<columnConstraints>
|
||||||
|
<ColumnConstraints hgrow="SOMETIMES" halignment="RIGHT" minWidth="200.0"/>
|
||||||
|
<ColumnConstraints hgrow="ALWAYS" minWidth="300.0"/>
|
||||||
|
</columnConstraints>
|
||||||
|
|
||||||
|
<rowConstraints>
|
||||||
|
<RowConstraints vgrow="NEVER"/>
|
||||||
|
<RowConstraints vgrow="NEVER"/>
|
||||||
|
<RowConstraints vgrow="NEVER"/>
|
||||||
|
</rowConstraints>
|
||||||
|
|
||||||
|
</GridPane>
|
||||||
|
|
||||||
</AnchorPane>
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,9 @@ import java.util.ResourceBundle;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import javafx.fxml.FXML;
|
||||||
|
import javafx.scene.control.*;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
|
@ -35,6 +38,8 @@ public class NetworkPreferencesViewCB extends CachedViewCB<NetworkPreferencesPM>
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(NetworkPreferencesViewCB.class);
|
private static final Logger log = LoggerFactory.getLogger(NetworkPreferencesViewCB.class);
|
||||||
|
|
||||||
|
@FXML TextField bitcoinNetworkType, p2pNetworkConnection, p2pNetworkAddress, bootstrapAddress;
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Constructor
|
// Constructor
|
||||||
|
|
@ -50,9 +55,9 @@ public class NetworkPreferencesViewCB extends CachedViewCB<NetworkPreferencesPM>
|
||||||
// Lifecycle
|
// Lifecycle
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
@SuppressWarnings("EmptyMethod")
|
||||||
@Override
|
@Override
|
||||||
public void initialize(URL url, ResourceBundle rb) {
|
public void initialize(URL url, ResourceBundle rb) {
|
||||||
|
|
||||||
super.initialize(url, rb);
|
super.initialize(url, rb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -60,8 +65,13 @@ public class NetworkPreferencesViewCB extends CachedViewCB<NetworkPreferencesPM>
|
||||||
public void activate() {
|
public void activate() {
|
||||||
super.activate();
|
super.activate();
|
||||||
|
|
||||||
|
bitcoinNetworkType.setText(presentationModel.bitcoinNetworkType());
|
||||||
|
p2pNetworkConnection.setText(presentationModel.p2pNetworkConnection());
|
||||||
|
p2pNetworkAddress.setText(presentationModel.p2pNetworkAddress());
|
||||||
|
bootstrapAddress.setText(presentationModel.bootstrapAddress());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("EmptyMethod")
|
||||||
@Override
|
@Override
|
||||||
public void deactivate() {
|
public void deactivate() {
|
||||||
super.deactivate();
|
super.deactivate();
|
||||||
|
|
|
||||||
|
|
@ -70,10 +70,10 @@ import org.slf4j.LoggerFactory;
|
||||||
/**
|
/**
|
||||||
* Creates a DHT peer and bootstraps to the network via a bootstrap node
|
* Creates a DHT peer and bootstraps to the network via a bootstrap node
|
||||||
*/
|
*/
|
||||||
class BootstrappedPeerFactory {
|
public class BootstrappedPeerFactory {
|
||||||
private static final Logger log = LoggerFactory.getLogger(BootstrappedPeerFactory.class);
|
private static final Logger log = LoggerFactory.getLogger(BootstrappedPeerFactory.class);
|
||||||
|
|
||||||
static final String BOOTSTRAP_NODE_KEY = "bootstrapNode";
|
public static final String BOOTSTRAP_NODE_KEY = "bootstrapNode";
|
||||||
static final String NETWORK_INTERFACE_KEY = "interface";
|
static final String NETWORK_INTERFACE_KEY = "interface";
|
||||||
static final String NETWORK_INTERFACE_UNSPECIFIED = "<unspecified>";
|
static final String NETWORK_INTERFACE_UNSPECIFIED = "<unspecified>";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -77,6 +77,7 @@ public class TomP2PNode {
|
||||||
private MessageBroker messageBroker;
|
private MessageBroker messageBroker;
|
||||||
|
|
||||||
private PeerAddress storedPeerAddress;
|
private PeerAddress storedPeerAddress;
|
||||||
|
|
||||||
private PeerDHT peerDHT;
|
private PeerDHT peerDHT;
|
||||||
private BootstrappedPeerFactory bootstrappedPeerFactory;
|
private BootstrappedPeerFactory bootstrappedPeerFactory;
|
||||||
|
|
||||||
|
|
@ -143,6 +144,9 @@ public class TomP2PNode {
|
||||||
peerDHT.peer().shutdown();
|
peerDHT.peer().shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PeerDHT getPeerDHT() {
|
||||||
|
return peerDHT;
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Generic DHT methods
|
// Generic DHT methods
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue