diff options
Diffstat (limited to 'controller')
-rw-r--r-- | controller/EmbeddedNetworkController.cpp | 5 | ||||
-rw-r--r-- | controller/EmbeddedNetworkController.hpp | 3 | ||||
-rw-r--r-- | controller/PostgreSQL.cpp | 3 | ||||
-rw-r--r-- | controller/PostgreSQL.hpp | 4 |
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; }; } |