rearrange a few things
This commit is contained in:
parent
34bcf79d98
commit
535c9732c6
|
@ -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
|
||||
|
|
|
@ -115,15 +115,17 @@
|
|||
</section>
|
||||
|
||||
<section v-if="views.section.status">
|
||||
<button v-if="!status.enabled" v-on:click="enable">Enable Traffic</button>
|
||||
<button v-if="status.enabled" v-on:click="disable">Disable Traffic</button>
|
||||
<br>
|
||||
<br>
|
||||
|
||||
http://localhost:{{ status.port }}
|
||||
<br>
|
||||
<br>
|
||||
|
||||
<section v-if="views.section.status_chooser">
|
||||
<button v-on:click.prevent.stop="changeState('status/share')">Share Files & Folders</button>
|
||||
<button v-on:click.prevent.stop="changeState('status/host')">Host a Website or Webapp</button>
|
||||
<button v-on:click.prevent.stop="changeState('status/access')">Remote Access via SSH</button>
|
||||
</section>
|
||||
|
||||
<section v-if="views.section.status_access">
|
||||
SSH:
|
||||
<span v-if="status.ssh">{{ status.ssh }}
|
||||
<button v-on:click="ssh(-1)">Disable SSH</button></span>
|
||||
|
@ -131,7 +133,18 @@
|
|||
<button v-on:click="ssh(state.ssh)">Enable SSH</button></span>
|
||||
<br>
|
||||
<br>
|
||||
<div v-if="state.ssh_active">SSH is currently running</div>
|
||||
<div v-if="!state.ssh_active">SSH is not currently running</div>
|
||||
<br>
|
||||
<div v-if="state.ssh_insecure">Password Authentication is NOT disabled.
|
||||
Please consider updating your <code>sshd_config</code> and restarting ssh.
|
||||
<pre><code>{{ status }}</code></pre>
|
||||
</div>
|
||||
<div v-if="!state.ssh_insecure">Key-Only Authentication is enabled :)</div>
|
||||
<br>
|
||||
</section>
|
||||
|
||||
<section v-if="views.section.status_share">
|
||||
Path Hosting:
|
||||
<ul>
|
||||
<li v-for="domain in status.pathHosting">
|
||||
|
@ -152,7 +165,9 @@
|
|||
<button>Add</button>
|
||||
</form>
|
||||
<br>
|
||||
</section>
|
||||
|
||||
<section v-if="views.section.status_host">
|
||||
Port Forwarding:
|
||||
<ul>
|
||||
<li v-for="domain in status.portForwards">
|
||||
|
@ -172,17 +187,23 @@
|
|||
<input v-model="newHttp.handler" type="number" placeholder="port (ex: 3000)" required>
|
||||
<button>Add</button>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
<br>
|
||||
Proctime: {{ statusProctime }}
|
||||
<br>
|
||||
Uptime: {{ statusUptime }}
|
||||
<br>
|
||||
Runtime: {{ statusRuntime }}
|
||||
<br>
|
||||
Reconnects: {{ status.reconnects }}
|
||||
|
||||
<details><summary><small>Advanced</small></summary>
|
||||
<button v-if="!status.enabled" v-on:click="enable">Enable Traffic</button>
|
||||
<button v-if="status.enabled" v-on:click="disable">Disable Traffic</button>
|
||||
<br>
|
||||
<br>
|
||||
|
||||
<pre><code>{{ status }}</code></pre>
|
||||
</details>
|
||||
</section>
|
||||
|
||||
</div>
|
||||
|
|
|
@ -247,6 +247,7 @@ var appMethods = {
|
|||
, deletePathHost: function (domain) {
|
||||
api.http(domain.name, 'none');
|
||||
}
|
||||
, changeState: changeState
|
||||
};
|
||||
var appStates = {
|
||||
setup: function () {
|
||||
|
@ -263,6 +264,51 @@ var appStates = {
|
|||
clearInterval(tok);
|
||||
}
|
||||
|
||||
var tok = setInterval(updateStatus, 2000);
|
||||
|
||||
return updateStatus().then(function () {
|
||||
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) {
|
||||
|
@ -275,6 +321,31 @@ var appStates = {
|
|||
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;
|
||||
|
@ -300,14 +371,6 @@ var appStates = {
|
|||
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 };
|
||||
return exitState;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
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);
|
||||
|
|
Loading…
Reference in New Issue