Release 4.8.0

This commit is contained in:
tsightler
2021-09-04 13:18:39 -04:00
parent 35ffb8f104
commit fe00f79288
6 changed files with 62 additions and 52 deletions

View File

@@ -28,6 +28,21 @@ class Utils
getISOTime(epoch) {
return new Date(epoch).toISOString().slice(0,-5)+"Z"
}
async getHostFqdn() {
const dns = require('dns')
const os = require('os')
const { promisify } = require('util')
const pLookup = promisify(dns.lookup)
const pLookupService = promisify(dns.lookupService)
try {
return (await pLookupService((await pLookup(os.hostname())).address, 0)).hostname
} catch {
console.log('Failed to resolve FQDN, using os.hostname() instead')
return os.hostname()
}
}
}
module.exports = new Utils()