diff options
| author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2019-03-14 14:29:15 -0700 |
|---|---|---|
| committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2019-03-14 14:29:15 -0700 |
| commit | e03102dbcb4d28cfa54740a8d9824d3c6324d97b (patch) | |
| tree | a0da61347f8899b7aa93ab3e754f337151e936d8 /node/Node.hpp | |
| parent | 9d7b7c72b2dd769853bea3423321539ab198829e (diff) | |
| download | infinitytier-e03102dbcb4d28cfa54740a8d9824d3c6324d97b.tar.gz infinitytier-e03102dbcb4d28cfa54740a8d9824d3c6324d97b.zip | |
Clean out some unnecessarily pedantic auth stuff in favor of a simpler way of gating multicast gathers.
Diffstat (limited to 'node/Node.hpp')
| -rw-r--r-- | node/Node.hpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/node/Node.hpp b/node/Node.hpp index 9f223eb5..c3e46deb 100644 --- a/node/Node.hpp +++ b/node/Node.hpp @@ -263,6 +263,16 @@ public: inline void setMultipathMode(uint8_t mode) { _multipathMode = mode; } inline uint8_t getMultipathMode() { return _multipathMode; } + inline bool localControllerHasAuthorized(const int64_t now,const uint64_t nwid,const Address &addr) const + { + _localControllerAuthorizations_m.lock(); + const int64_t *const at = _localControllerAuthorizations.get(_LocalControllerAuth(nwid,addr)); + _localControllerAuthorizations_m.unlock(); + if (at) + return ((now - *at) < (ZT_NETWORK_AUTOCONF_DELAY * 3)); + return false; + } + private: RuntimeEnvironment _RR; RuntimeEnvironment *RR; @@ -276,6 +286,19 @@ private: // Time of last identity verification indexed by InetAddress.rateGateHash() -- used in IncomingPacket::_doHELLO() via rateGateIdentityVerification() int64_t _lastIdentityVerification[16384]; + // Map that remembers if we have recently sent a network config to someone + // querying us as a controller. + struct _LocalControllerAuth + { + uint64_t nwid,address; + _LocalControllerAuth(const uint64_t nwid_,const Address &address_) : nwid(nwid_),address(address_.toInt()) {} + inline unsigned long hashCode() const { return (unsigned long)(nwid ^ address); } + inline bool operator==(const _LocalControllerAuth &a) const { return ((a.nwid == nwid)&&(a.address == address)); } + inline bool operator!=(const _LocalControllerAuth &a) const { return ((a.nwid != nwid)||(a.address != address)); } + }; + Hashtable< _LocalControllerAuth,int64_t > _localControllerAuthorizations; + Mutex _localControllerAuthorizations_m; + Hashtable< uint64_t,SharedPtr<Network> > _networks; Mutex _networks_m; |
