Fixup exposed ldap startup state

This commit is contained in:
Johannes Zellner
2021-12-10 17:48:36 +01:00
parent 1c7eeb6ac6
commit 438bd36267
2 changed files with 15 additions and 11 deletions

View File

@@ -15,7 +15,7 @@ const addonConfigs = require('./addonconfigs.js'),
BoxError = require('./boxerror.js'),
constants = require('./constants.js'),
debug = require('debug')('box:ldap'),
debugExposed = require('debug')('box:ldapExposed'),
debugExposed = require('debug')('box:exposedLdap'),
dns = require('./dns.js'),
domains = require('./domains.js'),
eventlog = require('./eventlog.js'),
@@ -698,7 +698,10 @@ async function start() {
}
async function stop() {
if (gServer) gServer.close();
if (!gServer) return;
gServer.close();
gServer = null;
}
// FIXME this needs to be restarted if settings changes or dashboard cert got renewed
@@ -725,7 +728,7 @@ async function startExposed() {
});
gExposedServer.on('error', function (error) {
debugExposed('start: server error ', error);
debugExposed('server startup error ', error);
});
gExposedServer.search('ou=users,dc=cloudron', authenticateApp, userSearch);
@@ -741,9 +744,15 @@ async function startExposed() {
return next();
});
debugExposed(`starting server on port ${constants.LDAPS_PORT}`);
await util.promisify(gExposedServer.listen.bind(gExposedServer))(constants.LDAPS_PORT, '0.0.0.0');
}
async function stopExposed() {
if (gExposedServer) gExposedServer.close();
if (!gExposedServer) return;
debugExposed('stopping server');
gExposedServer.close();
gExposedServer = null;
}