mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-03 16:00:51 +00:00
Send HELLO instead of NOP for NAT-t in order to measure latency always. Also prevents a race that can cause the first NAT-t to fail where the NOP arrives before the WHOIS reply from the supernode. Now NAT-t initiators will push their own public keys anyway so that doesnt matter.
This commit is contained in:
parent
2eaac3891e
commit
ef08494237
@ -314,6 +314,19 @@ void Switch::sendHELLO(const Address &dest)
|
|||||||
send(outp,false);
|
send(outp,false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Switch::sendHELLO(const SharedPtr<Peer> &dest,Demarc::Port localPort,const InetAddress &addr)
|
||||||
|
{
|
||||||
|
Packet outp(dest->address(),_r->identity.address(),Packet::VERB_HELLO);
|
||||||
|
outp.append((unsigned char)ZT_PROTO_VERSION);
|
||||||
|
outp.append((unsigned char)ZEROTIER_ONE_VERSION_MAJOR);
|
||||||
|
outp.append((unsigned char)ZEROTIER_ONE_VERSION_MINOR);
|
||||||
|
outp.append((uint16_t)ZEROTIER_ONE_VERSION_REVISION);
|
||||||
|
outp.append(Utils::now());
|
||||||
|
_r->identity.serialize(outp,false);
|
||||||
|
outp.hmacSet(dest->macKey());
|
||||||
|
return _r->demarc->send(localPort,addr,outp.data(),outp.size(),-1);
|
||||||
|
}
|
||||||
|
|
||||||
bool Switch::unite(const Address &p1,const Address &p2,bool force)
|
bool Switch::unite(const Address &p1,const Address &p2,bool force)
|
||||||
{
|
{
|
||||||
SharedPtr<Peer> p1p = _r->topology->getPeer(p1);
|
SharedPtr<Peer> p1p = _r->topology->getPeer(p1);
|
||||||
@ -394,11 +407,8 @@ unsigned long Switch::doTimerTasks()
|
|||||||
if (now >= i->second.fireAtTime) {
|
if (now >= i->second.fireAtTime) {
|
||||||
SharedPtr<Peer> withPeer = _r->topology->getPeer(i->first);
|
SharedPtr<Peer> withPeer = _r->topology->getPeer(i->first);
|
||||||
if (withPeer) {
|
if (withPeer) {
|
||||||
TRACE("sending NAT-T NOP to %s(%s)",i->first.toString().c_str(),i->second.inaddr.toString().c_str());
|
TRACE("sending NAT-T HELLO to %s(%s)",i->first.toString().c_str(),i->second.inaddr.toString().c_str());
|
||||||
Packet outp(i->first,_r->identity.address(),Packet::VERB_NOP);
|
sendHELLO(withPeer,i->second.localPort,i->second.inaddr);
|
||||||
outp.append("ZT",2); // arbitrary payload
|
|
||||||
outp.hmacSet(withPeer->macKey());
|
|
||||||
_r->demarc->send(i->second.localPort,i->second.inaddr,outp.data(),outp.size(),-1);
|
|
||||||
}
|
}
|
||||||
_rendezvousQueue.erase(i++);
|
_rendezvousQueue.erase(i++);
|
||||||
} else {
|
} else {
|
||||||
|
@ -106,6 +106,16 @@ public:
|
|||||||
*/
|
*/
|
||||||
void sendHELLO(const Address &dest);
|
void sendHELLO(const Address &dest);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send a HELLO announcement immediately to the indicated address
|
||||||
|
*
|
||||||
|
* @param localPort Originating local port or ANY_PORT to pick
|
||||||
|
* @param addr IP address to send to
|
||||||
|
* @param dest Destination peer
|
||||||
|
* @return True if send appears successful
|
||||||
|
*/
|
||||||
|
bool sendHELLO(const SharedPtr<Peer> &dest,Demarc::Port localPort,const InetAddress &addr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send RENDEZVOUS to two peers to permit them to directly connect
|
* Send RENDEZVOUS to two peers to permit them to directly connect
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user