Add route to set/get sysinfo
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
'use strict';
|
||||
|
||||
exports = module.exports = {
|
||||
getServerIp: getServerIp
|
||||
getServerIp: getServerIp,
|
||||
testConfig: testConfig
|
||||
};
|
||||
|
||||
var assert = require('assert'),
|
||||
@@ -20,3 +21,10 @@ function getServerIp(config, callback) {
|
||||
callback(null, result.text);
|
||||
});
|
||||
}
|
||||
|
||||
function testConfig(config, callback) {
|
||||
assert.strictEqual(typeof config, 'object');
|
||||
assert.strictEqual(typeof callback, 'function');
|
||||
|
||||
callback(null);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
'use strict';
|
||||
|
||||
exports = module.exports = {
|
||||
getServerIp: getServerIp
|
||||
getServerIp,
|
||||
testConfig
|
||||
};
|
||||
|
||||
var assert = require('assert');
|
||||
var assert = require('assert'),
|
||||
BoxError = require('../boxerror.js'),
|
||||
validator = require('validator');
|
||||
|
||||
function getServerIp(config, callback) {
|
||||
assert.strictEqual(typeof config, 'object');
|
||||
@@ -13,3 +16,12 @@ function getServerIp(config, callback) {
|
||||
callback(null, config.ip);
|
||||
}
|
||||
|
||||
function testConfig(config, callback) {
|
||||
assert.strictEqual(typeof config, 'object');
|
||||
assert.strictEqual(typeof callback, 'function');
|
||||
|
||||
if (typeof config.ip !== 'string') return callback(new BoxError(BoxError.BAD_FIELD, 'ip must be a string'));
|
||||
if (!validator.isIP(config.ip, 4)) return callback(new BoxError(BoxError.BAD_FIELD, 'ip is not a valid ipv4'));
|
||||
|
||||
callback(null);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
'use strict';
|
||||
|
||||
exports = module.exports = {
|
||||
getServerIp: getServerIp
|
||||
getServerIp,
|
||||
testConfig
|
||||
};
|
||||
|
||||
var assert = require('assert'),
|
||||
@@ -34,3 +35,10 @@ function getServerIp(config, callback) {
|
||||
callback(null, result);
|
||||
});
|
||||
}
|
||||
|
||||
function testConfig(config, callback) {
|
||||
assert.strictEqual(typeof config, 'object');
|
||||
assert.strictEqual(typeof callback, 'function');
|
||||
|
||||
callback(null);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
// -------------------------------------------
|
||||
|
||||
exports = module.exports = {
|
||||
getServerIp: getServerIp
|
||||
getServerIp,
|
||||
testConfig
|
||||
};
|
||||
|
||||
var assert = require('assert');
|
||||
@@ -19,3 +20,9 @@ function getServerIp(config, callback) {
|
||||
callback(new Error('not implemented'));
|
||||
}
|
||||
|
||||
function testConfig(config, callback) {
|
||||
assert.strictEqual(typeof config, 'object');
|
||||
assert.strictEqual(typeof callback, 'function');
|
||||
|
||||
callback(null);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
'use strict';
|
||||
|
||||
exports = module.exports = {
|
||||
getServerIp: getServerIp
|
||||
getServerIp,
|
||||
testConfig
|
||||
};
|
||||
|
||||
var assert = require('assert'),
|
||||
@@ -23,3 +24,12 @@ function getServerIp(config, callback) {
|
||||
|
||||
return callback(null, addresses[0]);
|
||||
}
|
||||
|
||||
function testConfig(config, callback) {
|
||||
assert.strictEqual(typeof config, 'object');
|
||||
assert.strictEqual(typeof callback, 'function');
|
||||
|
||||
if (typeof config.ifname !== 'string') return callback(new BoxError(BoxError.BAD_FIELD, 'ifname is not a string'));
|
||||
|
||||
callback(null);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
'use strict';
|
||||
|
||||
exports = module.exports = {
|
||||
getServerIp: getServerIp
|
||||
getServerIp,
|
||||
testConfig
|
||||
};
|
||||
|
||||
var assert = require('assert'),
|
||||
@@ -24,3 +25,9 @@ function getServerIp(config, callback) {
|
||||
});
|
||||
}
|
||||
|
||||
function testConfig(config, callback) {
|
||||
assert.strictEqual(typeof config, 'object');
|
||||
assert.strictEqual(typeof callback, 'function');
|
||||
|
||||
callback(null);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user