From e03102dbcb4d28cfa54740a8d9824d3c6324d97b Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Thu, 14 Mar 2019 14:29:15 -0700 Subject: Clean out some unnecessarily pedantic auth stuff in favor of a simpler way of gating multicast gathers. --- node/Node.hpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'node/Node.hpp') 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 > _networks; Mutex _networks_m; -- cgit v1.2.3