mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2024-12-19 04:57:53 +00:00
use network ID, not controller ID for looking up network data
This commit is contained in:
parent
10215af96d
commit
73ddea8864
@ -502,7 +502,7 @@ void PostgreSQL::initializeNetworks()
|
||||
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++) {
|
||||
json ip;
|
||||
@ -512,24 +512,27 @@ void PostgreSQL::initializeNetworks()
|
||||
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++) {
|
||||
std::string addr = row2[0].as<std::string>();
|
||||
std::string bits = row2[1].as<std::string>();
|
||||
std::string via = row2[2].as<std::string>();
|
||||
|
||||
json route;
|
||||
route["target"] = addr + "/" + bits;
|
||||
|
||||
if (via == "NULL") {
|
||||
if (row[2].is_null()) {
|
||||
route["via"] = nullptr;
|
||||
} else {
|
||||
route["via"] = via;
|
||||
route["via"] = row[2].as<std::string>();
|
||||
}
|
||||
|
||||
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) {
|
||||
fprintf(stderr, "ERROR: invalid number of DNS configurations for network %s. Must be 0 or 1\n", nwid.c_str());
|
||||
|
Loading…
Reference in New Issue
Block a user