show many more things
This commit is contained in:
parent
783dd3c53b
commit
90f5eb11d5
|
@ -18,24 +18,18 @@
|
||||||
|
|
||||||
<div class="container" ng-controller="LoginController as vm" ng-init="vm.setSimple()">
|
<div class="container" ng-controller="LoginController as vm" ng-init="vm.setSimple()">
|
||||||
<h1 ng-if="!vm.authnUpdated">Initializing... {{vm.hello}}</h1>
|
<h1 ng-if="!vm.authnUpdated">Initializing... {{vm.hello}}</h1>
|
||||||
|
<div>
|
||||||
|
Configure Remote Server
|
||||||
|
<label>Configuration Address:</label>
|
||||||
|
<input type="text" placeholder="i.e. 192.168.1.100">
|
||||||
|
<label>Configuration Name:</label>
|
||||||
|
<input type="text" placeholder="i.e. localhost.daplie.invalid">
|
||||||
|
<label>Root Certificate Validation (optional):</label>
|
||||||
|
<textarea class="textarea" placeholder="paste the contents of a root.pem here"></textarea>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div ng-if="!vm.authnUpdated">
|
<div ng-if="!vm.authnUpdated">
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
class="btn btn-link"
|
|
||||||
ng-if="!vm.advanced"
|
|
||||||
ng-click="vm.setAdvanced()"
|
|
||||||
>advanced</button>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
class="btn btn-link"
|
|
||||||
ng-if="vm.advanced"
|
|
||||||
ng-click="vm.setSimple();"
|
|
||||||
>simple</button>
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
ng-if="vm.advanced"
|
|
||||||
ng-change="vm.checkProviderUri(vm.myProviderUri)"
|
|
||||||
ng-model="vm.myProviderUri">
|
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
class="btn btn-default"
|
class="btn btn-default"
|
||||||
|
@ -43,48 +37,143 @@
|
||||||
ng-click="vm.authenticate()"
|
ng-click="vm.authenticate()"
|
||||||
>Login</button>
|
>Login</button>
|
||||||
</div>
|
</div>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="btn btn-link"
|
||||||
|
ng-if="!vm.advanced"
|
||||||
|
ng-click="vm.setAdvanced()"
|
||||||
|
>advanced</button>
|
||||||
|
<div ng-if="vm.advanced">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="btn btn-link"
|
||||||
|
ng-click="vm.setSimple();"
|
||||||
|
>simple</button>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
ng-change="vm.checkProviderUri(vm.myProviderUri)"
|
||||||
|
ng-model="vm.myProviderUri">
|
||||||
|
<br/>
|
||||||
|
<small>todo: allow per-device authorization</small>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div ng-if="vm.config">
|
<div ng-if="vm.config">
|
||||||
<div class="input-group" ng-init="siteconf = vm.config.global">
|
<div ng-init="siteconf = vm.config.global">
|
||||||
|
<h1>Server Device Name: <span ng-bind="vm.config.device.hostname"></span></h1>
|
||||||
|
<!-- input class="form-control" ng-model="vm.config.device.hostname" / -->
|
||||||
|
|
||||||
<h1>Server Working Directory:</h1>
|
<h1>Server Working Directory:</h1>
|
||||||
<input class="form-control" ng-model="vm.config.cwd" />
|
<input class="form-control" ng-model="vm.config.cwd" />
|
||||||
|
|
||||||
|
<h1>Addresses:</h1>
|
||||||
|
<table class="table">
|
||||||
|
<tr>
|
||||||
|
<th>Interface</th>
|
||||||
|
<th>Address</th>
|
||||||
|
<th>Family</th>
|
||||||
|
<th>Scope</th>
|
||||||
|
</tr>
|
||||||
|
<tr ng-repeat="addr in vm.config.addresses">
|
||||||
|
<td ng-bind="addr.iface"></td>
|
||||||
|
<td ng-bind="addr.address"></td>
|
||||||
|
<td ng-bind="addr.family"></td>
|
||||||
|
<td ng-bind="addr.range"></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<h1>Managed Domains:</h1>
|
||||||
|
|
||||||
|
<div ng-if="!vm.domains.length">
|
||||||
|
You don't have any domains with this account.
|
||||||
|
<br/>
|
||||||
|
Try a different account?
|
||||||
|
<br/>
|
||||||
|
<input type="url" placeholder="https://daplie.domains">
|
||||||
|
<button type="button"
|
||||||
|
class="btn"
|
||||||
|
disabled
|
||||||
|
>Login</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div ng-if="vm.domains.length">
|
||||||
|
<h2>Enable Tunnel</h2>
|
||||||
|
<input type="radio" ng-model="vm.config.tunnel.enabled" ng-value="true">
|
||||||
|
<input type="radio" ng-model="vm.config.tunnel.enabled" ng-value="false">
|
||||||
|
|
||||||
|
<table class="table">
|
||||||
|
<tr>
|
||||||
|
<th>Domain</th>
|
||||||
|
<th>Sub</th>
|
||||||
|
<th>Devices</th>
|
||||||
|
</tr>
|
||||||
|
<tr ng-repeat="d in vm.dns">
|
||||||
|
<td ng-bind="d.domain"></td>
|
||||||
|
<td ng-bind="d.name"></td>
|
||||||
|
<td>
|
||||||
|
<span ng-if="!d.domain">
|
||||||
|
<div ng-repeat="dev in d.devices">
|
||||||
|
<span ng-bind="dev"
|
||||||
|
></span> <button
|
||||||
|
type="button"
|
||||||
|
class="btn btn-danger"
|
||||||
|
ng-click="vm.removeDevice(d, dev)"
|
||||||
|
>x</button>
|
||||||
|
</div>
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
<h1>Global Settings:</h1>
|
<h1>Global Settings:</h1>
|
||||||
<br/>
|
<br/>
|
||||||
<div ng-repeat="path in siteconf.paths">Pathname:
|
<form class="form-inline">
|
||||||
<input class="form-control" ng-model="path.$id" />
|
<div ng-repeat="path in siteconf.paths">
|
||||||
<div ng-repeat="module in path.modules">Modulename: {{module.$id}}
|
<h2 ng-bind="path.$id"></h2>
|
||||||
<div ng-repeat="(key, value) in module">{{key}}:
|
<div ng-repeat="module in path.modules">
|
||||||
<input class="form-control" ng-model="value" />
|
<h3>{{module.$id}}</h3>
|
||||||
|
<div ng-repeat="(key, value) in module">
|
||||||
|
<label>{{key}}</label>: <input class="form-control" ng-model="module[key]" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<br/>
|
||||||
|
<br/>
|
||||||
|
<br/>
|
||||||
</div>
|
</div>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h1>Per-Domain Settings:</h1>
|
<h1>Per-Domain Settings:</h1>
|
||||||
<div class="input-group" ng-repeat="siteconf in vm.config.sites">
|
<div ng-repeat="siteconf in vm.config.sites">
|
||||||
<label>Hostname:</label> <input class="form-control" ng-model="siteconf.$id" />
|
<h2 ng-bind="siteconf.$id"></h2>
|
||||||
|
<div ng-repeat="path in siteconf.paths">
|
||||||
|
<h2 ng-bind="path.$id"></h2>
|
||||||
|
<div ng-repeat="module in path.modules">
|
||||||
|
<h3>{{module.$id}}</h3>
|
||||||
|
<div ng-repeat="(key, value) in module">
|
||||||
|
<label>{{key}}</label>: <input class="form-control" ng-model="module[key]" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<br/>
|
||||||
|
<br/>
|
||||||
<br/>
|
<br/>
|
||||||
<div ng-repeat="path in siteconf.paths">Pathname:
|
|
||||||
<input class="form-control" ng-model="path.$id" />
|
|
||||||
<div ng-repeat="module in path.modules">Modulename: {{module.$id}}
|
|
||||||
<div ng-repeat="(key, value) in module">{{key}}:
|
|
||||||
<input class="form-control" ng-model="value" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="input-group" ng-init="defaultsconf = vm.config.defaults">
|
<div ng-init="defaultsconf = vm.config.defaults">
|
||||||
<h1>Fallback Settings:</h1>
|
<h1>Fallback Settings:</h1>
|
||||||
<br/>
|
<br/>
|
||||||
<div ng-repeat="path in defaultsconf.paths">Pathname:
|
<div ng-repeat="path in siteconf.paths">
|
||||||
<input class="form-control" ng-model="path.$id" />
|
<h2 ng-bind="path.$id"></h2>
|
||||||
<div ng-repeat="module in path.modules">Modulename: {{module.$id}}
|
<div ng-repeat="module in path.modules">
|
||||||
<div ng-repeat="(key, value) in module">{{key}}:
|
<h3>{{module.$id}}</h3>
|
||||||
<input class="form-control" ng-model="value" />
|
<div ng-repeat="(key, value) in module">
|
||||||
|
<label>{{key}}</label>: <input class="form-control" ng-model="module[key]" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<br/>
|
||||||
|
<br/>
|
||||||
|
<br/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -104,6 +193,7 @@
|
||||||
<script src="/assets/org.oauth3/oauth3.core.js"></script>
|
<script src="/assets/org.oauth3/oauth3.core.js"></script>
|
||||||
<script src="/assets/org.oauth3/oauth3.ng.js"></script>
|
<script src="/assets/org.oauth3/oauth3.ng.js"></script>
|
||||||
<script src="/assets/org.oauth3/oauth3.domains.js"></script>
|
<script src="/assets/org.oauth3/oauth3.domains.js"></script>
|
||||||
|
<script src="/assets/org.oauth3/oauth3.dns.js"></script>
|
||||||
<script src="/js/app.js"></script>
|
<script src="/js/app.js"></script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
|
@ -38,6 +38,91 @@ angular.module('com.daplie.cloud', [ 'org.oauth3' ])
|
||||||
}, 250);
|
}, 250);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
vm.sortDnsRecords = function (a, b) {
|
||||||
|
if (a.sld !== b.sld) {
|
||||||
|
return a.sld > b.sld ? 1 : -1;
|
||||||
|
}
|
||||||
|
if (a.tld !== b.tld) {
|
||||||
|
return a.tld > b.tld ? 1 : -1;
|
||||||
|
}
|
||||||
|
// TODO normalize
|
||||||
|
a.sub = a.sub || '';
|
||||||
|
b.sub = b.sub || '';
|
||||||
|
if (a.sub !== b.sub) {
|
||||||
|
if (!a.sub) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (!b.sub) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return a.sub > b.sub ? 1 : -1;
|
||||||
|
}
|
||||||
|
if (a.domain !== b.domain) {
|
||||||
|
if (!a.domain) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (!b.domain) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
vm.viewDomains = function (config, domains, dns) {
|
||||||
|
vm.dns = dns.slice(0);
|
||||||
|
vm.domains = domains.slice(0);
|
||||||
|
vm.dns = vm.dns.filter(function (record) {
|
||||||
|
if (-1 === [ 'A', 'AAAA', 'ANAME' ].indexOf(record.type)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (record.device !== config.device.hostname) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
vm.dns.forEach(function (r) {
|
||||||
|
vm.domains.forEach(function (d) {
|
||||||
|
if (r.zone === d.domain) {
|
||||||
|
r.sub = r.name.substr(0, r.name.length - (d.domain.length + 1));
|
||||||
|
r.tld = d.tld;
|
||||||
|
r.sld = d.sld;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
vm.dns = vm.dns.concat(vm.domains);
|
||||||
|
vm.dns.sort(vm.sortDnsRecords);
|
||||||
|
vm.dns.forEach(function (r) {
|
||||||
|
if (r.domain) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
r.devices = r.devices || [ r.device ];
|
||||||
|
|
||||||
|
dns.forEach(function (r2) {
|
||||||
|
if (r.name !== r2.name) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (-1 !== r.devices.indexOf(r2.device)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
r.devices.push(r2.device);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
console.log('vm.dns');
|
||||||
|
console.log(vm.dns);
|
||||||
|
/*
|
||||||
|
vm.domains.forEach(function (d) {
|
||||||
|
d.devices = [];
|
||||||
|
dns.forEach(function (r) {
|
||||||
|
// 0 === r.name.split('').reverse().join('').indexOf(d.domain.split('').reverse().join(''))
|
||||||
|
if (r.zone === d.domain) {
|
||||||
|
d.devices.push({
|
||||||
|
name: r.device
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
*/
|
||||||
|
};
|
||||||
|
|
||||||
vm.authenticate = function () {
|
vm.authenticate = function () {
|
||||||
// TODO authorization redirect /api/org.oauth3.consumer/authorization_redirect/:provider_uri
|
// TODO authorization redirect /api/org.oauth3.consumer/authorization_redirect/:provider_uri
|
||||||
|
|
||||||
|
@ -46,7 +131,9 @@ angular.module('com.daplie.cloud', [ 'org.oauth3' ])
|
||||||
|
|
||||||
return oauth3.api('domains.list').then(function (domains) {
|
return oauth3.api('domains.list').then(function (domains) {
|
||||||
console.info("domains owned", domains);
|
console.info("domains owned", domains);
|
||||||
vm.domains = domains;
|
|
||||||
|
return oauth3.api('dns.list').then(function (dns) {
|
||||||
|
console.info("dns records", dns);
|
||||||
|
|
||||||
return OAUTH3.request({
|
return OAUTH3.request({
|
||||||
method: 'POST'
|
method: 'POST'
|
||||||
|
@ -79,6 +166,9 @@ angular.module('com.daplie.cloud', [ 'org.oauth3' ])
|
||||||
}).then(function (configResp) {
|
}).then(function (configResp) {
|
||||||
console.log('config', configResp.data);
|
console.log('config', configResp.data);
|
||||||
vm.config = configResp.data;
|
vm.config = configResp.data;
|
||||||
|
//vm.config.ifaces
|
||||||
|
//vm.config.addresses = [];
|
||||||
|
vm.viewDomains(vm.config, domains, dns);
|
||||||
return resp;
|
return resp;
|
||||||
});
|
});
|
||||||
}, function (err) {
|
}, function (err) {
|
||||||
|
@ -86,6 +176,7 @@ angular.module('com.daplie.cloud', [ 'org.oauth3' ])
|
||||||
window.alert("Initialization failed:" + err.message);
|
window.alert("Initialization failed:" + err.message);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}, function (err) {
|
}, function (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
window.alert("Authentication failed:" + err.message);
|
window.alert("Authentication failed:" + err.message);
|
||||||
|
|
|
@ -92,12 +92,50 @@ function createServer(port, _delete_me_, content, opts) {
|
||||||
|
|
||||||
return new PromiseA(function (realResolve) {
|
return new PromiseA(function (realResolve) {
|
||||||
var app = require('../lib/app.js');
|
var app = require('../lib/app.js');
|
||||||
|
var ipaddr = require('ipaddr.js');
|
||||||
|
var addresses = [];
|
||||||
|
|
||||||
|
Object.keys(opts.ifaces).forEach(function (ifacename) {
|
||||||
|
var iface = opts.ifaces[ifacename];
|
||||||
|
iface.ipv4.forEach(function (ip) {
|
||||||
|
addresses.push(ip);
|
||||||
|
});
|
||||||
|
iface.ipv6.forEach(function (ip) {
|
||||||
|
addresses.push(ip);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
addresses.sort(function (a, b) {
|
||||||
|
if (a.family !== b.family) {
|
||||||
|
return 'IPv4' === a.family ? 1 : -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return a.address > b.address ? 1 : -1;
|
||||||
|
});
|
||||||
|
|
||||||
|
addresses.forEach(function (addr) {
|
||||||
|
addr.range = ipaddr.parse(addr.address).range();
|
||||||
|
});
|
||||||
|
|
||||||
|
var Oauth3 = require('oauth3-cli');
|
||||||
|
var oauth3 = Oauth3.create({ device: { hostname: opts.device } });
|
||||||
|
return Oauth3.Devices.one(oauth3).then(function (device) {
|
||||||
|
return Oauth3.Devices.all(oauth3).then(function (devices) {
|
||||||
|
return { devices: devices, device: device.device || device };
|
||||||
|
});
|
||||||
|
}).then(function (devices) {
|
||||||
|
devices.device.secret = undefined;
|
||||||
|
console.log('devices');
|
||||||
|
console.log(devices);
|
||||||
var directive = {
|
var directive = {
|
||||||
global: opts.global
|
global: opts.global
|
||||||
, sites: opts.sites
|
, sites: opts.sites
|
||||||
, defaults: opts.defaults
|
, defaults: opts.defaults
|
||||||
, cwd: process.cwd()
|
, cwd: process.cwd()
|
||||||
|
, ifaces: opts.ifaces
|
||||||
|
, addresses: addresses
|
||||||
|
, devices: devices.devices
|
||||||
|
, device: devices.device
|
||||||
};
|
};
|
||||||
var server;
|
var server;
|
||||||
var insecureServer;
|
var insecureServer;
|
||||||
|
@ -240,6 +278,7 @@ function createServer(port, _delete_me_, content, opts) {
|
||||||
app = _app;
|
app = _app;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports.createServer = createServer;
|
module.exports.createServer = createServer;
|
||||||
|
|
|
@ -47,6 +47,7 @@
|
||||||
"greenlock": "git+https://git.daplie.com/Daplie/node-greenlock.git#master",
|
"greenlock": "git+https://git.daplie.com/Daplie/node-greenlock.git#master",
|
||||||
"greenlock-express": "git+https://git.daplie.com/Daplie/greenlock-express.git#master",
|
"greenlock-express": "git+https://git.daplie.com/Daplie/greenlock-express.git#master",
|
||||||
"httpolyglot": "^0.1.1",
|
"httpolyglot": "^0.1.1",
|
||||||
|
"ipaddr.js": "git+https://github.com/whitequark/ipaddr.js.git#v1.3.0",
|
||||||
"ipify": "^1.1.0",
|
"ipify": "^1.1.0",
|
||||||
"js-yaml": "^3.8.1",
|
"js-yaml": "^3.8.1",
|
||||||
"le-challenge-ddns": "git+https://git.daplie.com/Daplie/le-challenge-ddns.git#master",
|
"le-challenge-ddns": "git+https://git.daplie.com/Daplie/le-challenge-ddns.git#master",
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 356a2d3131bcc6d0f6199a1d2039dcdcee0e3481
|
Subproject commit d64699977e883871246d3fc062a384e88a554e2a
|
Loading…
Reference in New Issue