diff --git a/bin/telebitd.js b/bin/telebitd.js index 75408dc..8314e30 100755 --- a/bin/telebitd.js +++ b/bin/telebitd.js @@ -637,7 +637,7 @@ function handleApi(req, res) { , active: !!myRemote , initialized: (state.config.relay && state.config.token && state.config.agreeTos) ? true : false , connected: isConnected - , proctime: Math.round(process.uptime() * 1000) + //, proctime: Math.round(process.uptime() * 1000) , uptime: now - startTime , runtime: isConnected && connectTimes.length && (now - connectTimes[0]) || 0 , reconnects: connectTimes.length diff --git a/lib/admin/index.html b/lib/admin/index.html index a0e9028..6a08197 100644 --- a/lib/admin/index.html +++ b/lib/admin/index.html @@ -115,74 +115,95 @@
- - -
-
- http://localhost:{{ status.port }}

- SSH: - {{ status.ssh }} - - - -
-
+
+ + + +
- Path Hosting: - -
- - - - -
-
+
+ SSH: + {{ status.ssh }} + + + +
+
+
SSH is currently running
+
SSH is not currently running
+
+
Password Authentication is NOT disabled. + Please consider updating your sshd_config and restarting ssh. +
{{ status }}
+
+
Key-Only Authentication is enabled :)
+
+
- Port Forwarding: - -
- - - - -
+
+ Path Hosting: + +
+ + + + +
+
+
+ +
+ Port Forwarding: + +
+ + + + +
+
-
- Proctime: {{ statusProctime }}
Uptime: {{ statusUptime }}
Runtime: {{ statusRuntime }}
Reconnects: {{ status.reconnects }} + +
Advanced + +
+
+
{{ status }}
+
diff --git a/lib/admin/js/app.js b/lib/admin/js/app.js index 3dd907d..708dbfb 100644 --- a/lib/admin/js/app.js +++ b/lib/admin/js/app.js @@ -247,6 +247,7 @@ var appMethods = { , deletePathHost: function (domain) { api.http(domain.name, 'none'); } +, changeState: changeState }; var appStates = { setup: function () { @@ -263,51 +264,113 @@ var appStates = { clearInterval(tok); } - function updateStatus() { - return api.status().then(function (status) { - if (status.error) { - appData.views.flash.error = status.error.message || JSON.stringify(status.error, null, 2); - } - var wilddomains = []; - var rootdomains = []; - var subdomains = []; - var directories = []; - var portforwards = []; - var free = []; - appData.status = status; - Object.keys(appData.status.servernames).forEach(function (k) { - var s = appData.status.servernames[k]; - s.name = k; - if (s.wildcard) { wilddomains.push(s); } - if (!s.sub && !s.wildcard) { rootdomains.push(s); } - if (s.sub) { subdomains.push(s); } - if (s.handler) { - if (s.handler.toString() === parseInt(s.handler, 10).toString()) { - s._port = s.handler; - portforwards.push(s); - } else { - s.path = s.handler; - directories.push(s); - } - } else { - free.push(s); - } - }); - appData.status.portForwards = portforwards; - appData.status.pathHosting = directories; - appData.status.wildDomains = wilddomains; - appData.newHttp.name = (appData.status.wildDomains[0] || {}).name; - appData.state.ssh = (appData.status.ssh > 0) && appData.status.ssh || undefined; - }); - } var tok = setInterval(updateStatus, 2000); return updateStatus().then(function () { - appData.views.section = { status: true }; + appData.views.section = { status: true, status_chooser: true }; return exitState; }); } }; +appStates.status.share = function () { + function exitState() { + clearInterval(tok); + } + + var tok = setInterval(updateStatus, 2000); + + appData.views.section = { status: true, status_share: true }; + return updateStatus().then(function () { + return exitState; + }); +}; +appStates.status.host = function () { + function exitState() { + clearInterval(tok); + } + + var tok = setInterval(updateStatus, 2000); + + appData.views.section = { status: true, status_host: true }; + return updateStatus().then(function () { + return exitState; + }); +}; +appStates.status.access = function () { + function exitState() { + clearInterval(tok); + } + + var tok = setInterval(updateStatus, 2000); + + appData.views.section = { status: true, status_access: true }; + return updateStatus().then(function () { + return exitState; + }); +}; + +function updateStatus() { + return api.status().then(function (status) { + if (status.error) { + appData.views.flash.error = status.error.message || JSON.stringify(status.error, null, 2); + } + var wilddomains = []; + var rootdomains = []; + var subdomains = []; + var directories = []; + var portforwards = []; + var free = []; + appData.status = status; + if ('maybe' === status.ssh_requests_password) { + appData.status.ssh_active = false; + } else { + appData.status.ssh_active = true; + if ('yes' === status.ssh_requests_password) { + appData.status.ssh_insecure = true; + } + } + if ('yes' === status.ssh_password_authentication) { + appData.status.ssh_insecure = true; + } + if ('yes' === status.ssh_permit_root_login) { + appData.status.ssh_insecure = true; + } + + // only update what's changed + if (appData.state.ssh !== appData.status.ssh) { + appData.state.ssh = appData.status.ssh; + } + if (appData.state.ssh_insecure !== appData.status.ssh_insecure) { + appData.state.ssh_insecure = appData.status.ssh_insecure; + } + if (appData.state.ssh_active !== appData.status.ssh_active) { + appData.state.ssh_active = appData.status.ssh_active; + } + Object.keys(appData.status.servernames).forEach(function (k) { + var s = appData.status.servernames[k]; + s.name = k; + if (s.wildcard) { wilddomains.push(s); } + if (!s.sub && !s.wildcard) { rootdomains.push(s); } + if (s.sub) { subdomains.push(s); } + if (s.handler) { + if (s.handler.toString() === parseInt(s.handler, 10).toString()) { + s._port = s.handler; + portforwards.push(s); + } else { + s.path = s.handler; + directories.push(s); + } + } else { + free.push(s); + } + }); + appData.status.portForwards = portforwards; + appData.status.pathHosting = directories; + appData.status.wildDomains = wilddomains; + appData.newHttp.name = (appData.status.wildDomains[0] || {}).name; + appData.state.ssh = (appData.status.ssh > 0) && appData.status.ssh || undefined; + }); +} function changeState(newstate) { var newhash = '#/' + newstate + '/'; @@ -325,13 +388,14 @@ function setState(/*ev*/) { //ev.oldURL //ev.newURL if (appData.exit) { + console.log('previous state exiting'); appData.exit.then(function (exit) { if ('function' === typeof appData.exit) { exit(); } }); } - var parts = location.hash.substr(1).replace(/^\//, '').replace(/\/$/, '').split('/'); + var parts = location.hash.substr(1).replace(/^\//, '').replace(/\/$/, '').split('/').filter(Boolean); var fn = appStates; parts.forEach(function (s) { console.log("state:", s);