Prevent re-armoring of packets when in multipath broadcast mode

This commit is contained in:
Joseph Henry 2022-09-07 15:03:02 -07:00
parent 1d1843bf3b
commit 66b70a8043
No known key found for this signature in database
GPG Key ID: C45B33FF5EBC9344
2 changed files with 11 additions and 1 deletions

View File

@ -1249,6 +1249,14 @@ public:
return (((unsigned int)(*this)[ZT_PACKET_IDX_FLAGS] & 0x38) >> 3); 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 * Set this packet's cipher suite
*/ */

View File

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