mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-05 03:53:44 +02:00
Merge branch 'dev' of github.com:zerotier/ZeroTierOne into dev
This commit is contained in:
commit
5c7e51feaf
4 changed files with 24 additions and 34 deletions
|
@ -1477,6 +1477,8 @@ void EmbeddedNetworkController::_request(
|
||||||
json &memberTags = member["tags"];
|
json &memberTags = member["tags"];
|
||||||
json &dns = network["dns"];
|
json &dns = network["dns"];
|
||||||
|
|
||||||
|
fprintf(stderr, "IP Assignment Pools for Network %s: %s\n", nwids, OSUtils::jsonDump(ipAssignmentPools, 2).c_str());
|
||||||
|
|
||||||
if (metaData.getUI(ZT_NETWORKCONFIG_REQUEST_METADATA_KEY_RULES_ENGINE_REV,0) <= 0) {
|
if (metaData.getUI(ZT_NETWORKCONFIG_REQUEST_METADATA_KEY_RULES_ENGINE_REV,0) <= 0) {
|
||||||
// Old versions with no rules engine support get an allow everything rule.
|
// Old versions with no rules engine support get an allow everything rule.
|
||||||
// Since rules are enforced bidirectionally, newer versions *will* still
|
// Since rules are enforced bidirectionally, newer versions *will* still
|
||||||
|
|
|
@ -502,7 +502,7 @@ void PostgreSQL::initializeNetworks()
|
||||||
config["routes"] = json::array();
|
config["routes"] = json::array();
|
||||||
|
|
||||||
|
|
||||||
pqxx::result r2 = w.exec_params("SELECT host(ip_range_start), host(ip_range_end) FROM ztc_network_assignment_pool WHERE network_id = $1", _myAddressStr);
|
pqxx::result r2 = w.exec_params("SELECT host(ip_range_start), host(ip_range_end) FROM ztc_network_assignment_pool WHERE network_id = $1", nwid);
|
||||||
|
|
||||||
for (auto row2 = r2.begin(); row2 != r2.end(); row2++) {
|
for (auto row2 = r2.begin(); row2 != r2.end(); row2++) {
|
||||||
json ip;
|
json ip;
|
||||||
|
@ -512,24 +512,27 @@ void PostgreSQL::initializeNetworks()
|
||||||
config["ipAssignmentPools"].push_back(ip);
|
config["ipAssignmentPools"].push_back(ip);
|
||||||
}
|
}
|
||||||
|
|
||||||
r2 = w.exec_params("SELECT host(address), bits, host(via) FROM ztc_network_route WHERE network_id = $1", _myAddressStr);
|
|
||||||
|
|
||||||
|
r2 = w.exec_params("SELECT host(address), bits, host(via) FROM ztc_network_route WHERE network_id = $1", nwid);
|
||||||
|
|
||||||
for (auto row2 = r2.begin(); row2 != r2.end(); row2++) {
|
for (auto row2 = r2.begin(); row2 != r2.end(); row2++) {
|
||||||
std::string addr = row2[0].as<std::string>();
|
std::string addr = row2[0].as<std::string>();
|
||||||
std::string bits = row2[1].as<std::string>();
|
std::string bits = row2[1].as<std::string>();
|
||||||
std::string via = row2[2].as<std::string>();
|
|
||||||
json route;
|
json route;
|
||||||
route["target"] = addr + "/" + bits;
|
route["target"] = addr + "/" + bits;
|
||||||
|
|
||||||
if (via == "NULL") {
|
if (row[2].is_null()) {
|
||||||
route["via"] = nullptr;
|
route["via"] = nullptr;
|
||||||
} else {
|
} else {
|
||||||
route["via"] = via;
|
route["via"] = row[2].as<std::string>();
|
||||||
}
|
}
|
||||||
|
|
||||||
config["routes"].push_back(route);
|
config["routes"].push_back(route);
|
||||||
}
|
}
|
||||||
|
|
||||||
r2 = w.exec_params("SELECT domain, servers FROM ztc_network_dns WHERE network_id = $1", _myAddressStr);
|
r2 = w.exec_params("SELECT domain, servers FROM ztc_network_dns WHERE network_id = $1", nwid);
|
||||||
|
|
||||||
if (r2.size() > 1) {
|
if (r2.size() > 1) {
|
||||||
fprintf(stderr, "ERROR: invalid number of DNS configurations for network %s. Must be 0 or 1\n", nwid.c_str());
|
fprintf(stderr, "ERROR: invalid number of DNS configurations for network %s. Must be 0 or 1\n", nwid.c_str());
|
||||||
|
@ -1231,7 +1234,7 @@ void PostgreSQL::commitThread()
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (std::exception &e) {
|
} catch (std::exception &e) {
|
||||||
fprintf(stderr, "ERROR: Error updating member: %s\n", e.what());
|
fprintf(stderr, "ERROR: Error updating network: %s\n", e.what());
|
||||||
}
|
}
|
||||||
} else if (objtype == "_delete_network") {
|
} else if (objtype == "_delete_network") {
|
||||||
fprintf(stderr, "commitThread: delete network\n");
|
fprintf(stderr, "commitThread: delete network\n");
|
||||||
|
|
|
@ -419,35 +419,15 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rate limit gate for inbound ECHO requests. This rate limiter works
|
* Rate limit gate for inbound ECHO requests
|
||||||
* by draining a certain number of requests per unit time. Each peer may
|
|
||||||
* theoretically receive up to ZT_ECHO_CUTOFF_LIMIT requests per second.
|
|
||||||
*/
|
*/
|
||||||
inline bool rateGateEchoRequest(const int64_t now)
|
inline bool rateGateEchoRequest(const int64_t now)
|
||||||
{
|
{
|
||||||
/*
|
if ((now - _lastEchoRequestReceived) >= ZT_PEER_GENERAL_RATE_LIMIT) {
|
||||||
// TODO: Rethink this
|
_lastEchoRequestReceived = now;
|
||||||
if (_canUseMultipath) {
|
return true;
|
||||||
_echoRequestCutoffCount++;
|
|
||||||
int numToDrain = (now - _lastEchoCheck) / ZT_ECHO_DRAINAGE_DIVISOR;
|
|
||||||
_lastEchoCheck = now;
|
|
||||||
fprintf(stderr, "ZT_ECHO_CUTOFF_LIMIT=%d, (now - _lastEchoCheck)=%d, numToDrain=%d, ZT_ECHO_DRAINAGE_DIVISOR=%d\n", ZT_ECHO_CUTOFF_LIMIT, (now - _lastEchoCheck), numToDrain, ZT_ECHO_DRAINAGE_DIVISOR);
|
|
||||||
if (_echoRequestCutoffCount > numToDrain) {
|
|
||||||
_echoRequestCutoffCount-=numToDrain;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
_echoRequestCutoffCount = 0;
|
|
||||||
}
|
|
||||||
return (_echoRequestCutoffCount < ZT_ECHO_CUTOFF_LIMIT);
|
|
||||||
} else {
|
|
||||||
if ((now - _lastEchoRequestReceived) >= (ZT_PEER_GENERAL_RATE_LIMIT)) {
|
|
||||||
_lastEchoRequestReceived = now;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
*/
|
return false;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -377,8 +377,13 @@ class Binder {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (std::vector<InetAddress>::const_iterator i(explicitBind.begin()); i != explicitBind.end(); ++i)
|
for (std::vector<InetAddress>::const_iterator i(explicitBind.begin()); i != explicitBind.end(); ++i) {
|
||||||
localIfAddrs.insert(std::pair<InetAddress, std::string>(*i, std::string()));
|
InetAddress ip = InetAddress(*i);
|
||||||
|
for (int x = 0; x < (int)portCount; ++x) {
|
||||||
|
ip.setPort(ports[x]);
|
||||||
|
localIfAddrs.insert(std::pair<InetAddress, std::string>(ip, std::string()));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Default to binding to wildcard if we can't enumerate addresses
|
// Default to binding to wildcard if we can't enumerate addresses
|
||||||
|
|
Loading…
Add table
Reference in a new issue