mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2024-12-19 04:57:53 +00:00
Send error.
This commit is contained in:
parent
3c85322067
commit
5d429cedbb
@ -267,19 +267,22 @@ static void handlePacket(const int sock,const InetAddress *const ip,Packet &pkt)
|
|||||||
|
|
||||||
if (peer) {
|
if (peer) {
|
||||||
if (unlikely(peer->id != id)) {
|
if (unlikely(peer->id != id)) {
|
||||||
if (!peer->identityValidated) {
|
printf("%s HELLO rejected: identity address collision!" ZT_EOL_S,ip->toString(ipstr));
|
||||||
peer->identityValidated = peer->id.locallyValidate();
|
|
||||||
if (peer->identityValidated) {
|
|
||||||
printf("%s HELLO rejected: identity address collision!" ZT_EOL_S,ip->toString(ipstr));
|
|
||||||
// TODO: send error
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
peer.zero();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!peer) {
|
uint8_t key[48];
|
||||||
|
if (s_self.agree(id, key)) {
|
||||||
|
const uint64_t origId = pkt.packetId();
|
||||||
|
pkt.reset(source,s_self.address(),Packet::VERB_ERROR);
|
||||||
|
pkt.append((uint8_t)Packet::VERB_HELLO);
|
||||||
|
pkt.append(origId);;
|
||||||
|
pkt.append((uint8_t)Packet::ERROR_IDENTITY_COLLISION);
|
||||||
|
pkt.armor(key,true);
|
||||||
|
sendto(sock,pkt.data(),pkt.size(),SENDTO_FLAGS,(const struct sockaddr *)ip,(socklen_t)((ip->ss_family == AF_INET) ? sizeof(struct sockaddr_in) : sizeof(struct sockaddr_in6)));
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
peer.set(new RootPeer);
|
peer.set(new RootPeer);
|
||||||
peer->identityValidated = false;
|
peer->identityValidated = false;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user