Move hasIPv6 into sysinfo
This commit is contained in:
@@ -29,7 +29,6 @@ exports = module.exports = {
|
||||
sysadminOrigin: sysadminOrigin, // localhost routes
|
||||
adminFqdn: adminFqdn,
|
||||
mailFqdn: mailFqdn,
|
||||
hasIPv6: hasIPv6,
|
||||
|
||||
isDemo: isDemo,
|
||||
|
||||
@@ -195,9 +194,3 @@ function isDemo() {
|
||||
function provider() {
|
||||
return get('provider');
|
||||
}
|
||||
|
||||
function hasIPv6() {
|
||||
const IPV6_PROC_FILE = '/proc/net/if_inet6';
|
||||
// on contabo, /proc/net/if_inet6 is an empty file. so just exists is not enough
|
||||
return fs.existsSync(IPV6_PROC_FILE) && fs.readFileSync(IPV6_PROC_FILE, 'utf8').trim().length !== 0;
|
||||
}
|
||||
|
||||
+4
-3
@@ -52,6 +52,7 @@ var acme2 = require('./cert/acme2.js'),
|
||||
rimraf = require('rimraf'),
|
||||
safe = require('safetydance'),
|
||||
shell = require('./shell.js'),
|
||||
sysinfo = require('./sysinfo.js'),
|
||||
users = require('./users.js'),
|
||||
util = require('util');
|
||||
|
||||
@@ -388,7 +389,7 @@ function writeAdminNginxConfig(bundle, configFileName, vhost, callback) {
|
||||
sourceDir: path.resolve(__dirname, '..'),
|
||||
adminOrigin: config.adminOrigin(),
|
||||
vhost: vhost, // if vhost is empty it will become the default_server
|
||||
hasIPv6: config.hasIPv6(),
|
||||
hasIPv6: sysinfo.hasIPv6(),
|
||||
endpoint: 'admin',
|
||||
certFilePath: bundle.certFilePath,
|
||||
keyFilePath: bundle.keyFilePath,
|
||||
@@ -451,7 +452,7 @@ function writeAppNginxConfig(app, bundle, callback) {
|
||||
sourceDir: sourceDir,
|
||||
adminOrigin: config.adminOrigin(),
|
||||
vhost: app.fqdn,
|
||||
hasIPv6: config.hasIPv6(),
|
||||
hasIPv6: sysinfo.hasIPv6(),
|
||||
port: app.httpPort,
|
||||
endpoint: endpoint,
|
||||
certFilePath: bundle.certFilePath,
|
||||
@@ -481,7 +482,7 @@ function writeAppRedirectNginxConfig(app, fqdn, bundle, callback) {
|
||||
sourceDir: path.resolve(__dirname, '..'),
|
||||
vhost: fqdn,
|
||||
redirectTo: app.fqdn,
|
||||
hasIPv6: config.hasIPv6(),
|
||||
hasIPv6: sysinfo.hasIPv6(),
|
||||
endpoint: 'redirect',
|
||||
certFilePath: bundle.certFilePath,
|
||||
keyFilePath: bundle.keyFilePath,
|
||||
|
||||
+10
-1
@@ -3,12 +3,15 @@
|
||||
exports = module.exports = {
|
||||
SysInfoError: SysInfoError,
|
||||
|
||||
getPublicIp: getPublicIp
|
||||
getPublicIp: getPublicIp,
|
||||
|
||||
hasIPv6: hasIPv6
|
||||
};
|
||||
|
||||
var assert = require('assert'),
|
||||
config = require('./config.js'),
|
||||
ec2 = require('./sysinfo/ec2.js'),
|
||||
fs = require('fs'),
|
||||
generic = require('./sysinfo/generic.js'),
|
||||
scaleway = require('./sysinfo/scaleway.js'),
|
||||
util = require('util');
|
||||
@@ -56,3 +59,9 @@ function getPublicIp(callback) {
|
||||
api.getPublicIp(callback);
|
||||
});
|
||||
}
|
||||
|
||||
function hasIPv6() {
|
||||
const IPV6_PROC_FILE = '/proc/net/if_inet6';
|
||||
// on contabo, /proc/net/if_inet6 is an empty file. so just exists is not enough
|
||||
return fs.existsSync(IPV6_PROC_FILE) && fs.readFileSync(IPV6_PROC_FILE, 'utf8').trim().length !== 0;
|
||||
}
|
||||
|
||||
@@ -79,8 +79,4 @@ describe('config', function () {
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('test machine has IPv6 support', function () {
|
||||
expect(config.hasIPv6()).to.equal(true);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
/* global it:false */
|
||||
/* global describe:false */
|
||||
/* global after:false */
|
||||
/* global before:false */
|
||||
|
||||
'use strict';
|
||||
|
||||
var config = require('../config.js'),
|
||||
expect = require('expect.js'),
|
||||
sysinfo = require('../sysinfo.js');
|
||||
|
||||
describe('config', function () {
|
||||
before(function () {
|
||||
config._reset();
|
||||
});
|
||||
|
||||
after(function () {
|
||||
config._reset();
|
||||
});
|
||||
|
||||
it('test machine has IPv6 support', function () {
|
||||
expect(sysinfo.hasIPv6()).to.equal(true);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user