diff options
| author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2014-03-31 11:41:14 -0700 |
|---|---|---|
| committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2014-03-31 11:41:14 -0700 |
| commit | 8e587ae481631160527fd412d41c5d66439b3fda (patch) | |
| tree | f3224d9d99071f884f07d4cf67277860665389aa /node/Path.hpp | |
| parent | acb056e3b1997cbbf95b78787c385b134b924d15 (diff) | |
| download | infinitytier-8e587ae481631160527fd412d41c5d66439b3fda.tar.gz infinitytier-8e587ae481631160527fd412d41c5d66439b3fda.zip | |
Clean dead paths from peers.
Diffstat (limited to 'node/Path.hpp')
| -rw-r--r-- | node/Path.hpp | 18 |
1 files changed, 18 insertions, 0 deletions
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 <stdint.h> +#include <string.h> #include <stdexcept> #include <string> @@ -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() { |
