mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-05 03:53:44 +02:00
.
This commit is contained in:
parent
61d0f27d2a
commit
9180a30986
9 changed files with 17 additions and 18 deletions
|
@ -72,7 +72,7 @@ void MulticastTopology::erase(const MulticastGroup &mg,const Address &member)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int MulticastTopology::want(const MulticastGroup &mg,uint64_t now,unsigned int limit,bool updateLastGatheredTimeOnNonzeroReturn)
|
unsigned int MulticastTopology::shouldGather(const MulticastGroup &mg,uint64_t now,unsigned int limit,bool updateLastGatheredTimeOnNonzeroReturn)
|
||||||
{
|
{
|
||||||
Mutex::Lock _l(_groups_m);
|
Mutex::Lock _l(_groups_m);
|
||||||
MulticastGroupStatus &gs = _groups[mg];
|
MulticastGroupStatus &gs = _groups[mg];
|
||||||
|
|
|
@ -112,7 +112,7 @@ public:
|
||||||
* @param limit The maximum number we want per multicast group on this network
|
* @param limit The maximum number we want per multicast group on this network
|
||||||
* @param updateLastGatheredTimeOnNonzeroReturn If true, reset group's last gathered time to 'now' on non-zero return
|
* @param updateLastGatheredTimeOnNonzeroReturn If true, reset group's last gathered time to 'now' on non-zero return
|
||||||
*/
|
*/
|
||||||
unsigned int want(const MulticastGroup &mg,uint64_t now,unsigned int limit,bool updateLastGatheredTimeOnNonzeroReturn);
|
unsigned int shouldGather(const MulticastGroup &mg,uint64_t now,unsigned int limit,bool updateLastGatheredTimeOnNonzeroReturn);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update last gathered members time for a group
|
* Update last gathered members time for a group
|
||||||
|
|
|
@ -281,14 +281,13 @@ bool Network::isAllowed(const Address &peer) const
|
||||||
|
|
||||||
void Network::clean()
|
void Network::clean()
|
||||||
{
|
{
|
||||||
|
uint64_t now = Utils::now();
|
||||||
{
|
{
|
||||||
Mutex::Lock _l(_lock);
|
Mutex::Lock _l(_lock);
|
||||||
|
|
||||||
if (_destroyed)
|
if (_destroyed)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
uint64_t now = Utils::now();
|
|
||||||
|
|
||||||
if ((_config)&&(_config->isPublic())) {
|
if ((_config)&&(_config->isPublic())) {
|
||||||
// Open (public) networks do not track certs or cert pushes at all.
|
// Open (public) networks do not track certs or cert pushes at all.
|
||||||
_membershipCertificates.clear();
|
_membershipCertificates.clear();
|
||||||
|
@ -318,7 +317,6 @@ void Network::clean()
|
||||||
else ++mg;
|
else ++mg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
_multicastTopology.clean(now,*(_r->topology),(_config) ? _config->multicastLimit() : (unsigned int)ZT_DEFAULT_MULTICAST_LIMIT);
|
_multicastTopology.clean(now,*(_r->topology),(_config) ? _config->multicastLimit() : (unsigned int)ZT_DEFAULT_MULTICAST_LIMIT);
|
||||||
}
|
}
|
||||||
|
|
|
@ -413,6 +413,12 @@ public:
|
||||||
*/
|
*/
|
||||||
void setEnabled(bool enabled);
|
void setEnabled(bool enabled);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Multicast topology for this network
|
||||||
|
*/
|
||||||
|
inline MulticastTopology &mcTopology() { return _multicastTopology; }
|
||||||
|
inline const MulticastTopology &mcTopology() const { return _multicastTopology; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destroy this network
|
* Destroy this network
|
||||||
*
|
*
|
||||||
|
|
|
@ -85,18 +85,16 @@ void NetworkConfig::_fromDictionary(const Dictionary &d)
|
||||||
|
|
||||||
_timestamp = Utils::hexStrToU64(d.get(ZT_NETWORKCONFIG_DICT_KEY_TIMESTAMP).c_str());
|
_timestamp = Utils::hexStrToU64(d.get(ZT_NETWORKCONFIG_DICT_KEY_TIMESTAMP).c_str());
|
||||||
_issuedTo = Address(d.get(ZT_NETWORKCONFIG_DICT_KEY_ISSUED_TO));
|
_issuedTo = Address(d.get(ZT_NETWORKCONFIG_DICT_KEY_ISSUED_TO));
|
||||||
_multicastPrefixBits = Utils::hexStrToUInt(d.get(ZT_NETWORKCONFIG_DICT_KEY_MULTICAST_PREFIX_BITS,zero).c_str());
|
_multicastLimit = Utils::hexStrToUInt(d.get(ZT_NETWORKCONFIG_DICT_KEY_MULTICAST_LIMIT,zero).c_str());
|
||||||
if (!_multicastPrefixBits)
|
if (_multicastLimit == 0) _multicastLimit = ZT_DEFAULT_MULTICAST_LIMIT;
|
||||||
_multicastPrefixBits = ZT_DEFAULT_MULTICAST_PREFIX_BITS;
|
|
||||||
_multicastDepth = Utils::hexStrToUInt(d.get(ZT_NETWORKCONFIG_DICT_KEY_MULTICAST_DEPTH,zero).c_str());
|
|
||||||
if (!_multicastDepth)
|
|
||||||
_multicastDepth = ZT_DEFAULT_MULTICAST_DEPTH;
|
|
||||||
_allowPassiveBridging = (Utils::hexStrToUInt(d.get(ZT_NETWORKCONFIG_DICT_KEY_ALLOW_PASSIVE_BRIDGING,zero).c_str()) != 0);
|
_allowPassiveBridging = (Utils::hexStrToUInt(d.get(ZT_NETWORKCONFIG_DICT_KEY_ALLOW_PASSIVE_BRIDGING,zero).c_str()) != 0);
|
||||||
_private = (Utils::hexStrToUInt(d.get(ZT_NETWORKCONFIG_DICT_KEY_PRIVATE,one).c_str()) != 0);
|
_private = (Utils::hexStrToUInt(d.get(ZT_NETWORKCONFIG_DICT_KEY_PRIVATE,one).c_str()) != 0);
|
||||||
_enableBroadcast = (Utils::hexStrToUInt(d.get(ZT_NETWORKCONFIG_DICT_KEY_ENABLE_BROADCAST,one).c_str()) != 0);
|
_enableBroadcast = (Utils::hexStrToUInt(d.get(ZT_NETWORKCONFIG_DICT_KEY_ENABLE_BROADCAST,one).c_str()) != 0);
|
||||||
_name = d.get(ZT_NETWORKCONFIG_DICT_KEY_NAME);
|
_name = d.get(ZT_NETWORKCONFIG_DICT_KEY_NAME);
|
||||||
_description = d.get(ZT_NETWORKCONFIG_DICT_KEY_DESC,std::string());
|
_description = d.get(ZT_NETWORKCONFIG_DICT_KEY_DESC,std::string());
|
||||||
|
|
||||||
|
// In dictionary IPs are split into V4 and V6 addresses, but we don't really
|
||||||
|
// need that so merge them here.
|
||||||
std::string ipAddrs(d.get(ZT_NETWORKCONFIG_DICT_KEY_IPV4_STATIC,std::string()));
|
std::string ipAddrs(d.get(ZT_NETWORKCONFIG_DICT_KEY_IPV4_STATIC,std::string()));
|
||||||
{
|
{
|
||||||
std::string v6s(d.get(ZT_NETWORKCONFIG_DICT_KEY_IPV6_STATIC,std::string()));
|
std::string v6s(d.get(ZT_NETWORKCONFIG_DICT_KEY_IPV6_STATIC,std::string()));
|
||||||
|
|
|
@ -52,8 +52,7 @@ namespace ZeroTier {
|
||||||
#define ZT_NETWORKCONFIG_DICT_KEY_NETWORK_ID "nwid"
|
#define ZT_NETWORKCONFIG_DICT_KEY_NETWORK_ID "nwid"
|
||||||
#define ZT_NETWORKCONFIG_DICT_KEY_TIMESTAMP "ts"
|
#define ZT_NETWORKCONFIG_DICT_KEY_TIMESTAMP "ts"
|
||||||
#define ZT_NETWORKCONFIG_DICT_KEY_ISSUED_TO "id"
|
#define ZT_NETWORKCONFIG_DICT_KEY_ISSUED_TO "id"
|
||||||
#define ZT_NETWORKCONFIG_DICT_KEY_MULTICAST_PREFIX_BITS "mpb"
|
#define ZT_NETWORKCONFIG_DICT_KEY_MULTICAST_LIMIT "ml"
|
||||||
#define ZT_NETWORKCONFIG_DICT_KEY_MULTICAST_DEPTH "md"
|
|
||||||
#define ZT_NETWORKCONFIG_DICT_KEY_MULTICAST_RATES "mr"
|
#define ZT_NETWORKCONFIG_DICT_KEY_MULTICAST_RATES "mr"
|
||||||
#define ZT_NETWORKCONFIG_DICT_KEY_PRIVATE "p"
|
#define ZT_NETWORKCONFIG_DICT_KEY_PRIVATE "p"
|
||||||
#define ZT_NETWORKCONFIG_DICT_KEY_NAME "n"
|
#define ZT_NETWORKCONFIG_DICT_KEY_NAME "n"
|
||||||
|
@ -116,8 +115,7 @@ public:
|
||||||
inline uint64_t networkId() const throw() { return _nwid; }
|
inline uint64_t networkId() const throw() { return _nwid; }
|
||||||
inline uint64_t timestamp() const throw() { return _timestamp; }
|
inline uint64_t timestamp() const throw() { return _timestamp; }
|
||||||
inline const Address &issuedTo() const throw() { return _issuedTo; }
|
inline const Address &issuedTo() const throw() { return _issuedTo; }
|
||||||
inline unsigned int multicastPrefixBits() const throw() { return _multicastPrefixBits; }
|
inline unsigned int multicastLimit() const throw() { return _multicastLimit; }
|
||||||
inline unsigned int multicastDepth() const throw() { return _multicastDepth; }
|
|
||||||
inline const std::map<MulticastGroup,MulticastRate> &multicastRates() const throw() { return _multicastRates; }
|
inline const std::map<MulticastGroup,MulticastRate> &multicastRates() const throw() { return _multicastRates; }
|
||||||
inline bool allowPassiveBridging() const throw() { return _allowPassiveBridging; }
|
inline bool allowPassiveBridging() const throw() { return _allowPassiveBridging; }
|
||||||
inline bool isPublic() const throw() { return (!_private); }
|
inline bool isPublic() const throw() { return (!_private); }
|
||||||
|
@ -155,8 +153,7 @@ private:
|
||||||
uint64_t _nwid;
|
uint64_t _nwid;
|
||||||
uint64_t _timestamp;
|
uint64_t _timestamp;
|
||||||
Address _issuedTo;
|
Address _issuedTo;
|
||||||
unsigned int _multicastPrefixBits;
|
unsigned int _multicastLimit;
|
||||||
unsigned int _multicastDepth;
|
|
||||||
bool _allowPassiveBridging;
|
bool _allowPassiveBridging;
|
||||||
bool _private;
|
bool _private;
|
||||||
bool _enableBroadcast;
|
bool _enableBroadcast;
|
||||||
|
|
|
@ -10,6 +10,7 @@ OBJS=\
|
||||||
node/Dictionary.o \
|
node/Dictionary.o \
|
||||||
node/HttpClient.o \
|
node/HttpClient.o \
|
||||||
node/Identity.o \
|
node/Identity.o \
|
||||||
|
node/IncomingPacket.o \
|
||||||
node/InetAddress.o \
|
node/InetAddress.o \
|
||||||
node/Logger.o \
|
node/Logger.o \
|
||||||
node/MulticastTopology.o \
|
node/MulticastTopology.o \
|
||||||
|
@ -18,7 +19,6 @@ OBJS=\
|
||||||
node/Node.o \
|
node/Node.o \
|
||||||
node/NodeConfig.o \
|
node/NodeConfig.o \
|
||||||
node/Packet.o \
|
node/Packet.o \
|
||||||
node/PacketDecoder.o \
|
|
||||||
node/Peer.o \
|
node/Peer.o \
|
||||||
node/Poly1305.o \
|
node/Poly1305.o \
|
||||||
node/RoutingTable.o \
|
node/RoutingTable.o \
|
||||||
|
|
Loading…
Add table
Reference in a new issue