Skip to content

Commit

Permalink
Merge pull request #4659 from chimp1984/fix-missing-capability-handli…
Browse files Browse the repository at this point in the history
…ng-for-encrypted-msg

Handle Capabilities for encrypted messages (offer availibility request/response)
  • Loading branch information
sqrrm authored Oct 16, 2020
2 parents bac1e7b + 6b4d77f commit b924107
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions p2p/src/main/java/bisq/network/p2p/P2PService.java
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ public void onMessage(NetworkEnvelope networkEnvelope, Connection connection) {
connection.setPeerType(Connection.PeerType.DIRECT_MSG_PEER);
try {
DecryptedMessageWithPubKey decryptedMsg = encryptionService.decryptAndVerify(sealedMsg.getSealedAndSigned());
connection.maybeHandleSupportedCapabilitiesMessage(decryptedMsg.getNetworkEnvelope());
connection.getPeersNodeAddressOptional().ifPresentOrElse(nodeAddress ->
decryptedDirectMessageListeners.forEach(e -> e.onDirectMessage(decryptedMsg, nodeAddress)),
() -> {
Expand Down
14 changes: 8 additions & 6 deletions p2p/src/main/java/bisq/network/p2p/network/Connection.java
Original file line number Diff line number Diff line change
Expand Up @@ -785,11 +785,9 @@ && reportInvalidRequest(RuleViolation.WRONG_NETWORK_ID)) {
return;
}

if (networkEnvelope instanceof SupportedCapabilitiesMessage) {
boolean causedShutDown = handleSupportedCapabilitiesMessage(networkEnvelope);
if (causedShutDown) {
return;
}
boolean causedShutDown = maybeHandleSupportedCapabilitiesMessage(networkEnvelope);
if (causedShutDown) {
return;
}

if (networkEnvelope instanceof CloseConnectionMessage) {
Expand Down Expand Up @@ -865,7 +863,11 @@ && reportInvalidRequest(RuleViolation.WRONG_NETWORK_ID)) {
}
}

protected boolean handleSupportedCapabilitiesMessage(NetworkEnvelope networkEnvelope) {
public boolean maybeHandleSupportedCapabilitiesMessage(NetworkEnvelope networkEnvelope) {
if (!(networkEnvelope instanceof SupportedCapabilitiesMessage)) {
return false;
}

Capabilities supportedCapabilities = ((SupportedCapabilitiesMessage) networkEnvelope).getSupportedCapabilities();
if (supportedCapabilities == null || supportedCapabilities.isEmpty()) {
return false;
Expand Down

0 comments on commit b924107

Please sign in to comment.