Fixes to getServerIPv6()
This commit is contained in:
@@ -19,7 +19,9 @@ async function getServerIPv4(config) {
|
||||
async function getServerIPv6(config) {
|
||||
assert.strictEqual(typeof config, 'object');
|
||||
|
||||
return config.ipv6;
|
||||
if ('ipv6' in config) return config.ipv6;
|
||||
|
||||
throw new BoxError(BoxError.NETWORK_ERROR, 'No IPv6 configured');
|
||||
}
|
||||
|
||||
async function testConfig(config) {
|
||||
|
||||
@@ -42,7 +42,7 @@ async function getServerIPv4(config) {
|
||||
async function getServerIPv6(config) {
|
||||
assert.strictEqual(typeof config, 'object');
|
||||
|
||||
if (process.env.BOX_ENV === 'test') return '127.0.0.1';
|
||||
if (process.env.BOX_ENV === 'test') return '::1';
|
||||
|
||||
return await promiseRetry({ times: 10, interval: 5000, debug }, async () => {
|
||||
debug('getServerIPv6: getting server IP');
|
||||
|
||||
@@ -34,7 +34,7 @@ async function getServerIPv6(config) {
|
||||
if (!iface) throw new BoxError(BoxError.NETWORK_ERROR, `No interface named ${config.ifname}`);
|
||||
|
||||
const addresses = iface.filter(i => i.family === 'IPv6').map(i => i.address);
|
||||
if (addresses.length === 0) throw new BoxError(BoxError.NETWORK_ERROR, `${config.ifname} does not have any IPv4 address`);
|
||||
if (addresses.length === 0) throw new BoxError(BoxError.NETWORK_ERROR, `${config.ifname} does not have any IPv6 address`);
|
||||
if (addresses.length > 1) debug(`${config.ifname} has multiple ipv6 - ${JSON.stringify(addresses)}. choosing the first one.`);
|
||||
|
||||
return addresses[0];
|
||||
|
||||
Reference in New Issue
Block a user