mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-08-02 15:02:50 +02:00
Controller support for "relays" field.
This commit is contained in:
parent
055be92ef0
commit
92838fa1b2
3 changed files with 28 additions and 14 deletions
|
@ -16,24 +16,20 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <type_traits>
|
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#endif
|
#endif
|
||||||
#include "../include/ZeroTierOne.h"
|
#include "../include/ZeroTierOne.h"
|
||||||
#include "../version.h"
|
|
||||||
#include "EmbeddedNetworkController.hpp"
|
#include "EmbeddedNetworkController.hpp"
|
||||||
#include "FileDB.hpp"
|
#include "FileDB.hpp"
|
||||||
#include "LFDB.hpp"
|
#include "LFDB.hpp"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
#include <iomanip>
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <stdexcept>
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
@ -44,7 +40,6 @@
|
||||||
|
|
||||||
#include "../node/CertificateOfMembership.hpp"
|
#include "../node/CertificateOfMembership.hpp"
|
||||||
#include "../node/Dictionary.hpp"
|
#include "../node/Dictionary.hpp"
|
||||||
#include "../node/MAC.hpp"
|
|
||||||
#include "../node/NetworkConfig.hpp"
|
#include "../node/NetworkConfig.hpp"
|
||||||
#include "../node/Node.hpp"
|
#include "../node/Node.hpp"
|
||||||
|
|
||||||
|
@ -754,6 +749,24 @@ std::string EmbeddedNetworkController::networkUpdateFromPostData(uint64_t networ
|
||||||
network["v6AssignMode"] = nv6m;
|
network["v6AssignMode"] = nv6m;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (b.count("relays")) {
|
||||||
|
json nrelays = json::array();
|
||||||
|
char rtmp[64];
|
||||||
|
json& relays = b["relays"];
|
||||||
|
if (relays.is_array()) {
|
||||||
|
for (unsigned long i = 0; i < relays.size(); ++i) {
|
||||||
|
json& relay = relays[i];
|
||||||
|
if (relay.is_string()) {
|
||||||
|
nrelays.push_back(Address(Utils::hexStrToU64(OSUtils::jsonString(relay, "0").c_str()) & 0xffffffffffULL).toString(rtmp));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (nrelays.size() > 0)
|
||||||
|
network["relays"] = nrelays;
|
||||||
|
else
|
||||||
|
network.erase("relays");
|
||||||
|
}
|
||||||
|
|
||||||
if (b.count("routes")) {
|
if (b.count("routes")) {
|
||||||
json& rts = b["routes"];
|
json& rts = b["routes"];
|
||||||
if (rts.is_array()) {
|
if (rts.is_array()) {
|
||||||
|
@ -1815,6 +1828,7 @@ void EmbeddedNetworkController::_request(uint64_t nwid, const InetAddress& fromA
|
||||||
json& v6AssignMode = network["v6AssignMode"];
|
json& v6AssignMode = network["v6AssignMode"];
|
||||||
json& ipAssignmentPools = network["ipAssignmentPools"];
|
json& ipAssignmentPools = network["ipAssignmentPools"];
|
||||||
json& routes = network["routes"];
|
json& routes = network["routes"];
|
||||||
|
json& relays = network["relays"];
|
||||||
json& rules = network["rules"];
|
json& rules = network["rules"];
|
||||||
json& capabilities = network["capabilities"];
|
json& capabilities = network["capabilities"];
|
||||||
json& tags = network["tags"];
|
json& tags = network["tags"];
|
||||||
|
@ -1946,6 +1960,15 @@ void EmbeddedNetworkController::_request(uint64_t nwid, const InetAddress& fromA
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (relays.is_array()) {
|
||||||
|
for (unsigned long i = 0; i < relays.size(); ++i) {
|
||||||
|
Address relay(Address(Utils::hexStrToU64(OSUtils::jsonString(relays[i], "0").c_str()) & 0xffffffffffULL));
|
||||||
|
if (! relay.isReserved()) {
|
||||||
|
nc->addSpecialist(relay, ZT_NETWORKCONFIG_SPECIALIST_TYPE_NETWORK_RELAY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const bool noAutoAssignIps = OSUtils::jsonBool(member["noAutoAssignIps"], false);
|
const bool noAutoAssignIps = OSUtils::jsonBool(member["noAutoAssignIps"], false);
|
||||||
|
|
||||||
if ((v6AssignMode.is_object()) && (! noAutoAssignIps)) {
|
if ((v6AssignMode.is_object()) && (! noAutoAssignIps)) {
|
||||||
|
|
|
@ -14,21 +14,14 @@
|
||||||
#ifndef ZT_SQLITENETWORKCONTROLLER_HPP
|
#ifndef ZT_SQLITENETWORKCONTROLLER_HPP
|
||||||
#define ZT_SQLITENETWORKCONTROLLER_HPP
|
#define ZT_SQLITENETWORKCONTROLLER_HPP
|
||||||
|
|
||||||
#include "../node/Address.hpp"
|
|
||||||
#include "../node/Constants.hpp"
|
#include "../node/Constants.hpp"
|
||||||
#include "../node/InetAddress.hpp"
|
#include "../node/InetAddress.hpp"
|
||||||
#include "../node/NetworkController.hpp"
|
#include "../node/NetworkController.hpp"
|
||||||
#include "../node/Utils.hpp"
|
|
||||||
#include "../osdep/BlockingQueue.hpp"
|
#include "../osdep/BlockingQueue.hpp"
|
||||||
#include "../osdep/OSUtils.hpp"
|
|
||||||
#include "../osdep/Thread.hpp"
|
|
||||||
#include "DB.hpp"
|
#include "DB.hpp"
|
||||||
#include "DBMirrorSet.hpp"
|
#include "DBMirrorSet.hpp"
|
||||||
|
|
||||||
#include <atomic>
|
|
||||||
#include <cpp-httplib/httplib.h>
|
#include <cpp-httplib/httplib.h>
|
||||||
#include <list>
|
|
||||||
#include <map>
|
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
|
@ -21,8 +21,6 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
namespace ZeroTier {
|
namespace ZeroTier {
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue