Fix auth handshake, add missing img

This commit is contained in:
Manfred Karrer 2015-11-09 23:34:47 +01:00
parent d666c6cd3b
commit 7c4bf8680b
11 changed files with 30 additions and 25 deletions

View File

@ -67,6 +67,10 @@ To run it use:
$ 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?
---------

View File

@ -74,8 +74,8 @@
</GridPane.margin>
</TextField>
<Label text="Authenticated peers:" GridPane.rowIndex="5"/>
<TextArea fx:id="authenticatedPeersTextArea" GridPane.rowIndex="7" GridPane.columnIndex="1"
<Label text="Authenticated peers:" GridPane.rowIndex="4"/>
<TextArea fx:id="authenticatedPeersTextArea" GridPane.rowIndex="4" GridPane.columnIndex="1"
mouseTransparent="true" focusTraversable="false"/>
<columnConstraints>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

@ -21,13 +21,13 @@ import java.util.*;
// authentication example:
// node2 -> node1 RequestAuthenticationMessage
// node2 -> node1 AuthenticationRequest
// node1: close connection
// node1 -> node2 ChallengeMessage on new connection
// node1 -> node2 AuthenticationResponse on new connection
// node2: authentication to node1 done if nonce ok
// node2 -> node1 GetPeersMessage
// node2 -> node1 GetPeersAuthRequest
// node1: authentication to node2 done if nonce ok
// node1 -> node2 PeersMessage
// node1 -> node2 GetPeersAuthResponse
public class AuthenticationHandshake implements MessageListener {
private static final Logger log = LoggerFactory.getLogger(AuthenticationHandshake.class);
@ -77,12 +77,12 @@ public class AuthenticationHandshake implements MessageListener {
Futures.addCallback(future, new FutureCallback<Connection>() {
@Override
public void onSuccess(Connection connection) {
log.trace("GetPeersMessage sent successfully from " + myAddress + " to " + peerAddress);
log.trace("GetPeersAuthRequest sent successfully from " + myAddress + " to " + peerAddress);
}
@Override
public void onFailure(@NotNull Throwable throwable) {
log.info("GetPeersMessage sending failed " + throwable.getMessage());
log.info("GetPeersAuthRequest sending failed " + throwable.getMessage());
onFault(throwable);
}
});
@ -104,17 +104,17 @@ public class AuthenticationHandshake implements MessageListener {
SettableFuture<Connection> future = networkNode.sendMessage(peerAddress,
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());
Futures.addCallback(future, new FutureCallback<Connection>() {
@Override
public void onSuccess(Connection connection) {
log.trace("PeersMessage sent successfully from " + myAddress + " to " + peerAddress);
log.trace("GetPeersAuthResponse sent successfully from " + myAddress + " to " + peerAddress);
}
@Override
public void onFailure(@NotNull Throwable throwable) {
log.info("PeersMessage sending failed " + throwable.getMessage());
log.info("GetPeersAuthResponse sending failed " + throwable.getMessage());
onFault(throwable);
}
});
@ -132,16 +132,16 @@ public class AuthenticationHandshake implements MessageListener {
// Requesting peer
GetPeersAuthResponse getPeersAuthResponse = (GetPeersAuthResponse) message;
Address peerAddress = getPeersAuthResponse.address;
log.trace("PeersMessage from " + peerAddress + " at " + myAddress);
log.trace("GetPeersAuthResponse from " + peerAddress + " at " + myAddress);
HashSet<Address> peerAddresses = getPeersAuthResponse.peerAddresses;
log.trace("Received peers: " + peerAddresses);
peerGroup.addToReportedPeers(peerAddresses, connection);
// we wait until the handshake is completed before setting the authenticate flag
// 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 "
+ (System.currentTimeMillis() - startAuthTs) + " ms. \n\n");
+ (System.currentTimeMillis() - startAuthTs) + " ms.");
onSuccess(connection);
}
@ -176,7 +176,7 @@ public class AuthenticationHandshake implements MessageListener {
}
public SettableFuture<Connection> requestAuthentication(Set<Address> remainingAddresses, Address peerAddress) {
Log.traceCall();
Log.traceCall(peerAddress.getFullAddress());
// Requesting peer
resultFuture = SettableFuture.create();
startAuthTs = System.currentTimeMillis();
@ -193,8 +193,9 @@ public class AuthenticationHandshake implements MessageListener {
log.info("Send RequestAuthenticationMessage to " + peerAddress + " failed." +
"\nThat is expected if seed nodes are offline." +
"\nException:" + throwable.getMessage());
log.trace("We try to authenticate to another random seed nodes of that list: " + remainingAddresses);
authenticateToNextRandomPeer(remainingAddresses);
onFault(throwable);
// 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 void authenticateToNextRandomPeer(Set<Address> remainingAddresses) {
/* private void authenticateToNextRandomPeer(Set<Address> remainingAddresses) {
Log.traceCall();
Optional<Tuple2<Address, Set<Address>>> tupleOptional = getRandomAddressAndRemainingSet(remainingAddresses);
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.");
onSuccess(null);
}
}
}*/
private Optional<Tuple2<Address, Set<Address>>> getRandomAddressAndRemainingSet(Set<Address> addresses) {
Log.traceCall();

View File

@ -17,7 +17,7 @@ public final class AuthenticationRequest implements AuthenticationMessage {
@Override
public String toString() {
return "RequestAuthenticationMessage{" +
return "AuthenticationRequest{" +
"address=" + address +
", nonce=" + nonce +
'}';

View File

@ -19,7 +19,7 @@ public final class AuthenticationResponse implements AuthenticationMessage {
@Override
public String toString() {
return "ChallengeMessage{" +
return "AuthenticationResponse{" +
"address=" + address +
", requesterNonce=" + requesterNonce +
", challengerNonce=" + challengerNonce +

View File

@ -21,7 +21,7 @@ public final class GetPeersAuthRequest implements AuthenticationMessage {
@Override
public String toString() {
return "GetPeersMessage{" +
return "GetPeersAuthRequest{" +
"address=" + address +
", challengerNonce=" + challengerNonce +
", peerAddresses=" + peerAddresses +

View File

@ -19,7 +19,7 @@ public final class GetPeersAuthResponse implements AuthenticationMessage {
@Override
public String toString() {
return "PeersMessage{" + "peerAddresses=" + peerAddresses + '}';
return "GetPeersAuthResponse{" + "peerAddresses=" + peerAddresses + '}';
}
}

View File

@ -19,7 +19,7 @@ public final class GetPeersRequest implements MaintenanceMessage {
@Override
public String toString() {
return "GetPeersMessage{" +
return "GetPeersRequest{" +
"address=" + address +
", peerAddresses=" + peerAddresses +
'}';

View File

@ -17,7 +17,7 @@ public final class GetPeersResponse implements MaintenanceMessage {
@Override
public String toString() {
return "GetPeersMessage{" +
return "GetPeersResponse{" +
", peerAddresses=" + peerAddresses +
'}';
}