This commit is contained in:
Adam Ierymenko 2021-09-20 15:04:25 -04:00
parent bcf8c30ce0
commit 104fade420

View File

@ -273,11 +273,6 @@ static void handlePacket(const int sock,const InetAddress *const ip,Packet &pkt)
printf("%s HELLO rejected: identity address collision!" ZT_EOL_S,ip->toString(ipstr)); printf("%s HELLO rejected: identity address collision!" ZT_EOL_S,ip->toString(ipstr));
// TODO: send error // TODO: send error
return; return;
} else {
printf("* invalid identity found and discarded: %s" ZT_EOL_S,id.toString(false, tmpstr));
std::lock_guard<std::mutex> p_l(s_peersByVirtAddr_l);
s_peersByVirtAddr.erase(source);
peer.zero();
} }
} }
} }
@ -327,6 +322,7 @@ static void handlePacket(const int sock,const InetAddress *const ip,Packet &pkt)
peer = p->second; peer = p->second;
} }
} }
if (peer) {
if (!pkt.dearmor(peer->key)) { if (!pkt.dearmor(peer->key)) {
printf("%s HELLO rejected: packet authentication failed" ZT_EOL_S,ip->toString(ipstr)); printf("%s HELLO rejected: packet authentication failed" ZT_EOL_S,ip->toString(ipstr));
return; return;
@ -335,9 +331,11 @@ static void handlePacket(const int sock,const InetAddress *const ip,Packet &pkt)
printf("%s packet rejected: decompression failed" ZT_EOL_S,ip->toString(ipstr)); printf("%s packet rejected: decompression failed" ZT_EOL_S,ip->toString(ipstr));
return; return;
} }
} else {
return;
}
} }
if (likely(peer)) {
const int64_t now = OSUtils::now(); const int64_t now = OSUtils::now();
if (ip->isV4()) { if (ip->isV4()) {
@ -516,7 +514,6 @@ static void handlePacket(const int sock,const InetAddress *const ip,Packet &pkt)
return; return;
} }
}
// If we made it here, we are forwarding this packet to someone else and also possibly // If we made it here, we are forwarding this packet to someone else and also possibly
// sending a RENDEZVOUS message. // sending a RENDEZVOUS message.