diff options
| author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2017-02-01 12:32:06 -0800 |
|---|---|---|
| committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2017-02-01 12:32:06 -0800 |
| commit | 5e11cf637816121f79c3ed00370843e93b62b1c6 (patch) | |
| tree | b42628c32ef6ef3ac819270b6d65db7c0d8f5364 /node/Switch.cpp | |
| parent | 5dbebc513ad67bb65c41c42a9c761c085309564f (diff) | |
| download | infinitytier-5e11cf637816121f79c3ed00370843e93b62b1c6.tar.gz infinitytier-5e11cf637816121f79c3ed00370843e93b62b1c6.zip | |
Can't armor() a packet until all flags are set.
Diffstat (limited to 'node/Switch.cpp')
| -rw-r--r-- | node/Switch.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/node/Switch.cpp b/node/Switch.cpp index 6df84101..d4f477f0 100644 --- a/node/Switch.cpp +++ b/node/Switch.cpp @@ -693,6 +693,7 @@ bool Switch::_trySend(Packet &packet,bool encrypt) const Address destination(packet.destination()); #ifdef ZT_ENABLE_CLUSTER int clusterMostRecentMemberId = -1; + uint8_t clusterPeerSecret[ZT_PEER_SECRET_KEY_LENGTH]; #endif const SharedPtr<Peer> peer(RR->topology->getPeer(destination)); @@ -714,7 +715,7 @@ bool Switch::_trySend(Packet &packet,bool encrypt) if (!viaPath) { #ifdef ZT_ENABLE_CLUSTER if (RR->cluster) - clusterMostRecentMemberId = RR->cluster->prepSendViaCluster(destination,packet,encrypt); + clusterMostRecentMemberId = RR->cluster->prepSendViaCluster(destination,clusterPeerSecret); if (clusterMostRecentMemberId < 0) { #endif peer->tryMemorizedPath(now); // periodically attempt memorized or statically defined paths, if any are known @@ -751,12 +752,21 @@ bool Switch::_trySend(Packet &packet,bool encrypt) unsigned int chunkSize = std::min(packet.size(),(unsigned int)ZT_UDP_DEFAULT_PAYLOAD_MTU); packet.setFragmented(chunkSize < packet.size()); +#ifdef ZT_ENABLE_CLUSTER + const uint64_t trustedPathId = (viaPath) ? RR->topology->getOutboundPathTrust(viaPath->address()) : 0; + if (trustedPathId) { + packet.setTrusted(trustedPathId); + } else { + packet.armor((clusterMostRecentMemberId >= 0) ? clusterPeerSecret : peer->key(),encrypt); + } +#else const uint64_t trustedPathId = RR->topology->getOutboundPathTrust(viaPath->address()); if (trustedPathId) { packet.setTrusted(trustedPathId); } else { packet.armor(peer->key(),encrypt); } +#endif #ifdef ZT_ENABLE_CLUSTER if ( ((viaPath)&&(viaPath->send(RR,packet.data(),chunkSize,now))) || ((clusterMostRecentMemberId >= 0)&&(RR->cluster->sendViaCluster(clusterMostRecentMemberId,destination,packet.data(),chunkSize))) ) { |
