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 5c7a3a90..96dde42f 100644 --- a/controller/EmbeddedNetworkController.cpp +++ b/controller/EmbeddedNetworkController.cpp @@ -464,8 +464,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) @@ -488,7 +489,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 05bc1535..718c97ff 100644 --- a/controller/EmbeddedNetworkController.hpp +++ b/controller/EmbeddedNetworkController.hpp @@ -67,7 +67,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); @@ -149,6 +149,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 d6b43787..ede3e88f 100644 --- a/controller/PostgreSQL.cpp +++ b/controller/PostgreSQL.cpp @@ -72,12 +72,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 f5548671..7932317b 100644 --- a/controller/PostgreSQL.hpp +++ b/controller/PostgreSQL.hpp @@ -49,7 +49,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(); @@ -98,6 +98,8 @@ private: mutable std::mutex _readyLock; std::atomic<int> _ready, _connected, _run; mutable volatile bool _waitNoticePrinted; + + int _listenPort; }; } |
