From 8e587ae481631160527fd412d41c5d66439b3fda Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Mon, 31 Mar 2014 11:41:14 -0700 Subject: Clean dead paths from peers. --- node/Path.hpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'node/Path.hpp') diff --git a/node/Path.hpp b/node/Path.hpp index 10772161..b227811a 100644 --- a/node/Path.hpp +++ b/node/Path.hpp @@ -29,6 +29,7 @@ #define ZT_PATH_HPP #include +#include #include #include @@ -57,6 +58,12 @@ public: _tcp(false), _fixed(false) {} + Path(const Path &p) + { + // InetAddress is memcpy'able + memcpy(this,&p,sizeof(Path)); + } + Path(const InetAddress &addr,bool tcp,bool fixed = false) : _lastSend(0), _lastReceived(0), @@ -66,6 +73,13 @@ public: _tcp(tcp), _fixed(fixed) {} + inline Path &operator=(const Path &p) + { + if (this != &p) + memcpy(this,&p,sizeof(Path)); + return *this; + } + inline const InetAddress &address() const throw() { return _addr; } inline bool tcp() const throw() { return _tcp; } inline uint64_t lastSend() const throw() { return _lastSend; } @@ -81,6 +95,10 @@ public: inline void firewallOpenerSent(uint64_t t) throw() { _lastFirewallOpener = t; } inline void pinged(uint64_t t) throw() { _lastPing = t; } + /** + * @param now Current time + * @return True if this path is fixed or has received data in last ACTIVITY_TIMEOUT ms + */ inline bool active(uint64_t now) const throw() { -- cgit v1.2.3