diff --git a/dashboard/src/js/client.js b/dashboard/src/js/client.js
index d6a6fc7d2..d7ba46520 100644
--- a/dashboard/src/js/client.js
+++ b/dashboard/src/js/client.js
@@ -1512,16 +1512,7 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout
});
};
- Client.prototype.restore = function (backupConfig, remotePath, version, ipv4Config, skipDnsSetup, setupToken, callback) {
- var data = {
- backupConfig: backupConfig,
- remotePath: remotePath,
- version: version,
- ipv4Config: ipv4Config,
- skipDnsSetup: skipDnsSetup,
- setupToken: setupToken
- };
-
+ Client.prototype.restore = function (data, callback) {
post('/api/v1/provision/restore', data, null, function (error, data, status) {
if (error) return callback(error);
if (status !== 200) return callback(new ClientError(status));
diff --git a/dashboard/src/js/restore.js b/dashboard/src/js/restore.js
index 046289921..b3cd81991 100644
--- a/dashboard/src/js/restore.js
+++ b/dashboard/src/js/restore.js
@@ -61,7 +61,13 @@ app.controller('RestoreController', ['$scope', 'Client', function ($scope, Clien
ifname: ''
};
- $scope.ipv4Providers = [
+ $scope.ipv6Config = {
+ provider: 'generic',
+ ip: '',
+ ifname: ''
+ };
+
+ $scope.ipProviders = [
{ name: 'Disabled', value: 'noop' },
{ name: 'Public IP', value: 'generic' },
{ name: 'Static IP Address', value: 'fixed' },
@@ -225,16 +231,17 @@ app.controller('RestoreController', ['$scope', 'Client', function ($scope, Clien
return;
}
- var ipv4Config = {
- provider: $scope.ipv4Config.provider
+ var data = {
+ backupConfig: backupConfig,
+ remotePath: $scope.remotePath.replace(/\.tar\.gz(\.enc)?$/, ''),
+ version: version ? version[1] : '',
+ ipv4Config: $scope.ipv4Config,
+ ipv6Config: $scope.ipv6Config,
+ skipDnsSetup: $scope.skipDnsSetup,
+ setupToken: $scope.setupToken
};
- if ($scope.ipv4Config.provider === 'fixed') {
- ipv4Config.ip = $scope.ipv4Config.ip;
- } else if ($scope.ipv4Config.provider === 'network-interface') {
- ipv4Config.ifname = $scope.ipv4Config.ifname;
- }
- Client.restore(backupConfig, $scope.remotePath.replace(/\.tar\.gz(\.enc)?$/, ''), version ? version[1] : '', ipv4Config, $scope.skipDnsSetup, $scope.setupToken, function (error) {
+ Client.restore(data, function (error) {
$scope.busy = false;
if (error) {
diff --git a/dashboard/src/js/setupdns.js b/dashboard/src/js/setupdns.js
index 3e0b34ae8..da04176d1 100644
--- a/dashboard/src/js/setupdns.js
+++ b/dashboard/src/js/setupdns.js
@@ -32,7 +32,13 @@ app.controller('SetupDNSController', ['$scope', '$http', '$timeout', 'Client', f
ifname: ''
};
- $scope.ipv4Providers = [
+ $scope.ipv6Config = {
+ provider: 'generic',
+ ip: '',
+ ifname: ''
+ };
+
+ $scope.ipProviders = [
{ name: 'Disabled', value: 'noop' },
{ name: 'Public IP', value: 'generic' },
{ name: 'Static IP Address', value: 'fixed' },
@@ -223,15 +229,6 @@ app.controller('SetupDNSController', ['$scope', '$http', '$timeout', 'Client', f
tlsConfig.wildcard = true;
}
- var ipv4Config = {
- provider: $scope.ipv4Config.provider
- };
- if ($scope.ipv4Config.provider === 'fixed') {
- ipv4Config.ip = $scope.ipv4Config.ip;
- } else if ($scope.ipv4Config.provider === 'network-interface') {
- ipv4Config.ifname = $scope.ipv4Config.ifname;
- }
-
var data = {
domainConfig: {
domain: $scope.dnsCredentials.domain,
@@ -240,7 +237,8 @@ app.controller('SetupDNSController', ['$scope', '$http', '$timeout', 'Client', f
config: config,
tlsConfig: tlsConfig
},
- ipv4Config: ipv4Config,
+ ipv4Config: $scope.ipv4Config,
+ ipv6Config: $scope.ipv6Config,
providerToken: $scope.instanceId,
setupToken: $scope.setupToken
};
diff --git a/dashboard/src/restore.html b/dashboard/src/restore.html
index 43cc05f6a..4f888d396 100644
--- a/dashboard/src/restore.html
+++ b/dashboard/src/restore.html
@@ -304,7 +304,7 @@
@@ -316,7 +316,26 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dashboard/src/setupdns.html b/dashboard/src/setupdns.html
index 4f96bc505..cc65fd75b 100644
--- a/dashboard/src/setupdns.html
+++ b/dashboard/src/setupdns.html
@@ -314,7 +314,7 @@
@@ -326,8 +326,27 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Advanced settings...
diff --git a/src/provision.js b/src/provision.js
index eab252823..c67439bfb 100644
--- a/src/provision.js
+++ b/src/provision.js
@@ -90,9 +90,10 @@ async function setupTask(domain, auditSource) {
gStatus.setup.active = false;
}
-async function setup(domainConfig, ipv4Config, auditSource) {
+async function setup(domainConfig, ipv4Config, ipv6Config, auditSource) {
assert.strictEqual(typeof domainConfig, 'object');
assert.strictEqual(typeof ipv4Config, 'object');
+ assert.strictEqual(typeof ipv6Config, 'object');
assert.strictEqual(typeof auditSource, 'object');
if (gStatus.setup.active || gStatus.restore.active) throw new BoxError(BoxError.BAD_STATE, 'Already setting up or restoring');
@@ -122,6 +123,7 @@ async function setup(domainConfig, ipv4Config, auditSource) {
await mailServer.setLocation(constants.DASHBOARD_SUBDOMAIN, domain); // default mail location. do this before we add the domain for upserting mail DNS
await domains.add(domain, data, auditSource);
await network.setIPv4Config(ipv4Config);
+ await network.setIPv6Config(ipv6Config);
safe(setupTask(domain, auditSource), { debug }); // now that args are validated run the task in the background
} catch (error) {
@@ -160,10 +162,11 @@ async function activate(username, password, email, displayName, ip, auditSource)
};
}
-async function restoreTask(backupConfig, remotePath, ipv4Config, options, auditSource) {
+async function restoreTask(backupConfig, remotePath, ipv4Config, ipv6Config, options, auditSource) {
assert.strictEqual(typeof backupConfig, 'object');
assert.strictEqual(typeof remotePath, 'string');
assert.strictEqual(typeof ipv4Config, 'object');
+ assert.strictEqual(typeof ipv6Config, 'object');
assert.strictEqual(typeof options, 'object');
assert.strictEqual(typeof auditSource, 'object');
@@ -180,6 +183,7 @@ async function restoreTask(backupConfig, remotePath, ipv4Config, options, auditS
await ensureDhparams();
await network.setIPv4Config(ipv4Config);
+ await network.setIPv6Config(ipv6Config);
await reverseProxy.restoreFallbackCertificates();
const location = await dashboard.getLocation(); // load this fresh from after the backup.restore
diff --git a/src/routes/provision.js b/src/routes/provision.js
index 1fa415437..19c7d6dc4 100644
--- a/src/routes/provision.js
+++ b/src/routes/provision.js
@@ -68,11 +68,12 @@ async function setup(req, res, next) {
if (domainConfig.tlsConfig && (!domainConfig.tlsConfig.provider || typeof domainConfig.tlsConfig.provider !== 'string')) return next(new HttpError(400, 'tlsConfig.provider must be a string'));
if ('ipv4Config' in req.body && typeof req.body.ipv4Config !== 'object') return next(new HttpError(400, 'ipv4Config must be an object'));
+ if ('ipv6Config' in req.body && typeof req.body.ipv6Config !== 'object') return next(new HttpError(400, 'ipv6Config must be an object'));
// it can take sometime to setup DNS, register cloudron
req.clearTimeout();
- const [error] = await safe(provision.setup(domainConfig, req.body.ipv4Config || { provider: 'generic' }, AuditSource.fromRequest(req)));
+ const [error] = await safe(provision.setup(domainConfig, req.body.ipv4Config || { provider: 'generic' }, req.body.ipv6Config || { provider: 'generic' }, AuditSource.fromRequest(req)));
if (error) return next(BoxError.toHttpError(error));
next(new HttpSuccess(200, {}));
@@ -113,13 +114,15 @@ async function restore(req, res, next) {
if (typeof req.body.version !== 'string') return next(new HttpError(400, 'version must be a string'));
if ('ipv4Config' in req.body && typeof req.body.ipv4Config !== 'object') return next(new HttpError(400, 'ipv4Config must be an object'));
+ if ('ipv6Config' in req.body && typeof req.body.ipv6Config !== 'object') return next(new HttpError(400, 'ipv6Config must be an object'));
+
if ('skipDnsSetup' in req.body && typeof req.body.skipDnsSetup !== 'boolean') return next(new HttpError(400, 'skipDnsSetup must be a boolean'));
const options = {
skipDnsSetup: req.body.skipDnsSetup || false
};
- const [error] = await safe(provision.restore(backupConfig, req.body.remotePath, req.body.version, req.body.ipv4Config || { provider: 'generic' }, options, AuditSource.fromRequest(req)));
+ const [error] = await safe(provision.restore(backupConfig, req.body.remotePath, req.body.version, req.body.ipv4Config || { provider: 'generic' }, req.body.ipv6Config || { provider: 'generic' }, options, AuditSource.fromRequest(req)));
if (error) return next(BoxError.toHttpError(error));
next(new HttpSuccess(200, {}));