mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-01-18 02:40:13 +00:00
WIP: Pass listen port down to Postgres
This commit is contained in:
parent
b59c4a2106
commit
d98bdb5643
@ -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()));
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -805,7 +805,7 @@ public:
|
||||
OSUtils::rmDashRf((_homePath + ZT_PATH_SEPARATOR_S "iddb.d").c_str());
|
||||
|
||||
// Network controller is now enabled by default for desktop and server
|
||||
_controller = new EmbeddedNetworkController(_node,_controllerDbPath.c_str());
|
||||
_controller = new EmbeddedNetworkController(_node,_controllerDbPath.c_str(),_ports[0]);
|
||||
_node->setNetconfMaster((void *)_controller);
|
||||
|
||||
// Join existing networks in networks.d
|
||||
|
Loading…
Reference in New Issue
Block a user