Peer.hpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619
  1. /*
  2. * Copyright (c)2013-2020 ZeroTier, Inc.
  3. *
  4. * Use of this software is governed by the Business Source License included
  5. * in the LICENSE.TXT file in the project's root directory.
  6. *
  7. * Change Date: 2025-01-01
  8. *
  9. * On the date above, in accordance with the Business Source License, use
  10. * of this software will be governed by version 2.0 of the Apache License.
  11. */
  12. /****/
  13. #ifndef ZT_PEER_HPP
  14. #define ZT_PEER_HPP
  15. #include <vector>
  16. #include <list>
  17. #include "../include/ZeroTierOne.h"
  18. #include "Constants.hpp"
  19. #include "RuntimeEnvironment.hpp"
  20. #include "Node.hpp"
  21. #include "Path.hpp"
  22. #include "Address.hpp"
  23. #include "Utils.hpp"
  24. #include "Identity.hpp"
  25. #include "InetAddress.hpp"
  26. #include "Packet.hpp"
  27. #include "SharedPtr.hpp"
  28. #include "AtomicCounter.hpp"
  29. #include "Hashtable.hpp"
  30. #include "Mutex.hpp"
  31. #include "Bond.hpp"
  32. #include "BondController.hpp"
  33. #include "AES.hpp"
  34. #define ZT_PEER_MAX_SERIALIZED_STATE_SIZE (sizeof(Peer) + 32 + (sizeof(Path) * 2))
  35. namespace ZeroTier {
  36. /**
  37. * Peer on P2P Network (virtual layer 1)
  38. */
  39. class Peer
  40. {
  41. friend class SharedPtr<Peer>;
  42. friend class SharedPtr<Bond>;
  43. friend class Switch;
  44. friend class Bond;
  45. private:
  46. Peer() {} // disabled to prevent bugs -- should not be constructed uninitialized
  47. public:
  48. ~Peer() { Utils::burn(_key,sizeof(_key)); }
  49. /**
  50. * Construct a new peer
  51. *
  52. * @param renv Runtime environment
  53. * @param myIdentity Identity of THIS node (for key agreement)
  54. * @param peerIdentity Identity of peer
  55. * @throws std::runtime_error Key agreement with peer's identity failed
  56. */
  57. Peer(const RuntimeEnvironment *renv,const Identity &myIdentity,const Identity &peerIdentity);
  58. /**
  59. * @return This peer's ZT address (short for identity().address())
  60. */
  61. inline const Address &address() const { return _id.address(); }
  62. /**
  63. * @return This peer's identity
  64. */
  65. inline const Identity &identity() const { return _id; }
  66. /**
  67. * Log receipt of an authenticated packet
  68. *
  69. * This is called by the decode pipe when a packet is proven to be authentic
  70. * and appears to be valid.
  71. *
  72. * @param tPtr Thread pointer to be handed through to any callbacks called as a result of this call
  73. * @param path Path over which packet was received
  74. * @param hops ZeroTier (not IP) hops
  75. * @param packetId Packet ID
  76. * @param verb Packet verb
  77. * @param inRePacketId Packet ID in reply to (default: none)
  78. * @param inReVerb Verb in reply to (for OK/ERROR, default: VERB_NOP)
  79. * @param trustEstablished If true, some form of non-trivial trust (like allowed in network) has been established
  80. * @param networkId Network ID if this pertains to a network, or 0 otherwise
  81. */
  82. void received(
  83. void *tPtr,
  84. const SharedPtr<Path> &path,
  85. const unsigned int hops,
  86. const uint64_t packetId,
  87. const unsigned int payloadLength,
  88. const Packet::Verb verb,
  89. const uint64_t inRePacketId,
  90. const Packet::Verb inReVerb,
  91. const bool trustEstablished,
  92. const uint64_t networkId,
  93. const int32_t flowId);
  94. /**
  95. * Check whether we have an active path to this peer via the given address
  96. *
  97. * @param now Current time
  98. * @param addr Remote address
  99. * @return True if we have an active path to this destination
  100. */
  101. inline bool hasActivePathTo(int64_t now,const InetAddress &addr) const
  102. {
  103. Mutex::Lock _l(_paths_m);
  104. for(unsigned int i=0;i<ZT_MAX_PEER_NETWORK_PATHS;++i) {
  105. if (_paths[i].p) {
  106. if (((now - _paths[i].lr) < ZT_PEER_PATH_EXPIRATION)&&(_paths[i].p->address() == addr))
  107. return true;
  108. } else break;
  109. }
  110. return false;
  111. }
  112. /**
  113. * Send via best direct path
  114. *
  115. * @param tPtr Thread pointer to be handed through to any callbacks called as a result of this call
  116. * @param data Packet data
  117. * @param len Packet length
  118. * @param now Current time
  119. * @param force If true, send even if path is not alive
  120. * @return True if we actually sent something
  121. */
  122. inline bool sendDirect(void *tPtr,const void *data,unsigned int len,int64_t now,bool force)
  123. {
  124. SharedPtr<Path> bp(getAppropriatePath(now,force));
  125. if (bp)
  126. return bp->send(RR,tPtr,data,len,now);
  127. return false;
  128. }
  129. /**
  130. * Record incoming packets to
  131. *
  132. * @param tPtr Thread pointer to be handed through to any callbacks called as a result of this call
  133. * @param path Path over which packet was received
  134. * @param packetId Packet ID
  135. * @param payloadLength Length of packet data payload
  136. * @param verb Packet verb
  137. * @param flowId Flow ID
  138. * @param now Current time
  139. */
  140. void recordIncomingPacket(const SharedPtr<Path> &path, const uint64_t packetId,
  141. uint16_t payloadLength, const Packet::Verb verb, const int32_t flowId, int64_t now);
  142. /**
  143. *
  144. * @param path Path over which packet is being sent
  145. * @param packetId Packet ID
  146. * @param payloadLength Length of packet data payload
  147. * @param verb Packet verb
  148. * @param flowId Flow ID
  149. * @param now Current time
  150. */
  151. void recordOutgoingPacket(const SharedPtr<Path> &path, const uint64_t packetId,
  152. uint16_t payloadLength, const Packet::Verb verb, const int32_t flowId, int64_t now);
  153. /**
  154. * Record an invalid incoming packet. This packet failed
  155. * MAC/compression/cipher checks and will now contribute to a
  156. * Packet Error Ratio (PER).
  157. *
  158. * @param path Path over which packet was received
  159. */
  160. void recordIncomingInvalidPacket(const SharedPtr<Path>& path);
  161. /**
  162. * Get the most appropriate direct path based on current multipath and QoS configuration
  163. *
  164. * @param now Current time
  165. * @param includeExpired If true, include even expired paths
  166. * @return Best current path or NULL if none
  167. */
  168. SharedPtr<Path> getAppropriatePath(int64_t now, bool includeExpired, int32_t flowId = -1);
  169. /**
  170. * Send VERB_RENDEZVOUS to this and another peer via the best common IP scope and path
  171. */
  172. void introduce(void *const tPtr,const int64_t now,const SharedPtr<Peer> &other) const;
  173. /**
  174. * Send a HELLO to this peer at a specified physical address
  175. *
  176. * No statistics or sent times are updated here.
  177. *
  178. * @param tPtr Thread pointer to be handed through to any callbacks called as a result of this call
  179. * @param localSocket Local source socket
  180. * @param atAddress Destination address
  181. * @param now Current time
  182. */
  183. void sendHELLO(void *tPtr,const int64_t localSocket,const InetAddress &atAddress,int64_t now);
  184. /**
  185. * Send ECHO (or HELLO for older peers) to this peer at the given address
  186. *
  187. * No statistics or sent times are updated here.
  188. *
  189. * @param tPtr Thread pointer to be handed through to any callbacks called as a result of this call
  190. * @param localSocket Local source socket
  191. * @param atAddress Destination address
  192. * @param now Current time
  193. * @param sendFullHello If true, always send a full HELLO instead of just an ECHO
  194. */
  195. void attemptToContactAt(void *tPtr,const int64_t localSocket,const InetAddress &atAddress,int64_t now,bool sendFullHello);
  196. /**
  197. * Try a memorized or statically defined path if any are known
  198. *
  199. * Under the hood this is done periodically based on ZT_TRY_MEMORIZED_PATH_INTERVAL.
  200. *
  201. * @param tPtr Thread pointer to be handed through to any callbacks called as a result of this call
  202. * @param now Current time
  203. */
  204. void tryMemorizedPath(void *tPtr,int64_t now);
  205. /**
  206. * A check to be performed periodically which determines whether multipath communication is
  207. * possible with this peer. This check should be performed early in the life-cycle of the peer
  208. * as well as during the process of learning new paths.
  209. */
  210. void performMultipathStateCheck(void *tPtr, int64_t now);
  211. /**
  212. * Send pings or keepalives depending on configured timeouts
  213. *
  214. * This also cleans up some internal data structures. It's called periodically from Node.
  215. *
  216. * @param tPtr Thread pointer to be handed through to any callbacks called as a result of this call
  217. * @param now Current time
  218. * @param inetAddressFamily Keep this address family alive, or -1 for any
  219. * @return 0 if nothing sent or bit mask: bit 0x1 if IPv4 sent, bit 0x2 if IPv6 sent (0x3 means both sent)
  220. */
  221. unsigned int doPingAndKeepalive(void *tPtr,int64_t now);
  222. /**
  223. * Process a cluster redirect sent by this peer
  224. *
  225. * @param tPtr Thread pointer to be handed through to any callbacks called as a result of this call
  226. * @param originatingPath Path from which redirect originated
  227. * @param remoteAddress Remote address
  228. * @param now Current time
  229. */
  230. void clusterRedirect(void *tPtr,const SharedPtr<Path> &originatingPath,const InetAddress &remoteAddress,const int64_t now);
  231. /**
  232. * Reset paths within a given IP scope and address family
  233. *
  234. * Resetting a path involves sending an ECHO to it and then deactivating
  235. * it until or unless it responds. This is done when we detect a change
  236. * to our external IP or another system change that might invalidate
  237. * many or all current paths.
  238. *
  239. * @param tPtr Thread pointer to be handed through to any callbacks called as a result of this call
  240. * @param scope IP scope
  241. * @param inetAddressFamily Family e.g. AF_INET
  242. * @param now Current time
  243. */
  244. void resetWithinScope(void *tPtr,InetAddress::IpScope scope,int inetAddressFamily,int64_t now);
  245. /**
  246. * @param now Current time
  247. * @return All known paths to this peer
  248. */
  249. inline std::vector< SharedPtr<Path> > paths(const int64_t now) const
  250. {
  251. std::vector< SharedPtr<Path> > pp;
  252. Mutex::Lock _l(_paths_m);
  253. for(unsigned int i=0;i<ZT_MAX_PEER_NETWORK_PATHS;++i) {
  254. if (!_paths[i].p) break;
  255. pp.push_back(_paths[i].p);
  256. }
  257. return pp;
  258. }
  259. /**
  260. * @return Time of last receive of anything, whether direct or relayed
  261. */
  262. inline int64_t lastReceive() const { return _lastReceive; }
  263. /**
  264. * @return True if we've heard from this peer in less than ZT_PEER_ACTIVITY_TIMEOUT
  265. */
  266. inline bool isAlive(const int64_t now) const { return ((now - _lastReceive) < ZT_PEER_ACTIVITY_TIMEOUT); }
  267. /**
  268. * @return True if this peer has sent us real network traffic recently
  269. */
  270. inline int64_t isActive(int64_t now) const { return ((now - _lastNontrivialReceive) < ZT_PEER_ACTIVITY_TIMEOUT); }
  271. /**
  272. * @return Latency in milliseconds of best/aggregate path or 0xffff if unknown / no paths
  273. */
  274. inline unsigned int latency(const int64_t now)
  275. {
  276. if (_canUseMultipath) {
  277. return (int)_lastComputedAggregateMeanLatency;
  278. } else {
  279. SharedPtr<Path> bp(getAppropriatePath(now,false));
  280. if (bp)
  281. return bp->latency();
  282. return 0xffff;
  283. }
  284. }
  285. /**
  286. * This computes a quality score for relays and root servers
  287. *
  288. * If we haven't heard anything from these in ZT_PEER_ACTIVITY_TIMEOUT, they
  289. * receive the worst possible quality (max unsigned int). Otherwise the
  290. * quality is a product of latency and the number of potential missed
  291. * pings. This causes roots and relays to switch over a bit faster if they
  292. * fail.
  293. *
  294. * @return Relay quality score computed from latency and other factors, lower is better
  295. */
  296. inline unsigned int relayQuality(const int64_t now)
  297. {
  298. const uint64_t tsr = now - _lastReceive;
  299. if (tsr >= ZT_PEER_ACTIVITY_TIMEOUT)
  300. return (~(unsigned int)0);
  301. unsigned int l = latency(now);
  302. if (!l)
  303. l = 0xffff;
  304. return (l * (((unsigned int)tsr / (ZT_PEER_PING_PERIOD + 1000)) + 1));
  305. }
  306. /**
  307. * @return 256-bit secret symmetric encryption key
  308. */
  309. inline const unsigned char *key() const { return _key; }
  310. /**
  311. * Set the currently known remote version of this peer's client
  312. *
  313. * @param vproto Protocol version
  314. * @param vmaj Major version
  315. * @param vmin Minor version
  316. * @param vrev Revision
  317. */
  318. inline void setRemoteVersion(unsigned int vproto,unsigned int vmaj,unsigned int vmin,unsigned int vrev)
  319. {
  320. _vProto = (uint16_t)vproto;
  321. _vMajor = (uint16_t)vmaj;
  322. _vMinor = (uint16_t)vmin;
  323. _vRevision = (uint16_t)vrev;
  324. }
  325. inline unsigned int remoteVersionProtocol() const { return _vProto; }
  326. inline unsigned int remoteVersionMajor() const { return _vMajor; }
  327. inline unsigned int remoteVersionMinor() const { return _vMinor; }
  328. inline unsigned int remoteVersionRevision() const { return _vRevision; }
  329. inline bool remoteVersionKnown() const { return ((_vMajor > 0)||(_vMinor > 0)||(_vRevision > 0)); }
  330. /**
  331. * @return True if peer has received a trust established packet (e.g. common network membership) in the past ZT_TRUST_EXPIRATION ms
  332. */
  333. inline bool trustEstablished(const int64_t now) const { return ((now - _lastTrustEstablishedPacketReceived) < ZT_TRUST_EXPIRATION); }
  334. /**
  335. * Rate limit gate for VERB_PUSH_DIRECT_PATHS
  336. */
  337. inline bool rateGatePushDirectPaths(const int64_t now)
  338. {
  339. if ((now - _lastDirectPathPushReceive) <= ZT_PUSH_DIRECT_PATHS_CUTOFF_TIME)
  340. ++_directPathPushCutoffCount;
  341. else _directPathPushCutoffCount = 0;
  342. _lastDirectPathPushReceive = now;
  343. return (_directPathPushCutoffCount < ZT_PUSH_DIRECT_PATHS_CUTOFF_LIMIT);
  344. }
  345. /**
  346. * Rate limit gate for VERB_NETWORK_CREDENTIALS
  347. */
  348. inline bool rateGateCredentialsReceived(const int64_t now)
  349. {
  350. if ((now - _lastCredentialsReceived) <= ZT_PEER_CREDENTIALS_CUTOFF_TIME)
  351. ++_credentialsCutoffCount;
  352. else _credentialsCutoffCount = 0;
  353. _lastCredentialsReceived = now;
  354. return (_directPathPushCutoffCount < ZT_PEER_CREDEITIALS_CUTOFF_LIMIT);
  355. }
  356. /**
  357. * Rate limit gate for sending of ERROR_NEED_MEMBERSHIP_CERTIFICATE
  358. */
  359. inline bool rateGateRequestCredentials(const int64_t now)
  360. {
  361. if ((now - _lastCredentialRequestSent) >= ZT_PEER_GENERAL_RATE_LIMIT) {
  362. _lastCredentialRequestSent = now;
  363. return true;
  364. }
  365. return false;
  366. }
  367. /**
  368. * Rate limit gate for inbound WHOIS requests
  369. */
  370. inline bool rateGateInboundWhoisRequest(const int64_t now)
  371. {
  372. if ((now - _lastWhoisRequestReceived) >= ZT_PEER_WHOIS_RATE_LIMIT) {
  373. _lastWhoisRequestReceived = now;
  374. return true;
  375. }
  376. return false;
  377. }
  378. /**
  379. * Rate limit gate for inbound ECHO requests. This rate limiter works
  380. * by draining a certain number of requests per unit time. Each peer may
  381. * theoretically receive up to ZT_ECHO_CUTOFF_LIMIT requests per second.
  382. */
  383. inline bool rateGateEchoRequest(const int64_t now)
  384. {
  385. /*
  386. // TODO: Rethink this
  387. if (_canUseMultipath) {
  388. _echoRequestCutoffCount++;
  389. int numToDrain = (now - _lastEchoCheck) / ZT_ECHO_DRAINAGE_DIVISOR;
  390. _lastEchoCheck = now;
  391. fprintf(stderr, "ZT_ECHO_CUTOFF_LIMIT=%d, (now - _lastEchoCheck)=%d, numToDrain=%d, ZT_ECHO_DRAINAGE_DIVISOR=%d\n", ZT_ECHO_CUTOFF_LIMIT, (now - _lastEchoCheck), numToDrain, ZT_ECHO_DRAINAGE_DIVISOR);
  392. if (_echoRequestCutoffCount > numToDrain) {
  393. _echoRequestCutoffCount-=numToDrain;
  394. }
  395. else {
  396. _echoRequestCutoffCount = 0;
  397. }
  398. return (_echoRequestCutoffCount < ZT_ECHO_CUTOFF_LIMIT);
  399. } else {
  400. if ((now - _lastEchoRequestReceived) >= (ZT_PEER_GENERAL_RATE_LIMIT)) {
  401. _lastEchoRequestReceived = now;
  402. return true;
  403. }
  404. return false;
  405. }
  406. */
  407. return true;
  408. }
  409. /**
  410. * Serialize a peer for storage in local cache
  411. *
  412. * This does not serialize everything, just non-ephemeral information.
  413. */
  414. template<unsigned int C>
  415. inline void serializeForCache(Buffer<C> &b) const
  416. {
  417. b.append((uint8_t)1);
  418. _id.serialize(b);
  419. b.append((uint16_t)_vProto);
  420. b.append((uint16_t)_vMajor);
  421. b.append((uint16_t)_vMinor);
  422. b.append((uint16_t)_vRevision);
  423. {
  424. Mutex::Lock _l(_paths_m);
  425. unsigned int pc = 0;
  426. for(unsigned int i=0;i<ZT_MAX_PEER_NETWORK_PATHS;++i) {
  427. if (_paths[i].p)
  428. ++pc;
  429. else break;
  430. }
  431. b.append((uint16_t)pc);
  432. for(unsigned int i=0;i<pc;++i)
  433. _paths[i].p->address().serialize(b);
  434. }
  435. }
  436. template<unsigned int C>
  437. inline static SharedPtr<Peer> deserializeFromCache(int64_t now,void *tPtr,Buffer<C> &b,const RuntimeEnvironment *renv)
  438. {
  439. try {
  440. unsigned int ptr = 0;
  441. if (b[ptr++] != 1)
  442. return SharedPtr<Peer>();
  443. Identity id;
  444. ptr += id.deserialize(b,ptr);
  445. if (!id)
  446. return SharedPtr<Peer>();
  447. SharedPtr<Peer> p(new Peer(renv,renv->identity,id));
  448. p->_vProto = b.template at<uint16_t>(ptr); ptr += 2;
  449. p->_vMajor = b.template at<uint16_t>(ptr); ptr += 2;
  450. p->_vMinor = b.template at<uint16_t>(ptr); ptr += 2;
  451. p->_vRevision = b.template at<uint16_t>(ptr); ptr += 2;
  452. // When we deserialize from the cache we don't actually restore paths. We
  453. // just try them and then re-learn them if they happen to still be up.
  454. // Paths are fairly ephemeral in the real world in most cases.
  455. const unsigned int tryPathCount = b.template at<uint16_t>(ptr); ptr += 2;
  456. for(unsigned int i=0;i<tryPathCount;++i) {
  457. InetAddress inaddr;
  458. try {
  459. ptr += inaddr.deserialize(b,ptr);
  460. if (inaddr)
  461. p->attemptToContactAt(tPtr,-1,inaddr,now,true);
  462. } catch ( ... ) {
  463. break;
  464. }
  465. }
  466. return p;
  467. } catch ( ... ) {
  468. return SharedPtr<Peer>();
  469. }
  470. }
  471. /**
  472. *
  473. * @return
  474. */
  475. SharedPtr<Bond> bond() { return _bondToPeer; }
  476. /**
  477. *
  478. * @return
  479. */
  480. inline int8_t bondingPolicy() { return _bondingPolicy; }
  481. //inline const AES *aesKeysIfSupported() const
  482. //{ return (const AES *)0; }
  483. inline const AES *aesKeysIfSupported() const
  484. { return (_vProto >= 12) ? _aesKeys : (const AES *)0; }
  485. inline const AES *aesKeys() const
  486. { return _aesKeys; }
  487. private:
  488. struct _PeerPath
  489. {
  490. _PeerPath() : lr(0),p(),priority(1) {}
  491. int64_t lr; // time of last valid ZeroTier packet
  492. SharedPtr<Path> p;
  493. long priority; // >= 1, higher is better
  494. };
  495. uint8_t _key[ZT_SYMMETRIC_KEY_SIZE];
  496. AES _aesKeys[2];
  497. const RuntimeEnvironment *RR;
  498. int64_t _lastReceive; // direct or indirect
  499. int64_t _lastNontrivialReceive; // frames, things like netconf, etc.
  500. int64_t _lastTriedMemorizedPath;
  501. int64_t _lastDirectPathPushSent;
  502. int64_t _lastDirectPathPushReceive;
  503. int64_t _lastEchoRequestReceived;
  504. int64_t _lastCredentialRequestSent;
  505. int64_t _lastWhoisRequestReceived;
  506. int64_t _lastCredentialsReceived;
  507. int64_t _lastTrustEstablishedPacketReceived;
  508. int64_t _lastSentFullHello;
  509. int64_t _lastEchoCheck;
  510. unsigned char _freeRandomByte;
  511. uint16_t _vProto;
  512. uint16_t _vMajor;
  513. uint16_t _vMinor;
  514. uint16_t _vRevision;
  515. std::list< std::pair< Path *, int64_t > > _lastTriedPath;
  516. Mutex _lastTriedPath_m;
  517. _PeerPath _paths[ZT_MAX_PEER_NETWORK_PATHS];
  518. Mutex _paths_m;
  519. Identity _id;
  520. unsigned int _directPathPushCutoffCount;
  521. unsigned int _credentialsCutoffCount;
  522. unsigned int _echoRequestCutoffCount;
  523. AtomicCounter __refCount;
  524. bool _remotePeerMultipathEnabled;
  525. int _uniqueAlivePathCount;
  526. bool _localMultipathSupported;
  527. bool _remoteMultipathSupported;
  528. bool _canUseMultipath;
  529. volatile bool _shouldCollectPathStatistics;
  530. volatile int8_t _bondingPolicy;
  531. int32_t _lastComputedAggregateMeanLatency;
  532. SharedPtr<Bond> _bondToPeer;
  533. };
  534. } // namespace ZeroTier
  535. // Add a swap() for shared ptr's to peers to speed up peer sorts
  536. namespace std {
  537. template<>
  538. inline void swap(ZeroTier::SharedPtr<ZeroTier::Peer> &a,ZeroTier::SharedPtr<ZeroTier::Peer> &b)
  539. {
  540. a.swap(b);
  541. }
  542. }
  543. #endif