mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2024-12-19 13:07:55 +00:00
Merge branch 'dev' of http://10.6.6.2/zerotier/ZeroTierOne into dev
This commit is contained in:
commit
b8e46b835b
@ -287,6 +287,30 @@ InetAddress InetAddress::network() const
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ZT_SDK
|
||||||
|
bool InetAddress::isEqualPrefix(const InetAddress &addr) const
|
||||||
|
{
|
||||||
|
if (addr.ss_family == ss_family) {
|
||||||
|
switch(ss_family) {
|
||||||
|
case AF_INET6: {
|
||||||
|
const InetAddress mask(netmask());
|
||||||
|
InetAddress addr_mask(addr.netmask());
|
||||||
|
const uint8_t *n = reinterpret_cast<const uint8_t *>(reinterpret_cast<const struct sockaddr_in6 *>(&addr_mask)->sin6_addr.s6_addr);
|
||||||
|
const uint8_t *m = reinterpret_cast<const uint8_t *>(reinterpret_cast<const struct sockaddr_in6 *>(&mask)->sin6_addr.s6_addr);
|
||||||
|
const uint8_t *a = reinterpret_cast<const uint8_t *>(reinterpret_cast<const struct sockaddr_in6 *>(&addr)->sin6_addr.s6_addr);
|
||||||
|
const uint8_t *b = reinterpret_cast<const uint8_t *>(reinterpret_cast<const struct sockaddr_in6 *>(this)->sin6_addr.s6_addr);
|
||||||
|
for(unsigned int i=0;i<16;++i) {
|
||||||
|
if ((a[i] & m[i]) != (b[i] & n[i]))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
bool InetAddress::containsAddress(const InetAddress &addr) const
|
bool InetAddress::containsAddress(const InetAddress &addr) const
|
||||||
{
|
{
|
||||||
if (addr.ss_family == ss_family) {
|
if (addr.ss_family == ss_family) {
|
||||||
|
@ -355,6 +355,16 @@ struct InetAddress : public sockaddr_storage
|
|||||||
*/
|
*/
|
||||||
InetAddress network() const;
|
InetAddress network() const;
|
||||||
|
|
||||||
|
#ifdef ZT_SDK
|
||||||
|
/**
|
||||||
|
* Test whether this IPv6 prefix matches the prefix of a given IPv6 address
|
||||||
|
*
|
||||||
|
* @param addr Address to check
|
||||||
|
* @return True if this IPv6 prefix matches the prefix of a given IPv6 address
|
||||||
|
*/
|
||||||
|
bool isEqualPrefix(const InetAddress &addr) const;
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test whether this IP/netmask contains this address
|
* Test whether this IP/netmask contains this address
|
||||||
*
|
*
|
||||||
|
@ -104,11 +104,12 @@ namespace ZeroTier { typedef TestEthernetTap EthernetTap; }
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#ifdef ZT_SERVICE_NETCON
|
#ifdef ZT_SDK
|
||||||
|
#include "../controller/EmbeddedNetworkController.hpp"
|
||||||
#include "../netcon/NetconEthernetTap.hpp"
|
#include "../node/Node.hpp"
|
||||||
namespace ZeroTier { typedef NetconEthernetTap EthernetTap; }
|
// Use the virtual netcon endpoint instead of a tun/tap port driver
|
||||||
|
#include "../src/SocketTap.hpp"
|
||||||
|
namespace ZeroTier { typedef SocketTap EthernetTap; }
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
@ -989,6 +990,62 @@ public:
|
|||||||
else return std::string();
|
else return std::string();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ZT_SDK
|
||||||
|
virtual void leave(const char *hp)
|
||||||
|
{
|
||||||
|
_node->leave(Utils::hexStrToU64(hp),NULL,NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void join(const char *hp)
|
||||||
|
{
|
||||||
|
_node->join(Utils::hexStrToU64(hp),NULL,NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual std::string givenHomePath()
|
||||||
|
{
|
||||||
|
return _homePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual EthernetTap * getTap(uint64_t nwid)
|
||||||
|
{
|
||||||
|
Mutex::Lock _l(_nets_m);
|
||||||
|
std::map<uint64_t,NetworkState>::const_iterator n(_nets.find(nwid));
|
||||||
|
if (n == _nets.end())
|
||||||
|
return NULL;
|
||||||
|
return n->second.tap;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual EthernetTap *getTap(InetAddress &addr)
|
||||||
|
{
|
||||||
|
Mutex::Lock _l(_nets_m);
|
||||||
|
std::map<uint64_t,NetworkState>::iterator it;
|
||||||
|
for(it = _nets.begin(); it != _nets.end(); it++) {
|
||||||
|
if(it->second.tap) {
|
||||||
|
for(int j=0; j<it->second.tap->_ips.size(); j++) {
|
||||||
|
if(it->second.tap->_ips[j].isEqualPrefix(addr) || it->second.tap->_ips[j].ipsEqual(addr)) {
|
||||||
|
return it->second.tap;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual Node * getNode()
|
||||||
|
{
|
||||||
|
return _node;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void removeNets()
|
||||||
|
{
|
||||||
|
Mutex::Lock _l(_nets_m);
|
||||||
|
std::map<uint64_t,NetworkState>::iterator i;
|
||||||
|
for(i = _nets.begin(); i != _nets.end(); i++) {
|
||||||
|
delete i->second.tap;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif // ZT_SDK
|
||||||
|
|
||||||
virtual void terminate()
|
virtual void terminate()
|
||||||
{
|
{
|
||||||
_run_m.lock();
|
_run_m.lock();
|
||||||
@ -1158,9 +1215,11 @@ public:
|
|||||||
#else
|
#else
|
||||||
settings["portMappingEnabled"] = false; // not supported in build
|
settings["portMappingEnabled"] = false; // not supported in build
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef ZT_SDK
|
||||||
|
|
||||||
settings["softwareUpdate"] = OSUtils::jsonString(settings["softwareUpdate"],ZT_SOFTWARE_UPDATE_DEFAULT);
|
settings["softwareUpdate"] = OSUtils::jsonString(settings["softwareUpdate"],ZT_SOFTWARE_UPDATE_DEFAULT);
|
||||||
settings["softwareUpdateChannel"] = OSUtils::jsonString(settings["softwareUpdateChannel"],ZT_SOFTWARE_UPDATE_DEFAULT_CHANNEL);
|
settings["softwareUpdateChannel"] = OSUtils::jsonString(settings["softwareUpdateChannel"],ZT_SOFTWARE_UPDATE_DEFAULT_CHANNEL);
|
||||||
|
#endif
|
||||||
const World planet(_node->planet());
|
const World planet(_node->planet());
|
||||||
res["planetWorldId"] = planet.id();
|
res["planetWorldId"] = planet.id();
|
||||||
res["planetWorldTimestamp"] = planet.timestamp();
|
res["planetWorldTimestamp"] = planet.timestamp();
|
||||||
@ -1508,6 +1567,7 @@ public:
|
|||||||
_primaryPort = (unsigned int)OSUtils::jsonInt(settings["primaryPort"],(uint64_t)_primaryPort) & 0xffff;
|
_primaryPort = (unsigned int)OSUtils::jsonInt(settings["primaryPort"],(uint64_t)_primaryPort) & 0xffff;
|
||||||
_portMappingEnabled = OSUtils::jsonBool(settings["portMappingEnabled"],true);
|
_portMappingEnabled = OSUtils::jsonBool(settings["portMappingEnabled"],true);
|
||||||
|
|
||||||
|
#ifndef ZT_SDK
|
||||||
const std::string up(OSUtils::jsonString(settings["softwareUpdate"],ZT_SOFTWARE_UPDATE_DEFAULT));
|
const std::string up(OSUtils::jsonString(settings["softwareUpdate"],ZT_SOFTWARE_UPDATE_DEFAULT));
|
||||||
const bool udist = OSUtils::jsonBool(settings["softwareUpdateDist"],false);
|
const bool udist = OSUtils::jsonBool(settings["softwareUpdateDist"],false);
|
||||||
if (((up == "apply")||(up == "download"))||(udist)) {
|
if (((up == "apply")||(up == "download"))||(udist)) {
|
||||||
@ -1521,6 +1581,7 @@ public:
|
|||||||
_updater = (SoftwareUpdater *)0;
|
_updater = (SoftwareUpdater *)0;
|
||||||
_updateAutoApply = false;
|
_updateAutoApply = false;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
json &ignoreIfs = settings["interfacePrefixBlacklist"];
|
json &ignoreIfs = settings["interfacePrefixBlacklist"];
|
||||||
if (ignoreIfs.is_array()) {
|
if (ignoreIfs.is_array()) {
|
||||||
|
@ -32,6 +32,13 @@
|
|||||||
|
|
||||||
#include "../node/InetAddress.hpp"
|
#include "../node/InetAddress.hpp"
|
||||||
|
|
||||||
|
#ifdef ZT_SDK
|
||||||
|
#include "../node/Node.hpp"
|
||||||
|
// Use the virtual netcon endpoint instead of a tun/tap port driver
|
||||||
|
#include "../src/SocketTap.hpp"
|
||||||
|
namespace ZeroTier { typedef SocketTap EthernetTap; }
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace ZeroTier {
|
namespace ZeroTier {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -139,6 +146,43 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual std::string portDeviceName(uint64_t nwid) const = 0;
|
virtual std::string portDeviceName(uint64_t nwid) const = 0;
|
||||||
|
|
||||||
|
#ifdef ZT_SDK
|
||||||
|
/**
|
||||||
|
* Leaves a network
|
||||||
|
*/
|
||||||
|
virtual void leave(const char *hp) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Joins a network
|
||||||
|
*/
|
||||||
|
virtual void join(const char *hp) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the homePath given by the client application
|
||||||
|
*/
|
||||||
|
virtual std::string givenHomePath() = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Returns a SocketTap that is associated with the given nwid
|
||||||
|
*/
|
||||||
|
virtual EthernetTap * getTap(uint64_t nwid) = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Returns a SocketTap that cant function as a route to the specified host
|
||||||
|
*/
|
||||||
|
virtual EthernetTap * getTap(InetAddress &addr) = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Returns a pointer to the Node
|
||||||
|
*/
|
||||||
|
virtual Node * getNode() = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Delete all SocketTap interfaces
|
||||||
|
*/
|
||||||
|
virtual void removeNets() = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Terminate background service (can be called from other threads)
|
* Terminate background service (can be called from other threads)
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user