Przeglądaj źródła

Prevent re-armoring of packets when in multipath broadcast mode

Joseph Henry 2 lat temu
rodzic
commit
66b70a8043
2 zmienionych plików z 11 dodań i 1 usunięć
  1. 8 0
      node/Packet.hpp
  2. 3 1
      node/Switch.cpp

+ 8 - 0
node/Packet.hpp

@@ -1249,6 +1249,14 @@ public:
 		return (((unsigned int)(*this)[ZT_PACKET_IDX_FLAGS] & 0x38) >> 3);
 	}
 
+	/**
+	 * @return Whether this packet is currently encrypted
+	 */
+	inline bool isEncrypted() const
+	{
+		return (cipher() == ZT_PROTO_CIPHER_SUITE__C25519_POLY1305_SALSA2012) || (cipher() == ZT_PROTO_CIPHER_SUITE__AES_GMAC_SIV);
+	}
+
 	/**
 	 * Set this packet's cipher suite
 	 */

+ 3 - 1
node/Switch.cpp

@@ -1045,7 +1045,9 @@ void Switch::_sendViaSpecificPath(void *tPtr,SharedPtr<Peer> peer,SharedPtr<Path
 	if (trustedPathId) {
 		packet.setTrusted(trustedPathId);
 	} else {
-		packet.armor(peer->key(),encrypt,peer->aesKeysIfSupported());
+		if (!packet.isEncrypted()) {
+			packet.armor(peer->key(),encrypt,peer->aesKeysIfSupported());
+		}
 		RR->node->expectReplyTo(packet.packetId());
 	}