mirror of
https://github.com/lwch/natpass.git
synced 2024-04-21 12:41:54 +00:00
修改隧道列表,增加远端名称字段
This commit is contained in:
@@ -15,15 +15,17 @@ func (db *Dashboard) Tunnels(w http.ResponseWriter, r *http.Request) {
|
||||
RecvPacket uint64 `json:"recv_packet"`
|
||||
}
|
||||
type item struct {
|
||||
Name string `json:"name"`
|
||||
Port uint16 `json:"port"`
|
||||
Type string `json:"type"`
|
||||
Links []link `json:"links"`
|
||||
Name string `json:"name"`
|
||||
Remote string `json:"remote"`
|
||||
Port uint16 `json:"port"`
|
||||
Type string `json:"type"`
|
||||
Links []link `json:"links"`
|
||||
}
|
||||
var ret []item
|
||||
db.mgr.Range(func(t tunnel.Tunnel) {
|
||||
var it item
|
||||
it.Name = t.GetName()
|
||||
it.Remote = t.GetRemote()
|
||||
it.Port = t.GetPort()
|
||||
it.Type = t.GetTypeName()
|
||||
for _, l := range t.GetLinks() {
|
||||
|
||||
@@ -13,6 +13,7 @@ type Link interface {
|
||||
// Tunnel tunnel interface
|
||||
type Tunnel interface {
|
||||
GetName() string
|
||||
GetRemote() string
|
||||
GetPort() uint16
|
||||
GetTypeName() string
|
||||
GetTarget() string
|
||||
|
||||
@@ -54,6 +54,11 @@ func (t *Tunnel) GetLinks() []tunnel.Link {
|
||||
return ret
|
||||
}
|
||||
|
||||
// GetRemote get remote target name
|
||||
func (t *Tunnel) GetRemote() string {
|
||||
return t.cfg.Target
|
||||
}
|
||||
|
||||
// GetPort get listen port
|
||||
func (t *Tunnel) GetPort() uint16 {
|
||||
return t.cfg.LocalPort
|
||||
|
||||
@@ -55,6 +55,11 @@ func (shell *Shell) GetLinks() []tunnel.Link {
|
||||
return ret
|
||||
}
|
||||
|
||||
// GetRemote get remote target name
|
||||
func (shell *Shell) GetRemote() string {
|
||||
return shell.cfg.Target
|
||||
}
|
||||
|
||||
// GetPort get listen port
|
||||
func (shell *Shell) GetPort() uint16 {
|
||||
return shell.cfg.LocalPort
|
||||
|
||||
@@ -30,7 +30,8 @@
|
||||
<table id="tunnels" class="table table-hover">
|
||||
<thead><tr>
|
||||
<th>名称</th>
|
||||
<th style="width:80px">类型</th>
|
||||
<th style="width:200px">对端</th>
|
||||
<th style="width:120px">类型</th>
|
||||
<th style="width:120px">虚拟连接数</th>
|
||||
<th style="width:200px">接收/发送(字节数)</th>
|
||||
<th style="width:200px">接收/发送(数据包)</th>
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
var page = {
|
||||
init: function() {
|
||||
page.render();
|
||||
setInterval(page.render, 5000);
|
||||
},
|
||||
render: function() {
|
||||
page.render_cards();
|
||||
page.render_tunnels();
|
||||
},
|
||||
render_cards: function() {
|
||||
$.get('/api/info', function(ret) {
|
||||
$('#cards').empty();
|
||||
page.add_card('隧道总数', ret.tunnels);
|
||||
page.add_card('物理连接数', ret.physical_links);
|
||||
page.add_card('虚拟连接数', ret.virtual_links);
|
||||
@@ -13,6 +18,7 @@ var page = {
|
||||
},
|
||||
render_tunnels: function() {
|
||||
$.get('/api/tunnels', function(ret) {
|
||||
$('#tunnels tbody').empty();
|
||||
$.each(ret, function(_, tunnel) {
|
||||
var send_bytes = 0;
|
||||
var send_packet = 0;
|
||||
@@ -33,6 +39,7 @@ var page = {
|
||||
var str = `
|
||||
<tr>
|
||||
<td>${tunnel.name}</td>
|
||||
<td>${tunnel.remote}</td>
|
||||
<td>${tunnel.type}</td>
|
||||
<td>${tunnel.links?tunnel.links.length:0}</td>
|
||||
<td>${humanize.bytes(recv_bytes)}/${humanize.bytes(send_bytes)}</td>
|
||||
|
||||
Reference in New Issue
Block a user