network: simply use ip instead of ipv4/ipv6
this makes it simpler for openapi docs
This commit is contained in:
@@ -14,13 +14,13 @@ const assert = require('assert'),
|
||||
async function getIPv4(config) {
|
||||
assert.strictEqual(typeof config, 'object');
|
||||
|
||||
return config.ipv4;
|
||||
return config.ip;
|
||||
}
|
||||
|
||||
async function getIPv6(config) {
|
||||
assert.strictEqual(typeof config, 'object');
|
||||
|
||||
if ('ipv6' in config) return config.ipv6;
|
||||
if ('ip' in config) return config.ip;
|
||||
|
||||
throw new BoxError(BoxError.NETWORK_ERROR, 'No IPv6 configured');
|
||||
}
|
||||
@@ -28,8 +28,8 @@ async function getIPv6(config) {
|
||||
async function testIPv4Config(config) {
|
||||
assert.strictEqual(typeof config, 'object');
|
||||
|
||||
if (typeof config.ipv4 !== 'string') return new BoxError(BoxError.BAD_FIELD, 'ipv4 must be a string');
|
||||
if (!net.isIPv4(config.ipv4)) return new BoxError(BoxError.BAD_FIELD, 'invalid IPv4');
|
||||
if (typeof config.ip !== 'string') return new BoxError(BoxError.BAD_FIELD, 'ipv4 must be a string');
|
||||
if (!net.isIPv4(config.ip)) return new BoxError(BoxError.BAD_FIELD, 'invalid IPv4');
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -37,8 +37,8 @@ async function testIPv4Config(config) {
|
||||
async function testIPv6Config(config) {
|
||||
assert.strictEqual(typeof config, 'object');
|
||||
|
||||
if (typeof config.ipv6 !== 'string') return new BoxError(BoxError.BAD_FIELD, 'ipv6 must be a string');
|
||||
if (!net.isIPv6(config.ipv6)) return new BoxError(BoxError.BAD_FIELD, 'invalid IPv6');
|
||||
if (typeof config.ip !== 'string') return new BoxError(BoxError.BAD_FIELD, 'ipv6 must be a string');
|
||||
if (!net.isIPv6(config.ip)) return new BoxError(BoxError.BAD_FIELD, 'invalid IPv6');
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user