mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-04-19 13:36:54 +02:00
Go build stuff, root stuff
This commit is contained in:
parent
68ac884d47
commit
507ba7d26a
7 changed files with 54 additions and 14 deletions
|
@ -195,6 +195,14 @@ endif(WIN32)
|
|||
#target_link_libraries(${PROJECT_NAME} ${libs})
|
||||
#target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_BINARY_DIR})
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT zerotier
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/go
|
||||
COMMAND go build -trimpath -ldflags -s -o ../build/zerotier cmd/zerotier/zerotier.go
|
||||
DEPENDS zt_osdep zt_core zt_go_native
|
||||
)
|
||||
add_custom_target(build_zerotier ALL DEPENDS zerotier)
|
||||
|
||||
add_executable(zerotier-selftest selftest.cpp)
|
||||
target_link_libraries(zerotier-selftest ${libs} zt_core zt_osdep)
|
||||
target_compile_features(zerotier-selftest PUBLIC cxx_std_11)
|
||||
|
|
|
@ -747,7 +747,7 @@ func (n *Node) makeStateObjectPath(objType int, id [2]uint64) (string, bool) {
|
|||
fp = path.Join(n.basePath, "networks.d")
|
||||
_ = os.Mkdir(fp, 0755)
|
||||
fp = path.Join(fp, fmt.Sprintf("%.16x.conf", id[0]))
|
||||
case C.ZT_STATE_OBJECT_ROOT_LIST:
|
||||
case C.ZT_STATE_OBJECT_ROOTS:
|
||||
fp = path.Join(n.basePath, "roots")
|
||||
}
|
||||
return fp, secret
|
||||
|
|
|
@ -166,11 +166,6 @@ extern "C" {
|
|||
*/
|
||||
#define ZT_MAX_MULTICAST_SUBSCRIPTIONS 1024
|
||||
|
||||
/**
|
||||
* Maximum size for a state object (via state object put/get callbacks/API)
|
||||
*/
|
||||
#define ZT_MAX_STATE_OBJECT_SIZE 4096
|
||||
|
||||
/**
|
||||
* Maximum value for link quality (min is 0)
|
||||
*/
|
||||
|
@ -1342,7 +1337,7 @@ enum ZT_StateObjectType
|
|||
* Canonical path: <HOME>/roots
|
||||
* Persitence: required if root settings should persist
|
||||
*/
|
||||
ZT_STATE_OBJECT_ROOT_LIST = 7
|
||||
ZT_STATE_OBJECT_ROOTS = 7
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -189,6 +189,20 @@
|
|||
*/
|
||||
#define ZT_ADDRESS_RESERVED_PREFIX 0xff
|
||||
|
||||
/**
|
||||
* Secure DNS name for ZeroTier's default root
|
||||
*
|
||||
* This resolves via GeoDNS to the (probably) nearest actual root server's locator.
|
||||
*/
|
||||
#define ZT_DEFAULT_ROOT_NAME "ztl-aj4zes4l6zumq64na6borruuvd6diw2koxrjcaatolcekt2gj5rrhric.ztl-6lhxeo7n3z7kzkgcqzj3ndliaq.zerotier.network"
|
||||
|
||||
/**
|
||||
* Default locator for default root
|
||||
*
|
||||
* This is used before the root has been successfully fetched, or if DNS is unavailable.
|
||||
*/
|
||||
#define ZT_DEFAULT_ROOT_LOCATOR "AAAAAW2OuYyfOkbxvzAAduZvqzPihUmmLuIGTRhDJzwsMAukXD8gvvAtutIlcju1mpu0sTU1cwlhruz1oWOs5HfM6wcnAluZrBSlFmoJowAEBLm0DVInCQS5tA1SAbsGKgJuoMgVAAAAAAAAAAAAACcJBioCbqDIFQAAAAAAAAAAAAABuwAAYDvTNB2snbn7TYom4PBTh/ohRgCnI2/A/nfKakGCb+2hGJTtxTCiGTzKZdbjd0vyKAKQLJxhj7RaoCo3XjPn8w9nDEmhdNCgCM/IITCJIzc9tEKFsSQnJY4VmB3dopBAfQAA"
|
||||
|
||||
/**
|
||||
* Default virtual network MTU (not physical)
|
||||
*/
|
||||
|
|
|
@ -27,8 +27,8 @@
|
|||
#include <vector>
|
||||
|
||||
// These are absolute maximums -- real locators are never this big
|
||||
#define ZT_LOCATOR_MAX_PHYSICAL_ADDRESSES 255
|
||||
#define ZT_LOCATOR_MAX_VIRTUAL_ADDRESSES 255
|
||||
#define ZT_LOCATOR_MAX_PHYSICAL_ADDRESSES 64
|
||||
#define ZT_LOCATOR_MAX_VIRTUAL_ADDRESSES 64
|
||||
|
||||
namespace ZeroTier {
|
||||
|
||||
|
|
17
node/Str.hpp
17
node/Str.hpp
|
@ -197,6 +197,23 @@ public:
|
|||
return h;
|
||||
}
|
||||
|
||||
template<unsigned int C>
|
||||
inline void serialize(Buffer<C> &b,const bool forSign = false) const
|
||||
{
|
||||
b.append(_l);
|
||||
b.append(_s,(unsigned int)_l);
|
||||
}
|
||||
|
||||
template<unsigned int C>
|
||||
inline unsigned int deserialize(const Buffer<C> &b,unsigned int startAt = 0)
|
||||
{
|
||||
unsigned int p = startAt;
|
||||
_l = (uint8_t)b[p++];
|
||||
memcpy(_s,b.field(p,(unsigned int)_l),(unsigned long)_l);
|
||||
p += (unsigned int)_l;
|
||||
return (p - startAt);
|
||||
}
|
||||
|
||||
private:
|
||||
uint8_t _l;
|
||||
char _s[ZT_STR_CAPACITY+1];
|
||||
|
|
|
@ -64,7 +64,7 @@ private:
|
|||
unsigned int bestRootLatency;
|
||||
};
|
||||
|
||||
ZT_ALWAYS_INLINE void _updateDynamicRootIdentities()
|
||||
ZT_ALWAYS_INLINE void _updateRoots()
|
||||
{
|
||||
// assumes _roots_l is locked
|
||||
_rootIdentities.clear();
|
||||
|
@ -334,11 +334,13 @@ public:
|
|||
Locator &ll = _roots[name];
|
||||
if (ll.timestamp() < latestLocator.timestamp()) {
|
||||
ll = latestLocator;
|
||||
_updateDynamicRootIdentities();
|
||||
_updateRoots();
|
||||
_rootsModified = true;
|
||||
return true;
|
||||
}
|
||||
} else if (!_roots.contains(name)) {
|
||||
_roots[name];
|
||||
_roots.set(name,Locator()); // no locator known yet, but add name to name list to trigger DNS refreshing
|
||||
_rootsModified = true;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -350,8 +352,10 @@ public:
|
|||
inline void removeRoot(const Str &name)
|
||||
{
|
||||
Mutex::Lock l(_roots_l);
|
||||
_roots.erase(name);
|
||||
_updateDynamicRootIdentities();
|
||||
if (_roots.erase(name)) {
|
||||
_updateRoots();
|
||||
_rootsModified = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -529,8 +533,10 @@ private:
|
|||
|
||||
Hashtable< Address,SharedPtr<Peer> > _peers;
|
||||
Hashtable< Path::HashKey,SharedPtr<Path> > _paths;
|
||||
|
||||
Hashtable< Str,Locator > _roots;
|
||||
Hashtable< Identity,bool > _rootIdentities;
|
||||
bool _rootsModified;
|
||||
|
||||
int64_t _lastUpdatedBestRoot;
|
||||
SharedPtr<Peer> _bestRoot;
|
||||
|
|
Loading…
Add table
Reference in a new issue