diff options
author | Grant Limberg <grant.limberg@zerotier.com> | 2018-09-28 10:55:39 -0700 |
---|---|---|
committer | Grant Limberg <grant.limberg@zerotier.com> | 2018-09-28 10:55:39 -0700 |
commit | 417aa9547b4f3abb9009a3dbb66ecf93d3d686f7 (patch) | |
tree | 78e86f1a63027323ef4eaa4c67cd2a4c449b4919 /controller/PostgreSQL.cpp | |
parent | 0510f85a8fe6cba7e6258d534fa49d47f9f8e2a2 (diff) | |
download | infinitytier-417aa9547b4f3abb9009a3dbb66ecf93d3d686f7.tar.gz infinitytier-417aa9547b4f3abb9009a3dbb66ecf93d3d686f7.zip |
Working controller & docker container for GKE
Diffstat (limited to 'controller/PostgreSQL.cpp')
-rw-r--r-- | controller/PostgreSQL.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/controller/PostgreSQL.cpp b/controller/PostgreSQL.cpp index 4a33e4b6..412bca6b 100644 --- a/controller/PostgreSQL.cpp +++ b/controller/PostgreSQL.cpp @@ -23,6 +23,7 @@ #include "../version.h" #include <libpq-fe.h> +#include <sstream> using json = nlohmann::json; namespace { @@ -200,6 +201,10 @@ void PostgreSQL::initializeNetworks(PGconn *conn) json empty; json config; + const char *nwidparam[1] = { + PQgetvalue(res, i, 0) + }; + config["id"] = PQgetvalue(res, i, 0); config["nwid"] = PQgetvalue(res, i, 0); config["creationTime"] = std::stoull(PQgetvalue(res, i, 1)); @@ -225,7 +230,7 @@ void PostgreSQL::initializeNetworks(PGconn *conn) "SELECT host(ip_range_start), host(ip_range_end) FROM ztc_network_assignment_pool WHERE network_id = $1", 1, NULL, - params, + nwidparam, NULL, NULL, 0); @@ -252,7 +257,7 @@ void PostgreSQL::initializeNetworks(PGconn *conn) "SELECT host(address), bits, host(via) FROM ztc_network_route WHERE network_id = $1", 1, NULL, - params, + nwidparam, NULL, NULL, 0); @@ -284,6 +289,8 @@ void PostgreSQL::initializeNetworks(PGconn *conn) PQclear(r2); _networkChanged(empty, config, false); + + fprintf(stderr, "%s", OSUtils::jsonDump(config, 2).c_str()); } PQclear(res); @@ -1234,4 +1241,4 @@ void PostgreSQL::onlineNotificationThread() } PQfinish(conn); } -#endif //ZT_CONTROLLER_USE_LIBPQ
\ No newline at end of file +#endif //ZT_CONTROLLER_USE_LIBPQ |