Flesh out Cobalt, LDAP groups, &c.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
const Unit = require('libflitter/Unit')
|
||||
const LDAP = require('ldapjs')
|
||||
const Validator = require('email-validator')
|
||||
const net = require('net')
|
||||
|
||||
// TODO support logging ALL ldap requests when in DEBUG, not just routed ones
|
||||
// TODO need to support LDAP server auto-discovery/detection features
|
||||
@@ -89,11 +90,27 @@ class LDAPServerUnit extends Unit {
|
||||
}
|
||||
|
||||
this.output.info(`Will listen on ${this.config.interface}:${this.config.port}`)
|
||||
await new Promise((res, rej) => {
|
||||
this.server.listen(this.config.port, this.config.interface, () => {
|
||||
this.output.success(`LDAP server listening on port ${this.config.port}...`)
|
||||
if ( await this.port_free() ) {
|
||||
await new Promise((res, rej) => {
|
||||
this.server.listen(this.config.port, this.config.interface, (err) => {
|
||||
this.output.success(`LDAP server listening on port ${this.config.port}...`)
|
||||
res()
|
||||
})
|
||||
})
|
||||
} else {
|
||||
this.output.error(`LDAP server port ${this.config.port} is not available. The LDAP server was not started.`)
|
||||
}
|
||||
}
|
||||
|
||||
async port_free() {
|
||||
return new Promise((res, rej) => {
|
||||
const server = net.createServer()
|
||||
server.once('error', rej)
|
||||
server.once('listening', () => {
|
||||
server.close()
|
||||
res()
|
||||
})
|
||||
server.listen(this.config.port)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user