修正dashboard中的问题

This commit is contained in:
lwch
2021-11-18 23:42:16 +08:00
parent d30b27367f
commit b1cdccc8ec
6 changed files with 35 additions and 35 deletions
+2 -1
View File
@@ -62,4 +62,5 @@
# v0.6.3
1. bootstrap降版到4.6.1
2. dashboard页面支持隧道类型筛选
2. dashboard页面支持隧道类型筛选
3. **为遵守中国法律,移除内网穿透功能**
+1 -1
View File
@@ -38,7 +38,7 @@ func main() {
conf := flag.String("conf", "", "configure file path")
ver := flag.Bool("version", false, "show version info")
act := flag.String("action", "", "install or uninstall")
name := flag.String("name", "", "tunnel name")
name := flag.String("name", "", "rule name")
vport := flag.Uint("vport", 6155, "vnc worker listen port")
vcursor := flag.Bool("vcursor", false, "vnc show cursor")
flag.Parse()
+8 -9
View File
@@ -4,10 +4,10 @@
{{template "aside" .}}
<script>aside.active_dashboard();</script>
<style>
#label-tunnel-type {
#label-rule-type {
margin-right: 5px;
}
#tunnel-type {
#rule-type {
width: 200px;
display: inline-block;
}
@@ -32,19 +32,18 @@
<div class="row"><div class="col-12">
<div class="card">
<div class="card-header">
<h3 class="card-title">隧道列表</h3>
<h3 class="card-title">终端列表</h3>
</div>
<div class="card-body">
<div class="form-group">
<label id="label-tunnel-type" for="tunnel-type">类型:</label>
<select id="tunnel-type" class="form-control">
<label id="label-rule-type" for="rule-type">类型:</label>
<select id="rule-type" class="form-control">
<option value="all">全部</option>
<option value="reverse">reverse</option>
<option value="shell">shell</option>
<option value="vnc">vnc</option>
</select>
</div>
<table id="tunnels" class="table table-hover">
<table id="rules" class="table table-hover">
<thead><tr>
<th>名称</th>
<th style="width:200px">对端</th>
@@ -52,7 +51,7 @@
<th style="width:120px">虚拟连接数</th>
<th style="width:200px">接收/发送(字节数)</th>
<th style="width:200px">接收/发送(数据包)</th>
<th style="width:200px">操作</th>
<th style="width:120px">操作</th>
</tr></thead>
<tbody></tbody>
</table>
@@ -61,7 +60,7 @@
</div>
<!-- card -->
</div></div>
<!-- 隧道列表 -->
<!-- 终端列表 -->
</div>
<!-- container -->
</section>
+19 -19
View File
@@ -1,63 +1,63 @@
var page = {
init: function() {
$('#tunnel-type').change(page.render);
$('#rule-type').change(page.render);
page.render();
setInterval(page.render, 5000);
},
render: function() {
page.render_cards();
page.render_tunnels();
page.render_rules();
},
render_cards: function() {
$.get('/api/info', function(ret) {
$('#cards').empty();
page.add_card('隧道总数', ret.tunnels);
page.add_card('规则总数', ret.rules);
page.add_card('物理连接数', ret.physical_links);
page.add_card('虚拟连接数', ret.virtual_links);
page.add_card('终端会话', ret.sessions);
});
},
render_tunnels: function() {
$.get('/api/tunnels', function(ret) {
$('#tunnels tbody').empty();
var type = $('#tunnel-type').val();
$.each(ret, function(_, tunnel) {
if (type != 'all' && tunnel.type != type) {
render_rules: function() {
$.get('/api/rules', function(ret) {
$('#rules tbody').empty();
var type = $('#rule-type').val();
$.each(ret, function(_, rule) {
if (type != 'all' && rule.type != type) {
return;
}
var send_bytes = 0;
var send_packet = 0;
var recv_bytes = 0;
var recv_packet = 0;
$.each(tunnel.links, function(_, link) {
$.each(rule.links, function(_, link) {
send_bytes += link.send_bytes;
send_packet += link.send_packet;
recv_bytes += link.recv_bytes;
recv_packet += link.recv_packet;
});
var op = '';
switch (tunnel.type) {
switch (rule.type) {
case 'reverse':
op = `
<a href="http://${location.hostname}:${tunnel.port}" target="_blank">http</a>
<a href="https://${location.hostname}:${tunnel.port}" target="_blank">https</a>`;
<a href="http://${location.hostname}:${rule.port}" target="_blank">http</a>
<a href="https://${location.hostname}:${rule.port}" target="_blank">https</a>`;
break;
case 'shell':
case 'vnc':
op = `<a href="http://${location.host}/terminal.html?name=${tunnel.name}" target="_blank">连接</a>`;
op = `<a href="http://${location.host}/terminal.html?name=${rule.name}" target="_blank">连接</a>`;
break;
}
var str = `
<tr>
<td>${tunnel.name}</td>
<td>${tunnel.remote}</td>
<td>${tunnel.type}</td>
<td>${tunnel.links?tunnel.links.length:0}</td>
<td>${rule.name}</td>
<td>${rule.remote}</td>
<td>${rule.type}</td>
<td>${rule.links?rule.links.length:0}</td>
<td>${humanize.bytes(recv_bytes)}/${humanize.bytes(send_bytes)}</td>
<td>${recv_packet}/${send_packet}</td>
<td>${op}</td>
</tr>`;
$('#tunnels tbody').append($(str));
$('#rules tbody').append($(str));
});
});
},
+5 -5
View File
@@ -11,14 +11,14 @@ var page = {
},
load: function(cb) {
if (!cb) cb = function(){};
$.get('/api/tunnels', function(ret) {
$.get('/api/rules', function(ret) {
$('#terms').empty();
$.each(ret, function(_, tunnel) {
if (tunnel.type != 'shell' &&
tunnel.type != 'vnc') {
$.each(ret, function(_, rule) {
if (rule.type != 'shell' &&
rule.type != 'vnc') {
return;
}
$('#terms').append($(`<option value="${tunnel.port}">${tunnel.name}</option>`));
$('#terms').append($(`<option value="${rule.port}">${rule.name}</option>`));
});
cb();
});