mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-07 13:03:45 +02:00
more cleanup
This commit is contained in:
parent
4da8036222
commit
6947a6b1d4
2 changed files with 14 additions and 12 deletions
|
@ -86,16 +86,15 @@ public:
|
||||||
inline uint64_t networkId() const { return _networkId; }
|
inline uint64_t networkId() const { return _networkId; }
|
||||||
inline int64_t timestamp() const { return _ts; }
|
inline int64_t timestamp() const { return _ts; }
|
||||||
inline uint32_t id() const { return _id; }
|
inline uint32_t id() const { return _id; }
|
||||||
inline unsigned int thingCount() const { return (unsigned int)_thingCount; }
|
inline const Address &issuedTo() const { return _issuedTo; }
|
||||||
inline const Address &signer() const { return _signedBy; }
|
inline const Address &signer() const { return _signedBy; }
|
||||||
inline const uint8_t *signature() const { return _signature; }
|
inline const uint8_t *signature() const { return _signature; }
|
||||||
inline unsigned int signatureLength() const { return _signatureLength; }
|
inline unsigned int signatureLength() const { return _signatureLength; }
|
||||||
|
|
||||||
|
inline unsigned int thingCount() const { return (unsigned int)_thingCount; }
|
||||||
inline Thing thingType(const unsigned int i) const { return (Thing)_thingTypes[i]; }
|
inline Thing thingType(const unsigned int i) const { return (Thing)_thingTypes[i]; }
|
||||||
inline const uint8_t *thingValue(const unsigned int i) const { return _thingValues[i]; }
|
inline const uint8_t *thingValue(const unsigned int i) const { return _thingValues[i]; }
|
||||||
|
|
||||||
inline const Address &issuedTo() const { return _issuedTo; }
|
|
||||||
|
|
||||||
inline bool owns(const InetAddress &ip) const
|
inline bool owns(const InetAddress &ip) const
|
||||||
{
|
{
|
||||||
if (ip.ss_family == AF_INET)
|
if (ip.ss_family == AF_INET)
|
||||||
|
|
|
@ -400,17 +400,20 @@ uint64_t Utils::random()
|
||||||
{
|
{
|
||||||
// https://en.wikipedia.org/wiki/Xorshift#xoshiro256**
|
// https://en.wikipedia.org/wiki/Xorshift#xoshiro256**
|
||||||
static Mutex l;
|
static Mutex l;
|
||||||
static uint64_t s[4] = { Utils::getSecureRandom64(),Utils::getSecureRandom64(),Utils::getSecureRandom64(),Utils::getSecureRandom64() };
|
static uint64_t s0 = Utils::getSecureRandom64();
|
||||||
|
static uint64_t s1 = Utils::getSecureRandom64();
|
||||||
|
static uint64_t s2 = Utils::getSecureRandom64();
|
||||||
|
static uint64_t s3 = Utils::getSecureRandom64();
|
||||||
|
|
||||||
l.lock();
|
l.lock();
|
||||||
const uint64_t result = ROL64(s[1] * 5,7) * 9;
|
const uint64_t result = ROL64(s1 * 5,7) * 9;
|
||||||
const uint64_t t = s[1] << 17;
|
const uint64_t t = s1 << 17;
|
||||||
s[2] ^= s[0];
|
s2 ^= s0;
|
||||||
s[3] ^= s[1];
|
s3 ^= s1;
|
||||||
s[1] ^= s[2];
|
s1 ^= s2;
|
||||||
s[0] ^= s[3];
|
s0 ^= s3;
|
||||||
s[2] ^= t;
|
s2 ^= t;
|
||||||
s[3] = ROL64(s[3],45);
|
s3 = ROL64(s3,45);
|
||||||
l.unlock();
|
l.unlock();
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
Loading…
Add table
Reference in a new issue