mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-06 20:43:44 +02:00
.
This commit is contained in:
parent
4da315fab2
commit
22e95b3bcb
6 changed files with 45 additions and 11 deletions
|
@ -10,7 +10,7 @@ License text copyright (c) 2017 MariaDB Corporation Ab, All Rights Reserved.
|
||||||
Parameters
|
Parameters
|
||||||
|
|
||||||
Licensor: ZeroTier, Inc.
|
Licensor: ZeroTier, Inc.
|
||||||
Licensed Work: ZeroTier Network Virtualization Engine 1.4.4
|
Licensed Work: ZeroTier Network Virtualization Engine
|
||||||
The Licensed Work is (c)2019 ZeroTier, Inc.
|
The Licensed Work is (c)2019 ZeroTier, Inc.
|
||||||
Additional Use Grant: You may make use of the Licensed Work, provided you
|
Additional Use Grant: You may make use of the Licensed Work, provided you
|
||||||
do not use it in any of the following ways:
|
do not use it in any of the following ways:
|
||||||
|
@ -26,7 +26,7 @@ Additional Use Grant: You may make use of the Licensed Work, provided you
|
||||||
ZeroTier behind the scenes to operate a service not
|
ZeroTier behind the scenes to operate a service not
|
||||||
related to ZeroTier network administration.
|
related to ZeroTier network administration.
|
||||||
|
|
||||||
* Create Non-Open-Source Commercial Derviative Works
|
* Create Non-Open-Source Commercial Derivative Works
|
||||||
|
|
||||||
(2) Link or directly include the Licensed Work in a
|
(2) Link or directly include the Licensed Work in a
|
||||||
commercial or for-profit application or other product
|
commercial or for-profit application or other product
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include "SHA512.hpp"
|
#include "SHA512.hpp"
|
||||||
#include "Str.hpp"
|
#include "Str.hpp"
|
||||||
#include "ScopedPtr.hpp"
|
#include "ScopedPtr.hpp"
|
||||||
|
#include "SharedPtr.hpp"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
@ -43,6 +44,8 @@ namespace ZeroTier {
|
||||||
*/
|
*/
|
||||||
class Locator
|
class Locator
|
||||||
{
|
{
|
||||||
|
friend class SharedPtr<Locator>;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ZT_ALWAYS_INLINE Locator() : _ts(0),_signatureLength(0) {}
|
ZT_ALWAYS_INLINE Locator() : _ts(0),_signatureLength(0) {}
|
||||||
|
|
||||||
|
@ -371,6 +374,7 @@ private:
|
||||||
std::vector<Identity> _virtual;
|
std::vector<Identity> _virtual;
|
||||||
unsigned int _signatureLength;
|
unsigned int _signatureLength;
|
||||||
uint8_t _signature[ZT_SIGNATURE_BUFFER_SIZE];
|
uint8_t _signature[ZT_SIGNATURE_BUFFER_SIZE];
|
||||||
|
AtomicCounter __refCount;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace ZeroTier
|
} // namespace ZeroTier
|
||||||
|
|
|
@ -639,6 +639,33 @@ void Node::setController(void *networkControllerInstance)
|
||||||
/* Node methods used only within node/ */
|
/* Node methods used only within node/ */
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
|
||||||
|
SharedPtr< const Locator > Node::locator()
|
||||||
|
{
|
||||||
|
Mutex::Lock lck(_locator_m);
|
||||||
|
if (!_locator) {
|
||||||
|
Locator *l = new Locator();
|
||||||
|
try {
|
||||||
|
RR->topology->eachRoot([l](const SharedPtr<Peer> &p,const std::vector<InetAddress> &phyAddr) -> bool {
|
||||||
|
l->add(p->identity());
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
{
|
||||||
|
Mutex::Lock lck2(_localInterfaceAddresses_m);
|
||||||
|
for(std::vector< ZT_InterfaceAddress >::const_iterator a(_localInterfaceAddresses.begin());a!=_localInterfaceAddresses.end();++a) {
|
||||||
|
if (a->permanent != 0) {
|
||||||
|
l->add(*reinterpret_cast<const InetAddress *>(&(a->address)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch ( ... ) {
|
||||||
|
delete l;
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
_locator.set(l);
|
||||||
|
}
|
||||||
|
return _locator;
|
||||||
|
}
|
||||||
|
|
||||||
bool Node::shouldUsePathForZeroTierTraffic(void *tPtr,const Address &ztaddr,const int64_t localSocket,const InetAddress &remoteAddress)
|
bool Node::shouldUsePathForZeroTierTraffic(void *tPtr,const Address &ztaddr,const int64_t localSocket,const InetAddress &remoteAddress)
|
||||||
{
|
{
|
||||||
if (!Path::isAddressValidForPath(remoteAddress))
|
if (!Path::isAddressValidForPath(remoteAddress))
|
||||||
|
|
|
@ -41,6 +41,8 @@
|
||||||
|
|
||||||
namespace ZeroTier {
|
namespace ZeroTier {
|
||||||
|
|
||||||
|
class Locator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of Node object as defined in CAPI
|
* Implementation of Node object as defined in CAPI
|
||||||
*
|
*
|
||||||
|
@ -175,6 +177,7 @@ public:
|
||||||
|
|
||||||
void setInterfaceAddresses(const ZT_InterfaceAddress *addrs,unsigned int addrCount);
|
void setInterfaceAddresses(const ZT_InterfaceAddress *addrs,unsigned int addrCount);
|
||||||
|
|
||||||
|
SharedPtr< const Locator > locator();
|
||||||
ZT_ALWAYS_INLINE void postEvent(void *tPtr,ZT_Event ev,const void *md = (const void *)0) { _cb.eventCallback(reinterpret_cast<ZT_Node *>(this),_uPtr,tPtr,ev,md); }
|
ZT_ALWAYS_INLINE void postEvent(void *tPtr,ZT_Event ev,const void *md = (const void *)0) { _cb.eventCallback(reinterpret_cast<ZT_Node *>(this),_uPtr,tPtr,ev,md); }
|
||||||
ZT_ALWAYS_INLINE void configureVirtualNetworkPort(void *tPtr,uint64_t nwid,void **nuptr,ZT_VirtualNetworkConfigOperation op,const ZT_VirtualNetworkConfig *nc) { _cb.virtualNetworkConfigFunction(reinterpret_cast<ZT_Node *>(this),_uPtr,tPtr,nwid,nuptr,op,nc); }
|
ZT_ALWAYS_INLINE void configureVirtualNetworkPort(void *tPtr,uint64_t nwid,void **nuptr,ZT_VirtualNetworkConfigOperation op,const ZT_VirtualNetworkConfig *nc) { _cb.virtualNetworkConfigFunction(reinterpret_cast<ZT_Node *>(this),_uPtr,tPtr,nwid,nuptr,op,nc); }
|
||||||
ZT_ALWAYS_INLINE bool online() const { return _online; }
|
ZT_ALWAYS_INLINE bool online() const { return _online; }
|
||||||
|
@ -284,14 +287,14 @@ private:
|
||||||
ZT_ALWAYS_INLINE bool operator!=(const _LocalControllerAuth &a) const { return ((a.nwid != nwid)||(a.address != address)); }
|
ZT_ALWAYS_INLINE bool operator!=(const _LocalControllerAuth &a) const { return ((a.nwid != nwid)||(a.address != address)); }
|
||||||
};
|
};
|
||||||
Hashtable< _LocalControllerAuth,int64_t > _localControllerAuthorizations;
|
Hashtable< _LocalControllerAuth,int64_t > _localControllerAuthorizations;
|
||||||
Mutex _localControllerAuthorizations_m;
|
|
||||||
|
|
||||||
Hashtable< uint64_t,SharedPtr<Network> > _networks;
|
Hashtable< uint64_t,SharedPtr<Network> > _networks;
|
||||||
Mutex _networks_m;
|
SharedPtr< const Locator > _locator;
|
||||||
|
|
||||||
std::vector< ZT_InterfaceAddress > _localInterfaceAddresses;
|
std::vector< ZT_InterfaceAddress > _localInterfaceAddresses;
|
||||||
Mutex _localInterfaceAddresses_m;
|
|
||||||
|
|
||||||
|
Mutex _localControllerAuthorizations_m;
|
||||||
|
Mutex _networks_m;
|
||||||
|
Mutex _locator_m;
|
||||||
|
Mutex _localInterfaceAddresses_m;
|
||||||
Mutex _backgroundTasksLock;
|
Mutex _backgroundTasksLock;
|
||||||
|
|
||||||
uint8_t _multipathMode;
|
uint8_t _multipathMode;
|
||||||
|
|
|
@ -525,8 +525,6 @@ private:
|
||||||
unsigned int _QoSCutoffCount;
|
unsigned int _QoSCutoffCount;
|
||||||
unsigned int _ACKCutoffCount;
|
unsigned int _ACKCutoffCount;
|
||||||
|
|
||||||
AtomicCounter __refCount;
|
|
||||||
|
|
||||||
RingBuffer<int,ZT_MULTIPATH_PROPORTION_WIN_SZ> _pathChoiceHist;
|
RingBuffer<int,ZT_MULTIPATH_PROPORTION_WIN_SZ> _pathChoiceHist;
|
||||||
|
|
||||||
bool _linkIsBalanced;
|
bool _linkIsBalanced;
|
||||||
|
@ -537,6 +535,8 @@ private:
|
||||||
int64_t _lastAggregateAllocation;
|
int64_t _lastAggregateAllocation;
|
||||||
|
|
||||||
char _interfaceListStr[256]; // 16 characters * 16 paths in a link
|
char _interfaceListStr[256]; // 16 characters * 16 paths in a link
|
||||||
|
|
||||||
|
AtomicCounter __refCount;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace ZeroTier
|
} // namespace ZeroTier
|
||||||
|
|
|
@ -70,7 +70,7 @@ private:
|
||||||
_rootIdentities.clear();
|
_rootIdentities.clear();
|
||||||
Hashtable< Str,Locator >::Iterator i(_roots);
|
Hashtable< Str,Locator >::Iterator i(_roots);
|
||||||
Str *k = (Str *)0;
|
Str *k = (Str *)0;
|
||||||
Locator *v = (Locator *)0;
|
SharedPtr< const Locator > *v = (SharedPtr< const Locator > *)0;
|
||||||
while (i.next(k,v)) {
|
while (i.next(k,v)) {
|
||||||
if (*v)
|
if (*v)
|
||||||
_rootIdentities.set(v->id(),true);
|
_rootIdentities.set(v->id(),true);
|
||||||
|
@ -534,7 +534,7 @@ private:
|
||||||
Hashtable< Address,SharedPtr<Peer> > _peers;
|
Hashtable< Address,SharedPtr<Peer> > _peers;
|
||||||
Hashtable< Path::HashKey,SharedPtr<Path> > _paths;
|
Hashtable< Path::HashKey,SharedPtr<Path> > _paths;
|
||||||
|
|
||||||
Hashtable< Str,Locator > _roots;
|
Hashtable< Str,SharedPtr<const Locator> > _roots;
|
||||||
Hashtable< Identity,bool > _rootIdentities;
|
Hashtable< Identity,bool > _rootIdentities;
|
||||||
bool _rootsModified;
|
bool _rootsModified;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue