diff options
| author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2017-02-23 11:47:36 -0800 |
|---|---|---|
| committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2017-02-23 11:47:36 -0800 |
| commit | 10185e92faa77a4b032a27a7c01b4186727b91b9 (patch) | |
| tree | 5ce223c4cbeda31551d80ee3f42445924902f2ad /node/NetworkConfig.cpp | |
| parent | 33b94e8478e99d1e185041fa522b01de25fe53d4 (diff) | |
| download | infinitytier-10185e92faa77a4b032a27a7c01b4186727b91b9.tar.gz infinitytier-10185e92faa77a4b032a27a7c01b4186727b91b9.zip | |
Certificate of ownership -- used to secure against IP address spoofing, especially for IPv4 and regular IPv6.
Diffstat (limited to 'node/NetworkConfig.cpp')
| -rw-r--r-- | node/NetworkConfig.cpp | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/node/NetworkConfig.cpp b/node/NetworkConfig.cpp index 2f356b15..fe7393e8 100644 --- a/node/NetworkConfig.cpp +++ b/node/NetworkConfig.cpp @@ -21,7 +21,6 @@ #include <algorithm> #include "NetworkConfig.hpp" -#include "Utils.hpp" namespace ZeroTier { @@ -138,6 +137,13 @@ bool NetworkConfig::toDictionary(Dictionary<ZT_NETWORKCONFIG_DICT_CAPACITY> &d,b } tmp->clear(); + for(unsigned int i=0;i<this->certificateOfOwnershipCount;++i) + this->certificatesOfOwnership[i].serialize(*tmp); + if (tmp->size()) { + if (!d.add(ZT_NETWORKCONFIG_DICT_KEY_CERTIFICATES_OF_OWNERSHIP,*tmp)) return false; + } + + tmp->clear(); for(unsigned int i=0;i<this->specialistCount;++i) tmp->append((uint64_t)this->specialists[i]); if (tmp->size()) { @@ -297,10 +303,23 @@ bool NetworkConfig::fromDictionary(const Dictionary<ZT_NETWORKCONFIG_DICT_CAPACI std::sort(&(this->tags[0]),&(this->tags[this->tagCount])); } + if (d.get(ZT_NETWORKCONFIG_DICT_KEY_CERTIFICATES_OF_OWNERSHIP,*tmp)) { + unsigned int p = 0; + while (p < tmp->size()) { + if (certificateOfOwnershipCount < ZT_MAX_CERTIFICATES_OF_OWNERSHIP) + p += certificatesOfOwnership[certificateOfOwnershipCount++].deserialize(*tmp,p); + else { + CertificateOfOwnership foo; + p += foo.deserialize(*tmp,p); + } + } + } + if (d.get(ZT_NETWORKCONFIG_DICT_KEY_SPECIALISTS,*tmp)) { unsigned int p = 0; - while (((p + 8) <= tmp->size())&&(specialistCount < ZT_MAX_NETWORK_SPECIALISTS)) { - this->specialists[this->specialistCount++] = tmp->at<uint64_t>(p); + while ((p + 8) <= tmp->size()) { + if (specialistCount < ZT_MAX_NETWORK_SPECIALISTS) + this->specialists[this->specialistCount++] = tmp->at<uint64_t>(p); p += 8; } } |
