This commit is contained in:
Adam Ierymenko 2019-10-09 10:00:30 -07:00
parent 4da315fab2
commit 22e95b3bcb
No known key found for this signature in database
GPG key ID: C8877CF2D7A5D7F3
6 changed files with 45 additions and 11 deletions

View file

@ -10,7 +10,7 @@ License text copyright (c) 2017 MariaDB Corporation Ab, All Rights Reserved.
Parameters
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.
Additional Use Grant: You may make use of the Licensed Work, provided you
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
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
commercial or for-profit application or other product

View file

@ -22,6 +22,7 @@
#include "SHA512.hpp"
#include "Str.hpp"
#include "ScopedPtr.hpp"
#include "SharedPtr.hpp"
#include <algorithm>
#include <vector>
@ -43,6 +44,8 @@ namespace ZeroTier {
*/
class Locator
{
friend class SharedPtr<Locator>;
public:
ZT_ALWAYS_INLINE Locator() : _ts(0),_signatureLength(0) {}
@ -371,6 +374,7 @@ private:
std::vector<Identity> _virtual;
unsigned int _signatureLength;
uint8_t _signature[ZT_SIGNATURE_BUFFER_SIZE];
AtomicCounter __refCount;
};
} // namespace ZeroTier

View file

@ -639,6 +639,33 @@ void Node::setController(void *networkControllerInstance)
/* 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)
{
if (!Path::isAddressValidForPath(remoteAddress))

View file

@ -41,6 +41,8 @@
namespace ZeroTier {
class Locator;
/**
* Implementation of Node object as defined in CAPI
*
@ -175,6 +177,7 @@ public:
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 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; }
@ -284,14 +287,14 @@ private:
ZT_ALWAYS_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;
SharedPtr< const Locator > _locator;
std::vector< ZT_InterfaceAddress > _localInterfaceAddresses;
Mutex _localControllerAuthorizations_m;
Mutex _networks_m;
std::vector<ZT_InterfaceAddress> _localInterfaceAddresses;
Mutex _locator_m;
Mutex _localInterfaceAddresses_m;
Mutex _backgroundTasksLock;
uint8_t _multipathMode;

View file

@ -525,8 +525,6 @@ private:
unsigned int _QoSCutoffCount;
unsigned int _ACKCutoffCount;
AtomicCounter __refCount;
RingBuffer<int,ZT_MULTIPATH_PROPORTION_WIN_SZ> _pathChoiceHist;
bool _linkIsBalanced;
@ -537,6 +535,8 @@ private:
int64_t _lastAggregateAllocation;
char _interfaceListStr[256]; // 16 characters * 16 paths in a link
AtomicCounter __refCount;
};
} // namespace ZeroTier

View file

@ -70,7 +70,7 @@ private:
_rootIdentities.clear();
Hashtable< Str,Locator >::Iterator i(_roots);
Str *k = (Str *)0;
Locator *v = (Locator *)0;
SharedPtr< const Locator > *v = (SharedPtr< const Locator > *)0;
while (i.next(k,v)) {
if (*v)
_rootIdentities.set(v->id(),true);
@ -534,7 +534,7 @@ private:
Hashtable< Address,SharedPtr<Peer> > _peers;
Hashtable< Path::HashKey,SharedPtr<Path> > _paths;
Hashtable< Str,Locator > _roots;
Hashtable< Str,SharedPtr<const Locator> > _roots;
Hashtable< Identity,bool > _rootIdentities;
bool _rootsModified;