diff --git a/.gitignore b/.gitignore index 4cfd0fe..73586b6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,8 @@ emails +lib/extensions/permissions.json +lib/extensions/permissions.json.bak +lib/extensions/admin/sclient/dist/ +lib/extensions/admin/optify/dist/ node_modules.* include bin/node diff --git a/bin/telebit-relay.js b/bin/telebit-relay.js index 684b86f..93f3a2f 100755 --- a/bin/telebit-relay.js +++ b/bin/telebit-relay.js @@ -2,6 +2,10 @@ (function () { 'use strict'; +var fs = require('fs'); +var path = require('path'); +var os = require('os'); + var pkg = require('../package.json'); var argv = process.argv.slice(2); @@ -67,54 +71,59 @@ function applyConfig(config) { state.config.greenlock.configDir = require('os').homedir() + require('path').sep + 'acme'; } + // The domains being approved for the first time are listed in opts.domains + // Certs being renewed are listed in certs.altnames function approveDomains(opts, certs, cb) { if (state.debug) { console.log('[debug] approveDomains', opts.domains); } - // This is where you check your database and associated - // email addresses with domains and agreements and such - // The domains being approved for the first time are listed in opts.domains - // Certs being renewed are listed in certs.altnames - if (certs) { - opts.domains = certs.altnames; - cb(null, { options: opts, certs: certs }); - return; - } - - if (!state.validHosts) { state.validHosts = {}; } - if (!state.validHosts[opts.domains[0]] && state.config.vhost) { - if (state.debug) { console.log('[sni] vhost checking is turned on'); } - var vhost = state.config.vhost.replace(/:hostname/, opts.domains[0]); - require('fs').readdir(vhost, function (err, nodes) { - if (state.debug) { console.log('[sni] checking fs vhost', opts.domains[0], !err); } - if (err) { check(); return; } - if (nodes) { approve(); } - }); - return; - } - - function approve() { + function allow() { state.validHosts[opts.domains[0]] = true; opts.email = state.config.email; opts.agreeTos = state.config.agreeTos; opts.communityMember = state.config.communityMember || state.config.greenlock.communityMember; opts.challenges = { // TODO dns-01 - 'http-01': require('le-challenge-fs').create({ webrootPath: '/tmp/acme-challenges' }) + 'http-01': require('le-challenge-fs').create({ webrootPath: path.join(os.tmpdir(), 'acme-challenges') }) }; opts.communityMember = state.config.communityMember; cb(null, { options: opts, certs: certs }); } - function check() { - if (state.debug) { console.log('[sni] checking servername'); } - if (-1 !== state.servernames.indexOf(opts.domain) || -1 !== (state._servernames||[]).indexOf(opts.domain)) { - approve(); - } else { - cb(new Error("failed the approval chain '" + opts.domains[0] + "'")); - } + function deny() { + cb(new Error("[bin/telebit-relay.js] failed the approval chain '" + opts.domains[0] + "'")); + return; } - check(); + // 1) If the host was already allowed => allow + if (!state.validHosts) { state.validHosts = {}; } + if (state.validHosts[opts.domains[0]]) { + allow(); + return; + } + + // 2) If the host is in the config => allow + if (state.debug) { console.log('[sni] checking servername'); } + if (-1 !== state.servernames.indexOf(opts.domain) + || -1 !== (state._servernames||[]).indexOf(opts.domain)) { + allow(); + return; + } + + // 3) If dynamic vhosting is allowed + // & a vhost folder exist for this domain => allow + if (state.config.vhost) { + if (state.debug) { console.log('[sni] vhost checking is turned on'); } + var vhost = state.config.vhost.replace(/:hostname/, opts.domains[0]); + require('fs').readdir(vhost, function (err, nodes) { + if (state.debug) { console.log('[sni] checking fs vhost', opts.domains[0], !err); } + if (err) { deny(); return; } + if (nodes) { allow(); } + }); + return; + } + + // 4) fallback => fail + deny(); } state.greenlock = Greenlock.create({ @@ -196,7 +205,7 @@ function applyConfig(config) { //}); } -require('fs').readFile(confpath, 'utf8', function (err, text) { +fs.readFile(confpath, 'utf8', function (err, text) { var config; var recase = require('recase').create({}); diff --git a/lib/extensions/admin/dist/notes.txt b/lib/extensions/admin/dist/notes.txt new file mode 100644 index 0000000..a4b26cd --- /dev/null +++ b/lib/extensions/admin/dist/notes.txt @@ -0,0 +1,86 @@ +Release Notes +============= + +Table of Contents + +* v0.20.6 - protocol upgrade + +Re: v0.20.6 +=========== + +Saturday, Sept 29, 2018 + +This version is a required update. I had to make some changes to the network +protocol that were easy enough to make backwards-compatible in the client, but +not worth the effort to do so on the server. + +Mac, Linux, Raspberry Pi Users: +------------------------------- + + curl -fsSL https://get.telebit.io | bash + +That should be quick and easy, but you may need to reboot your computer. + +Windows & npm users +------------------- + + npm install -g npm + +Note that on Windows the upgrade will **NOT** work while Telebit is +running. `telebit restart` should kill it but, on Windows, won't actually +restart it. + +This is not well tested, so please contact me (aj@ppl.family) if you have any +trouble. + +Upgrading *really* old versions +--------------------- + +If you have a version of telebit prior to v0.18.1 (which may not even list its +version in `telebit help` yet), it'll probably be easiest to manually remove +the old telebit files first: + + sudo rm -rf ~/Applications/telebit* ~/.config/telebit* + sudo rm -rf /opt/telebit* /etc/telebit* /etc/systemd/system/telebit* + +You'll lose your current domain. If that's an issue, contact me and we can work +it out. + +Rationale +--------- + +> "If it ain't broke, don't fix it" - Ancient Redneck Proverb + +> "When is broke, is most right time to fix" - Ageless Chinese Adage + +There's a delicate balance between the two and in my infinite wisdom I've +decided that now is the right time to fix. +There are some rather disruptive bugs in the network protocol and fixing them +means breaking most existing clients. + +If you've been using telebit on a daily basis, especially with ssh, I believe +that'll you see benefit immediately and even moreso once the server is updated. +It's worth it. + +Additional Notes +---------------- + +A number of good fixes are in here: + + +### `telebit help` + +The in-app cli help is now correctly documented. Not everything _works_ as +documented, however. Feel free to poke around and give me feedback. + + +### `telebit ssh none` + +Previously `telebit ssh none` behaved identically to `telebit ssh auto`. + +The output correctly showed the actual behavior, but it didn't make sense. + +Bascially this was happening: `telebit.ssh = telebit.ssh || 22`. So when it +it was `false` it became `true` + +It was changed to this `if (!('ssh' in telebit)) { telebit.ssh = 22; }`. diff --git a/lib/extensions/admin/index.html b/lib/extensions/admin/index.html index ea5cdc5..0eb625b 100644 --- a/lib/extensions/admin/index.html +++ b/lib/extensions/admin/index.html @@ -2,13 +2,36 @@ + Telebit™ Cloud - + +
@@ -29,10 +52,9 @@
-

Work from 127.0.0.1

-
-
- Download +

Access your devices +
Share your stuff +

@@ -68,7 +90,7 @@
-
+

Use it
+ Telebit - Pair Device + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +