summaryrefslogtreecommitdiff
path: root/node/Node.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'node/Node.hpp')
-rw-r--r--node/Node.hpp41
1 files changed, 39 insertions, 2 deletions
diff --git a/node/Node.hpp b/node/Node.hpp
index 79284b63..a6f92eb1 100644
--- a/node/Node.hpp
+++ b/node/Node.hpp
@@ -1,6 +1,6 @@
/*
* ZeroTier One - Network Virtualization Everywhere
- * Copyright (C) 2011-2018 ZeroTier, Inc. https://www.zerotier.com/
+ * Copyright (C) 2011-2019 ZeroTier, Inc. https://www.zerotier.com/
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -13,7 +13,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* --
*
@@ -260,6 +260,25 @@ public:
inline const Address &remoteTraceTarget() const { return _remoteTraceTarget; }
inline Trace::Level remoteTraceLevel() const { return _remoteTraceLevel; }
+ 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;
+ }
+
+ inline void statsLogVerb(const unsigned int v,const unsigned int bytes)
+ {
+ ++_stats.inVerbCounts[v];
+ _stats.inVerbBytes[v] += (uint64_t)bytes;
+ }
+
private:
RuntimeEnvironment _RR;
RuntimeEnvironment *RR;
@@ -273,6 +292,22 @@ private:
// Time of last identity verification indexed by InetAddress.rateGateHash() -- used in IncomingPacket::_doHELLO() via rateGateIdentityVerification()
int64_t _lastIdentityVerification[16384];
+ // Statistics about stuff happening
+ volatile ZT_NodeStatistics _stats;
+
+ // 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;
@@ -284,6 +319,8 @@ private:
Address _remoteTraceTarget;
enum Trace::Level _remoteTraceLevel;
+ uint8_t _multipathMode;
+
volatile int64_t _now;
int64_t _lastPingCheck;
int64_t _lastHousekeepingRun;