From 41443db817cb093e586cd948d0200611d0948917 Mon Sep 17 00:00:00 2001 From: ameba23 Date: Thu, 30 Sep 2021 15:54:32 +0200 Subject: [PATCH] Bug with checking contactId, improve logging --- .../bramble/connection/IncomingDuplexSyncConnection.java | 2 +- .../bramble/connection/OutgoingDuplexSyncConnection.java | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/bramble-core/src/main/java/org/briarproject/bramble/connection/IncomingDuplexSyncConnection.java b/bramble-core/src/main/java/org/briarproject/bramble/connection/IncomingDuplexSyncConnection.java index 4fe8373d2..446cecf71 100644 --- a/bramble-core/src/main/java/org/briarproject/bramble/connection/IncomingDuplexSyncConnection.java +++ b/bramble-core/src/main/java/org/briarproject/bramble/connection/IncomingDuplexSyncConnection.java @@ -152,7 +152,7 @@ class IncomingDuplexSyncConnection extends DuplexSyncConnection handshakeManager.handshake(contactId, in, out); keyManager.addRotationKeys(contactId, result.getMasterKey(), TIMESTAMP, result.isAlice(), true); - LOG.info("Rotation keys added"); + LOG.info("Rotation keys added - IncomingDuplexSyncConnection"); return true; } catch (IOException | DbException e) { logException(LOG, WARNING, e); diff --git a/bramble-core/src/main/java/org/briarproject/bramble/connection/OutgoingDuplexSyncConnection.java b/bramble-core/src/main/java/org/briarproject/bramble/connection/OutgoingDuplexSyncConnection.java index 2fa0d35e7..b4f6bc8f5 100644 --- a/bramble-core/src/main/java/org/briarproject/bramble/connection/OutgoingDuplexSyncConnection.java +++ b/bramble-core/src/main/java/org/briarproject/bramble/connection/OutgoingDuplexSyncConnection.java @@ -64,6 +64,7 @@ class OutgoingDuplexSyncConnection extends DuplexSyncConnection LOG.info("Running OutgoingDuplexSyncConnection on transport " + transportId.getString()); // Allocate a stream context + StreamContext ctx = allocateStreamContext(contactId, transportId); if (ctx == null) { LOG.warning("Could not allocate stream context"); @@ -71,6 +72,7 @@ class OutgoingDuplexSyncConnection extends DuplexSyncConnection return; } if (ctx.isHandshakeMode()) { + LOG.info("OutgoingDuplexSyncConnection - context is in handshake mode, performing handshake"); if (!performHandshake(ctx)) { LOG.warning("Handshake failed"); return; @@ -178,7 +180,7 @@ class OutgoingDuplexSyncConnection extends DuplexSyncConnection } // Check that the stream comes from the expected contact ContactId inContactId = ctxIn.getContactId(); - if (contactId == null) { + if (inContactId == null) { LOG.warning("Expected contact tag, got rendezvous tag"); onReadError(); return false; @@ -197,7 +199,7 @@ class OutgoingDuplexSyncConnection extends DuplexSyncConnection handshakeManager.handshake(contactId, in, out); keyManager.addRotationKeys(contactId, result.getMasterKey(), TIMESTAMP, result.isAlice(), true); - LOG.info("Rotation keys added"); + LOG.info("Rotation keys added - OutgoingDuplexSyncConnection"); return true; } catch (IOException | DbException e) { logException(LOG, WARNING, e);