mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-05 03:53:44 +02:00
Add some TRACE instrumentation to external surface address awareness.
This commit is contained in:
parent
b51d00146b
commit
417f56de2f
3 changed files with 15 additions and 11 deletions
|
@ -270,9 +270,9 @@ bool IncomingPacket::_doHELLO(const RuntimeEnvironment *RR)
|
||||||
|
|
||||||
if (RR->topology->isSupernode(id.address())) {
|
if (RR->topology->isSupernode(id.address())) {
|
||||||
RR->node->postNewerVersionIfNewer(vMajor,vMinor,vRevision);
|
RR->node->postNewerVersionIfNewer(vMajor,vMinor,vRevision);
|
||||||
RR->sa->iam(_remoteAddress,destAddr,true);
|
RR->sa->iam(id.address(),_remoteAddress,destAddr,true);
|
||||||
} else {
|
} else {
|
||||||
RR->sa->iam(_remoteAddress,destAddr,false);
|
RR->sa->iam(id.address(),_remoteAddress,destAddr,false);
|
||||||
}
|
}
|
||||||
|
|
||||||
Packet outp(id.address(),RR->identity.address(),Packet::VERB_OK);
|
Packet outp(id.address(),RR->identity.address(),Packet::VERB_OK);
|
||||||
|
|
|
@ -63,24 +63,26 @@ SelfAwareness::~SelfAwareness()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void SelfAwareness::iam(const InetAddress &reporterPhysicalAddress,const InetAddress &myPhysicalAddress,bool trusted)
|
void SelfAwareness::iam(const Address &reporter,const InetAddress &reporterPhysicalAddress,const InetAddress &myPhysicalAddress,bool trusted)
|
||||||
{
|
{
|
||||||
// This code depends on the numeric values assigned to scopes in InetAddress.hpp
|
// This code depends on the numeric values assigned to scopes in InetAddress.hpp
|
||||||
const unsigned int scope = (unsigned int)myPhysicalAddress.ipScope();
|
const unsigned int scope = (unsigned int)myPhysicalAddress.ipScope();
|
||||||
if ((scope > 0)&&(scope < (unsigned int)InetAddress::IP_SCOPE_LOOPBACK)) {
|
if ((scope > 0)&&(scope < (unsigned int)InetAddress::IP_SCOPE_LOOPBACK)) {
|
||||||
/* For now only trusted peers are permitted to inform us of changes to
|
if ( (!trusted) && ((scope == (unsigned int)InetAddress::IP_SCOPE_GLOBAL)||(scope != (unsigned int)reporterPhysicalAddress.ipScope())) ) {
|
||||||
* our global Internet IP or to changes of NATed IPs. We'll let peers on
|
/* For now only trusted peers are permitted to inform us of changes to
|
||||||
* private, shared, or link-local networks inform us of changes as long
|
* our global Internet IP or to changes of NATed IPs. We'll let peers on
|
||||||
* as they too are at the same scope. This discrimination avoids a DoS
|
* private, shared, or link-local networks inform us of changes as long
|
||||||
* attack in which an attacker could force us to reset our connections. */
|
* as they too are at the same scope. This discrimination avoids a DoS
|
||||||
if ( (!trusted) && ((scope == (unsigned int)InetAddress::IP_SCOPE_GLOBAL)||(scope != (unsigned int)reporterPhysicalAddress.ipScope())) )
|
* attack in which an attacker could force us to reset our connections. */
|
||||||
return;
|
return;
|
||||||
else {
|
} else {
|
||||||
Mutex::Lock _l(_lock);
|
Mutex::Lock _l(_lock);
|
||||||
InetAddress &lastPhy = _lastPhysicalAddress[scope - 1];
|
InetAddress &lastPhy = _lastPhysicalAddress[scope - 1];
|
||||||
if (!lastPhy) {
|
if (!lastPhy) {
|
||||||
|
TRACE("learned physical address %s for scope %u from reporter %s(%s) (replaced <null>)",myPhysicalAddress.toString().c_str(),scope,reporter.toString().c_str(),reporterPhysicalAddress.toString().c_str());
|
||||||
lastPhy = myPhysicalAddress;
|
lastPhy = myPhysicalAddress;
|
||||||
} else if (lastPhy != myPhysicalAddress) {
|
} else if (lastPhy != myPhysicalAddress) {
|
||||||
|
TRACE("learned physical address %s for scope %u from reporter %s(%s) (replaced %s, resetting within scope)",myPhysicalAddress.toString().c_str(),scope,reporter.toString().c_str(),reporterPhysicalAddress.toString().c_str(),lastPhy.toString().c_str());
|
||||||
lastPhy = myPhysicalAddress;
|
lastPhy = myPhysicalAddress;
|
||||||
_ResetWithinScope rset(RR,RR->node->now(),(InetAddress::IpScope)scope);
|
_ResetWithinScope rset(RR,RR->node->now(),(InetAddress::IpScope)scope);
|
||||||
RR->topology->eachPeer<_ResetWithinScope &>(rset);
|
RR->topology->eachPeer<_ResetWithinScope &>(rset);
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#define ZT_SELFAWARENESS_HPP
|
#define ZT_SELFAWARENESS_HPP
|
||||||
|
|
||||||
#include "InetAddress.hpp"
|
#include "InetAddress.hpp"
|
||||||
|
#include "Address.hpp"
|
||||||
#include "Mutex.hpp"
|
#include "Mutex.hpp"
|
||||||
|
|
||||||
namespace ZeroTier {
|
namespace ZeroTier {
|
||||||
|
@ -47,11 +48,12 @@ public:
|
||||||
/**
|
/**
|
||||||
* Called when a trusted remote peer informs us of our external network address
|
* Called when a trusted remote peer informs us of our external network address
|
||||||
*
|
*
|
||||||
|
* @param reporter ZeroTier address of reporting peer
|
||||||
* @param reporterPhysicalAddress Physical address that reporting peer seems to have
|
* @param reporterPhysicalAddress Physical address that reporting peer seems to have
|
||||||
* @param myPhysicalAddress Physical address that peer says we have
|
* @param myPhysicalAddress Physical address that peer says we have
|
||||||
* @param trusted True if this peer is trusted as an authority to inform us of external address changes
|
* @param trusted True if this peer is trusted as an authority to inform us of external address changes
|
||||||
*/
|
*/
|
||||||
void iam(const InetAddress &reporterPhysicalAddress,const InetAddress &myPhysicalAddress,bool trusted);
|
void iam(const Address &reporter,const InetAddress &reporterPhysicalAddress,const InetAddress &myPhysicalAddress,bool trusted);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const RuntimeEnvironment *RR;
|
const RuntimeEnvironment *RR;
|
||||||
|
|
Loading…
Add table
Reference in a new issue