Relicense: GPLv3 -> ZeroTier BSL 1.1

This commit is contained in:
Adam Ierymenko 2019-08-23 09:23:39 -07:00
parent 509da3ac34
commit 52a166a71f
No known key found for this signature in database
GPG key ID: 1657198823E52A61
129 changed files with 1094 additions and 3540 deletions

View file

@ -1,28 +1,15 @@
/*
* ZeroTier One - Network Virtualization Everywhere
* Copyright (C) 2011-2019 ZeroTier, Inc. https://www.zerotier.com/
* Copyright (c)2019 ZeroTier, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* Use of this software is governed by the Business Source License included
* in the LICENSE.TXT file in the project's root directory.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* Change Date: 2023-01-01
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* --
*
* You can be released from the requirements of the license by purchasing
* a commercial license. Buying such a license is mandatory as soon as you
* develop commercial closed-source software that incorporates or links
* directly against ZeroTier software without disclosing the source code
* of your own application.
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2.0 of the Apache License.
*/
/****/
#include "PostgreSQL.hpp"
@ -141,7 +128,7 @@ PostgreSQL::~PostgreSQL()
{
_run = 0;
std::this_thread::sleep_for(std::chrono::milliseconds(100));
_heartbeatThread.join();
_membersDbWatcher.join();
_networksDbWatcher.join();
@ -222,7 +209,7 @@ void PostgreSQL::eraseNetwork(const uint64_t networkId)
_commitQueue.post(tmp);
}
void PostgreSQL::eraseMember(const uint64_t networkId, const uint64_t memberId)
void PostgreSQL::eraseMember(const uint64_t networkId, const uint64_t memberId)
{
char tmp2[24];
std::pair<nlohmann::json,bool> tmp;
@ -267,7 +254,7 @@ void PostgreSQL::initializeNetworks(PGconn *conn)
NULL,
NULL,
0);
if (PQresultStatus(res) != PGRES_TUPLES_OK) {
fprintf(stderr, "Networks Initialization Failed: %s", PQerrorMessage(conn));
PQclear(res);
@ -339,7 +326,7 @@ void PostgreSQL::initializeNetworks(PGconn *conn)
NULL,
NULL,
0);
if (PQresultStatus(r2) != PGRES_TUPLES_OK) {
fprintf(stderr, "ERROR: Error retreiving IP pools for network: %s\n", PQresultErrorMessage(r2));
PQclear(r2);
@ -391,7 +378,7 @@ void PostgreSQL::initializeNetworks(PGconn *conn)
}
PQclear(r2);
_networkChanged(empty, config, false);
}
@ -616,7 +603,7 @@ void PostgreSQL::heartbeat()
};
PGresult *res = PQexecParams(conn,
"INSERT INTO ztc_controller (id, cluster_host, last_alive, public_identity, v_major, v_minor, v_rev, v_build, host_port, use_rabbitmq) "
"INSERT INTO ztc_controller (id, cluster_host, last_alive, public_identity, v_major, v_minor, v_rev, v_build, host_port, use_rabbitmq) "
"VALUES ($1, $2, TO_TIMESTAMP($3::double precision/1000), $4, $5, $6, $7, $8, $9, $10) "
"ON CONFLICT (id) DO UPDATE SET cluster_host = EXCLUDED.cluster_host, last_alive = EXCLUDED.last_alive, "
"public_identity = EXCLUDED.public_identity, v_major = EXCLUDED.v_major, v_minor = EXCLUDED.v_minor, "
@ -768,7 +755,7 @@ void PostgreSQL::networksDbWatcher()
PQfinish(conn);
conn = NULL;
}
if (_run == 1) {
fprintf(stderr, "ERROR: %s networksDbWatcher should still be running! Exiting Controller.\n", _myAddressStr.c_str());
exit(8);
@ -934,7 +921,7 @@ void PostgreSQL::commitThread()
NULL,
NULL,
0);
if (PQresultStatus(res) != PGRES_COMMAND_OK) {
fprintf(stderr, "ERROR: Error updating member: %s\n", PQresultErrorMessage(res));
fprintf(stderr, "%s", OSUtils::jsonDump(*config, 2).c_str());
@ -1004,7 +991,7 @@ void PostgreSQL::commitThread()
NULL,
NULL,
0);
if (PQresultStatus(res) != PGRES_COMMAND_OK) {
fprintf(stderr, "ERROR: Error setting IP addresses for member: %s\n", PQresultErrorMessage(res));
PQclear(res);
@ -1029,7 +1016,7 @@ void PostgreSQL::commitThread()
nlohmann::json memNew(*config);
get(nwidInt, nwOrig, memberidInt, memOrig);
_memberChanged(memOrig, memNew, qitem.second);
} else {
fprintf(stderr, "Can't notify of change. Error parsing nwid or memberid: %llu-%llu\n", (unsigned long long)nwidInt, (unsigned long long)memberidInt);
@ -1111,7 +1098,7 @@ void PostgreSQL::commitThread()
NULL,
NULL,
0);
if (PQresultStatus(res) != PGRES_COMMAND_OK) {
fprintf(stderr, "ERROR: Error updating network record: %s\n", PQresultErrorMessage(res));
PQclear(res);
@ -1136,7 +1123,7 @@ void PostgreSQL::commitThread()
const char *params[1] = {
id.c_str()
};
res = PQexecParams(conn,
res = PQexecParams(conn,
"DELETE FROM ztc_network_assignment_pool WHERE network_id = $1",
1,
NULL,
@ -1190,7 +1177,7 @@ void PostgreSQL::commitThread()
continue;
}
res = PQexecParams(conn,
res = PQexecParams(conn,
"DELETE FROM ztc_network_route WHERE network_id = $1",
1,
NULL,
@ -1295,7 +1282,7 @@ void PostgreSQL::commitThread()
NULL,
NULL,
0);
if (PQresultStatus(res) != PGRES_COMMAND_OK) {
fprintf(stderr, "ERROR: Error deleting network: %s\n", PQresultErrorMessage(res));
}
@ -1395,16 +1382,16 @@ void PostgreSQL::onlineNotificationThread()
if (found == _networks.end()) {
continue; // skip members trying to join non-existant networks
}
std::string networkId(nwidTmp);
std::string memberId(memTmp);
std::vector<std::string> &members = updateMap[networkId];
members.push_back(memberId);
lastOnlineCumulative[i->first] = i->second.first;
const char *qvals[2] = {
networkId.c_str(),
memberId.c_str()
@ -1432,7 +1419,7 @@ void PostgreSQL::onlineNotificationThread()
int64_t ts = i->second.first;
std::string ipAddr = i->second.second.toIpString(ipTmp);
std::string timestamp = std::to_string(ts);
if (firstRun) {
firstRun = false;
} else {
@ -1481,7 +1468,7 @@ PGconn *PostgreSQL::getPgConn(OverrideMode m)
if (connStr != NULL) {
fprintf(stderr, "PGBouncer Override\n");
std::string conn(connStr);
conn += " application_name=controller-";
conn += " application_name=controller-";
conn += _myAddressStr.c_str();
return PQconnectdb(conn.c_str());
}