sysinfo: async'ify
in the process, provision, dyndns, mail, dns also got further asyncified
This commit is contained in:
+6
-14
@@ -9,10 +9,7 @@ exports = module.exports = {
|
||||
|
||||
const assert = require('assert'),
|
||||
fs = require('fs'),
|
||||
settings = require('./settings.js'),
|
||||
util = require('util');
|
||||
|
||||
const getSysinfoConfig = util.callbackify(settings.getSysinfoConfig);
|
||||
settings = require('./settings.js');
|
||||
|
||||
function api(provider) {
|
||||
assert.strictEqual(typeof provider, 'string');
|
||||
@@ -24,14 +21,10 @@ function api(provider) {
|
||||
}
|
||||
}
|
||||
|
||||
function getServerIp(callback) {
|
||||
assert.strictEqual(typeof callback, 'function');
|
||||
async function getServerIp() {
|
||||
const config = await settings.getSysinfoConfig();
|
||||
|
||||
getSysinfoConfig(function (error, config) {
|
||||
if (error) return callback(error);
|
||||
|
||||
api(config.provider).getServerIp(config, callback);
|
||||
});
|
||||
return await api(config.provider).getServerIp(config);
|
||||
}
|
||||
|
||||
function hasIPv6() {
|
||||
@@ -40,9 +33,8 @@ function hasIPv6() {
|
||||
return fs.existsSync(IPV6_PROC_FILE) && fs.readFileSync(IPV6_PROC_FILE, 'utf8').trim().length !== 0;
|
||||
}
|
||||
|
||||
function testConfig(config, callback) {
|
||||
async function testConfig(config) {
|
||||
assert.strictEqual(typeof config, 'object');
|
||||
assert.strictEqual(typeof callback, 'function');
|
||||
|
||||
api(config.provider).testConfig(config, callback);
|
||||
return await api(config.provider).testConfig(config);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user