From dc8ee9e6d12546b66933a3e5b2863ff613acf297 Mon Sep 17 00:00:00 2001
From: thorkill <thkr@hannover.ccc.de>
Date: Tue, 10 May 2016 11:43:14 +0200
Subject: [PATCH] Prevent receive_tcppacket_sptps from forwarding data when we
 are in handshake phase with those nodes

Forwarding data to node which does not have vaildkey yet would destroy
the running handshake.
---
 src/net_packet.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/net_packet.c b/src/net_packet.c
index 21e6c2ac..e1612699 100644
--- a/src/net_packet.c
+++ b/src/net_packet.c
@@ -470,8 +470,11 @@ bool receive_tcppacket_sptps(connection_t *c, const char *data, int len) {
 	/* If we're not the final recipient, relay the packet. */
 
 	if(to != myself) {
-		send_sptps_data(to, from, 0, data, len);
-		try_tx(to, true);
+		if (!to->status.waitingforkey) {
+			send_sptps_data(to, from, 0, data, len);
+			try_tx(to, true);
+		} else
+			logger(DEBUG_ALWAYS, LOG_INFO, "Cannot forward TCP packet from %s (%s) to %s (%s) because we are still wating for key", from->name, from->hostname, to->name, to->hostname);
 		return true;
 	}