summaryrefslogtreecommitdiff
path: root/controller
diff options
context:
space:
mode:
authorGrant Limberg <grant.limberg@zerotier.com>2019-01-21 11:18:20 -0800
committerGrant Limberg <grant.limberg@zerotier.com>2019-01-21 11:18:20 -0800
commitd98bdb5643b7de7097526a4767dbc88235e05fc9 (patch)
tree676532c23a956a9c1f76e7226a4e98374343d3ca /controller
parentb59c4a2106ad17d92c15c086c31d5764a0462c16 (diff)
downloadinfinitytier-d98bdb5643b7de7097526a4767dbc88235e05fc9.tar.gz
infinitytier-d98bdb5643b7de7097526a4767dbc88235e05fc9.zip
WIP: Pass listen port down to Postgres
Diffstat (limited to 'controller')
-rw-r--r--controller/EmbeddedNetworkController.cpp5
-rw-r--r--controller/EmbeddedNetworkController.hpp3
-rw-r--r--controller/PostgreSQL.cpp3
-rw-r--r--controller/PostgreSQL.hpp4
4 files changed, 10 insertions, 5 deletions
diff --git a/controller/EmbeddedNetworkController.cpp b/controller/EmbeddedNetworkController.cpp
index baed88e6..b20c1365 100644
--- a/controller/EmbeddedNetworkController.cpp
+++ b/controller/EmbeddedNetworkController.cpp
@@ -456,8 +456,9 @@ static bool _parseRule(json &r,ZT_VirtualNetworkRule &rule)
} // anonymous namespace
-EmbeddedNetworkController::EmbeddedNetworkController(Node *node,const char *dbPath) :
+EmbeddedNetworkController::EmbeddedNetworkController(Node *node,const char *dbPath, int listenPort) :
_startTime(OSUtils::now()),
+ _listenPort(listenPort),
_node(node),
_path(dbPath),
_sender((NetworkController::Sender *)0)
@@ -480,7 +481,7 @@ void EmbeddedNetworkController::init(const Identity &signingId,Sender *sender)
_signingIdAddressString = signingId.address().toString(tmp);
#ifdef ZT_CONTROLLER_USE_LIBPQ
if ((_path.length() > 9)&&(_path.substr(0,9) == "postgres:"))
- _db.reset(new PostgreSQL(this,_signingId,_path.substr(9).c_str()));
+ _db.reset(new PostgreSQL(this,_signingId,_path.substr(9).c_str(), _listenPort));
else // else use FileDB after endif
#endif
_db.reset(new FileDB(this,_signingId,_path.c_str()));
diff --git a/controller/EmbeddedNetworkController.hpp b/controller/EmbeddedNetworkController.hpp
index c3f121c5..14ee9d04 100644
--- a/controller/EmbeddedNetworkController.hpp
+++ b/controller/EmbeddedNetworkController.hpp
@@ -59,7 +59,7 @@ public:
* @param node Parent node
* @param dbPath Database path (file path or database credentials)
*/
- EmbeddedNetworkController(Node *node,const char *dbPath);
+ EmbeddedNetworkController(Node *node,const char *dbPath, int listenPort);
virtual ~EmbeddedNetworkController();
virtual void init(const Identity &signingId,Sender *sender);
@@ -141,6 +141,7 @@ private:
};
const int64_t _startTime;
+ int _listenPort;
Node *const _node;
std::string _path;
Identity _signingId;
diff --git a/controller/PostgreSQL.cpp b/controller/PostgreSQL.cpp
index db0537ec..6d284d42 100644
--- a/controller/PostgreSQL.cpp
+++ b/controller/PostgreSQL.cpp
@@ -64,12 +64,13 @@ std::string join(const std::vector<std::string> &elements, const char * const se
using namespace ZeroTier;
-PostgreSQL::PostgreSQL(EmbeddedNetworkController *const nc, const Identity &myId, const char *path)
+PostgreSQL::PostgreSQL(EmbeddedNetworkController *const nc, const Identity &myId, const char *path, int listenPort)
: DB(nc, myId, path)
, _ready(0)
, _connected(1)
, _run(1)
, _waitNoticePrinted(false)
+ , _listenPort(listenPort)
{
_connString = std::string(path) + " application_name=controller_" +_myAddressStr;
diff --git a/controller/PostgreSQL.hpp b/controller/PostgreSQL.hpp
index a20bfe99..6f1daa75 100644
--- a/controller/PostgreSQL.hpp
+++ b/controller/PostgreSQL.hpp
@@ -41,7 +41,7 @@ namespace ZeroTier
class PostgreSQL : public DB
{
public:
- PostgreSQL(EmbeddedNetworkController *const nc, const Identity &myId, const char *path);
+ PostgreSQL(EmbeddedNetworkController *const nc, const Identity &myId, const char *path, int listenPort);
virtual ~PostgreSQL();
virtual bool waitForReady();
@@ -90,6 +90,8 @@ private:
mutable std::mutex _readyLock;
std::atomic<int> _ready, _connected, _run;
mutable volatile bool _waitNoticePrinted;
+
+ int _listenPort;
};
}