mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-06-19 12:24:19 -04:00
Fix auth handshake, add missing img
This commit is contained in:
parent
d666c6cd3b
commit
7c4bf8680b
11 changed files with 30 additions and 25 deletions
|
@ -67,6 +67,10 @@ To run it use:
|
||||||
|
|
||||||
$ java -jar gui/target/shaded.jar
|
$ java -jar gui/target/shaded.jar
|
||||||
|
|
||||||
|
For developing the following program arguments are useful (regtest mode):
|
||||||
|
|
||||||
|
$ java -jar gui/target/shaded.jar --bitcoin.network=regtest --useLocalhost=true --node.port=2222 --devTest=true --app.name=Bitsquare-Regtest-Alice
|
||||||
|
|
||||||
Problems?
|
Problems?
|
||||||
---------
|
---------
|
||||||
|
|
||||||
|
|
|
@ -74,8 +74,8 @@
|
||||||
</GridPane.margin>
|
</GridPane.margin>
|
||||||
</TextField>
|
</TextField>
|
||||||
|
|
||||||
<Label text="Authenticated peers:" GridPane.rowIndex="5"/>
|
<Label text="Authenticated peers:" GridPane.rowIndex="4"/>
|
||||||
<TextArea fx:id="authenticatedPeersTextArea" GridPane.rowIndex="7" GridPane.columnIndex="1"
|
<TextArea fx:id="authenticatedPeersTextArea" GridPane.rowIndex="4" GridPane.columnIndex="1"
|
||||||
mouseTransparent="true" focusTraversable="false"/>
|
mouseTransparent="true" focusTraversable="false"/>
|
||||||
|
|
||||||
<columnConstraints>
|
<columnConstraints>
|
||||||
|
|
BIN
gui/src/main/resources/images/connection/tor.png
Normal file
BIN
gui/src/main/resources/images/connection/tor.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
BIN
gui/src/main/resources/images/connection/tor@2x.png
Normal file
BIN
gui/src/main/resources/images/connection/tor@2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.3 KiB |
|
@ -21,13 +21,13 @@ import java.util.*;
|
||||||
|
|
||||||
|
|
||||||
// authentication example:
|
// authentication example:
|
||||||
// node2 -> node1 RequestAuthenticationMessage
|
// node2 -> node1 AuthenticationRequest
|
||||||
// node1: close connection
|
// node1: close connection
|
||||||
// node1 -> node2 ChallengeMessage on new connection
|
// node1 -> node2 AuthenticationResponse on new connection
|
||||||
// node2: authentication to node1 done if nonce ok
|
// node2: authentication to node1 done if nonce ok
|
||||||
// node2 -> node1 GetPeersMessage
|
// node2 -> node1 GetPeersAuthRequest
|
||||||
// node1: authentication to node2 done if nonce ok
|
// node1: authentication to node2 done if nonce ok
|
||||||
// node1 -> node2 PeersMessage
|
// node1 -> node2 GetPeersAuthResponse
|
||||||
|
|
||||||
public class AuthenticationHandshake implements MessageListener {
|
public class AuthenticationHandshake implements MessageListener {
|
||||||
private static final Logger log = LoggerFactory.getLogger(AuthenticationHandshake.class);
|
private static final Logger log = LoggerFactory.getLogger(AuthenticationHandshake.class);
|
||||||
|
@ -77,12 +77,12 @@ public class AuthenticationHandshake implements MessageListener {
|
||||||
Futures.addCallback(future, new FutureCallback<Connection>() {
|
Futures.addCallback(future, new FutureCallback<Connection>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(Connection connection) {
|
public void onSuccess(Connection connection) {
|
||||||
log.trace("GetPeersMessage sent successfully from " + myAddress + " to " + peerAddress);
|
log.trace("GetPeersAuthRequest sent successfully from " + myAddress + " to " + peerAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(@NotNull Throwable throwable) {
|
public void onFailure(@NotNull Throwable throwable) {
|
||||||
log.info("GetPeersMessage sending failed " + throwable.getMessage());
|
log.info("GetPeersAuthRequest sending failed " + throwable.getMessage());
|
||||||
onFault(throwable);
|
onFault(throwable);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -104,17 +104,17 @@ public class AuthenticationHandshake implements MessageListener {
|
||||||
|
|
||||||
SettableFuture<Connection> future = networkNode.sendMessage(peerAddress,
|
SettableFuture<Connection> future = networkNode.sendMessage(peerAddress,
|
||||||
new GetPeersAuthResponse(myAddress, new HashSet<>(peerGroup.getAllPeerAddresses())));
|
new GetPeersAuthResponse(myAddress, new HashSet<>(peerGroup.getAllPeerAddresses())));
|
||||||
log.trace("sent PeersMessage to " + peerAddress + " from " + myAddress
|
log.trace("sent GetPeersAuthResponse to " + peerAddress + " from " + myAddress
|
||||||
+ " with allPeers=" + peerGroup.getAllPeerAddresses());
|
+ " with allPeers=" + peerGroup.getAllPeerAddresses());
|
||||||
Futures.addCallback(future, new FutureCallback<Connection>() {
|
Futures.addCallback(future, new FutureCallback<Connection>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(Connection connection) {
|
public void onSuccess(Connection connection) {
|
||||||
log.trace("PeersMessage sent successfully from " + myAddress + " to " + peerAddress);
|
log.trace("GetPeersAuthResponse sent successfully from " + myAddress + " to " + peerAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(@NotNull Throwable throwable) {
|
public void onFailure(@NotNull Throwable throwable) {
|
||||||
log.info("PeersMessage sending failed " + throwable.getMessage());
|
log.info("GetPeersAuthResponse sending failed " + throwable.getMessage());
|
||||||
onFault(throwable);
|
onFault(throwable);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -132,16 +132,16 @@ public class AuthenticationHandshake implements MessageListener {
|
||||||
// Requesting peer
|
// Requesting peer
|
||||||
GetPeersAuthResponse getPeersAuthResponse = (GetPeersAuthResponse) message;
|
GetPeersAuthResponse getPeersAuthResponse = (GetPeersAuthResponse) message;
|
||||||
Address peerAddress = getPeersAuthResponse.address;
|
Address peerAddress = getPeersAuthResponse.address;
|
||||||
log.trace("PeersMessage from " + peerAddress + " at " + myAddress);
|
log.trace("GetPeersAuthResponse from " + peerAddress + " at " + myAddress);
|
||||||
HashSet<Address> peerAddresses = getPeersAuthResponse.peerAddresses;
|
HashSet<Address> peerAddresses = getPeersAuthResponse.peerAddresses;
|
||||||
log.trace("Received peers: " + peerAddresses);
|
log.trace("Received peers: " + peerAddresses);
|
||||||
peerGroup.addToReportedPeers(peerAddresses, connection);
|
peerGroup.addToReportedPeers(peerAddresses, connection);
|
||||||
|
|
||||||
// we wait until the handshake is completed before setting the authenticate flag
|
// we wait until the handshake is completed before setting the authenticate flag
|
||||||
// authentication at both sides of the connection
|
// authentication at both sides of the connection
|
||||||
log.info("\n\nAuthenticationComplete\nPeer with address " + peerAddress
|
log.info("AuthenticationComplete: Peer with address " + peerAddress
|
||||||
+ " authenticated (" + connection.objectId + "). Took "
|
+ " authenticated (" + connection.objectId + "). Took "
|
||||||
+ (System.currentTimeMillis() - startAuthTs) + " ms. \n\n");
|
+ (System.currentTimeMillis() - startAuthTs) + " ms.");
|
||||||
|
|
||||||
onSuccess(connection);
|
onSuccess(connection);
|
||||||
}
|
}
|
||||||
|
@ -176,7 +176,7 @@ public class AuthenticationHandshake implements MessageListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
public SettableFuture<Connection> requestAuthentication(Set<Address> remainingAddresses, Address peerAddress) {
|
public SettableFuture<Connection> requestAuthentication(Set<Address> remainingAddresses, Address peerAddress) {
|
||||||
Log.traceCall();
|
Log.traceCall(peerAddress.getFullAddress());
|
||||||
// Requesting peer
|
// Requesting peer
|
||||||
resultFuture = SettableFuture.create();
|
resultFuture = SettableFuture.create();
|
||||||
startAuthTs = System.currentTimeMillis();
|
startAuthTs = System.currentTimeMillis();
|
||||||
|
@ -193,8 +193,9 @@ public class AuthenticationHandshake implements MessageListener {
|
||||||
log.info("Send RequestAuthenticationMessage to " + peerAddress + " failed." +
|
log.info("Send RequestAuthenticationMessage to " + peerAddress + " failed." +
|
||||||
"\nThat is expected if seed nodes are offline." +
|
"\nThat is expected if seed nodes are offline." +
|
||||||
"\nException:" + throwable.getMessage());
|
"\nException:" + throwable.getMessage());
|
||||||
log.trace("We try to authenticate to another random seed nodes of that list: " + remainingAddresses);
|
onFault(throwable);
|
||||||
authenticateToNextRandomPeer(remainingAddresses);
|
// log.trace("We try to authenticate to another random seed nodes of that list: " + remainingAddresses);
|
||||||
|
// authenticateToNextRandomPeer(remainingAddresses);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -267,7 +268,7 @@ public class AuthenticationHandshake implements MessageListener {
|
||||||
// Private
|
// Private
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
private void authenticateToNextRandomPeer(Set<Address> remainingAddresses) {
|
/* private void authenticateToNextRandomPeer(Set<Address> remainingAddresses) {
|
||||||
Log.traceCall();
|
Log.traceCall();
|
||||||
Optional<Tuple2<Address, Set<Address>>> tupleOptional = getRandomAddressAndRemainingSet(remainingAddresses);
|
Optional<Tuple2<Address, Set<Address>>> tupleOptional = getRandomAddressAndRemainingSet(remainingAddresses);
|
||||||
if (tupleOptional.isPresent()) {
|
if (tupleOptional.isPresent()) {
|
||||||
|
@ -277,7 +278,7 @@ public class AuthenticationHandshake implements MessageListener {
|
||||||
log.info("No other seed node found. That is expected for the first seed node.");
|
log.info("No other seed node found. That is expected for the first seed node.");
|
||||||
onSuccess(null);
|
onSuccess(null);
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
private Optional<Tuple2<Address, Set<Address>>> getRandomAddressAndRemainingSet(Set<Address> addresses) {
|
private Optional<Tuple2<Address, Set<Address>>> getRandomAddressAndRemainingSet(Set<Address> addresses) {
|
||||||
Log.traceCall();
|
Log.traceCall();
|
||||||
|
|
|
@ -17,7 +17,7 @@ public final class AuthenticationRequest implements AuthenticationMessage {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "RequestAuthenticationMessage{" +
|
return "AuthenticationRequest{" +
|
||||||
"address=" + address +
|
"address=" + address +
|
||||||
", nonce=" + nonce +
|
", nonce=" + nonce +
|
||||||
'}';
|
'}';
|
||||||
|
|
|
@ -19,7 +19,7 @@ public final class AuthenticationResponse implements AuthenticationMessage {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "ChallengeMessage{" +
|
return "AuthenticationResponse{" +
|
||||||
"address=" + address +
|
"address=" + address +
|
||||||
", requesterNonce=" + requesterNonce +
|
", requesterNonce=" + requesterNonce +
|
||||||
", challengerNonce=" + challengerNonce +
|
", challengerNonce=" + challengerNonce +
|
||||||
|
|
|
@ -21,7 +21,7 @@ public final class GetPeersAuthRequest implements AuthenticationMessage {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "GetPeersMessage{" +
|
return "GetPeersAuthRequest{" +
|
||||||
"address=" + address +
|
"address=" + address +
|
||||||
", challengerNonce=" + challengerNonce +
|
", challengerNonce=" + challengerNonce +
|
||||||
", peerAddresses=" + peerAddresses +
|
", peerAddresses=" + peerAddresses +
|
||||||
|
|
|
@ -19,7 +19,7 @@ public final class GetPeersAuthResponse implements AuthenticationMessage {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "PeersMessage{" + "peerAddresses=" + peerAddresses + '}';
|
return "GetPeersAuthResponse{" + "peerAddresses=" + peerAddresses + '}';
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ public final class GetPeersRequest implements MaintenanceMessage {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "GetPeersMessage{" +
|
return "GetPeersRequest{" +
|
||||||
"address=" + address +
|
"address=" + address +
|
||||||
", peerAddresses=" + peerAddresses +
|
", peerAddresses=" + peerAddresses +
|
||||||
'}';
|
'}';
|
||||||
|
|
|
@ -17,7 +17,7 @@ public final class GetPeersResponse implements MaintenanceMessage {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "GetPeersMessage{" +
|
return "GetPeersResponse{" +
|
||||||
", peerAddresses=" + peerAddresses +
|
", peerAddresses=" + peerAddresses +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue