simple ps

This commit is contained in:
csznet
2024-04-21 15:36:48 +08:00
parent 54980429be
commit 954807b7fe
3 changed files with 9 additions and 4 deletions

View File

@@ -102,30 +102,32 @@
<table> <table>
<thead> <thead>
<tr> <tr>
<th>ID</th> <!-- <th>ID</th> -->
<th>本地端口</th> <th>本地端口</th>
<th>远程地址</th> <th>远程地址</th>
<th>远程端口</th> <th>远程端口</th>
<th>类型</th> <th>类型</th>
<th>流量</th> <th>流量</th>
<th>操作</th> <th>操作</th>
<th>备注</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{{range .forwardList}} {{range .forwardList}}
<tr> <tr>
<td>{{.Id}}</td> <!-- <td>{{.Id}}</td> -->
<td>{{.LocalPort}}</td> <td>{{.LocalPort}}</td>
<td>{{.RemoteAddr}}</td> <td>{{.RemoteAddr}}</td>
<td>{{.RemotePort}}</td> <td>{{.RemotePort}}</td>
<td>{{.Protocol}}</td> <td>{{.Protocol}}</td>
<td>{{if gt .TotalGigabyte 0}}{{.TotalGigabyte}}G{{end}}{{.TotalBytes}}</td> <td id="data">{{if gt .TotalGigabyte 0}}{{.TotalGigabyte}}G{{end}}{{.TotalBytes}}</td>
<td> <td>
<div class="but-container"> <div class="but-container">
<a class="but" href="/del/{{.Id}}">删除</a> <a class="but" href="/del/{{.Id}}">删除</a>
<a class="but" style="background-color: #{{if eq .Status 0}}d93b3b{{else}}2181b5{{end}};" href="/do/{{.Id}}">{{if eq .Status 0}}停用{{else}}启用{{end}}</a> <a class="but" style="background-color: #{{if eq .Status 0}}d93b3b{{else}}2181b5{{end}};" href="/do/{{.Id}}">{{if eq .Status 0}}停用{{else}}启用{{end}}</a>
</div> </div>
</td> </td>
<td>{{.Ps}}</td>
</tr> </tr>
{{end}} {{end}}
</tbody> </tbody>
@@ -137,6 +139,7 @@
<input type="text" name="localPort" placeholder="本地端口" required> <input type="text" name="localPort" placeholder="本地端口" required>
<input type="text" name="remotePort" placeholder="远程端口" required> <input type="text" name="remotePort" placeholder="远程端口" required>
<input type="text" name="remoteAddr" placeholder="远程地址" required> <input type="text" name="remoteAddr" placeholder="远程地址" required>
<input type="text" name="ps" placeholder="备注信息">
<label for="protocol">类型:</label> <label for="protocol">类型:</label>
<select id="protocol" name="protocol" required> <select id="protocol" name="protocol" required>
<option value="tcp">TCP</option> <option value="tcp">TCP</option>
@@ -146,7 +149,7 @@
</form> </form>
<script> <script>
document.addEventListener('DOMContentLoaded', function () { document.addEventListener('DOMContentLoaded', function () {
const trafficCells = document.querySelectorAll('td:nth-child(6)'); // 选择所有流量单元格 const trafficCells = document.querySelectorAll('#data'); // 选择所有流量单元格
trafficCells.forEach(cell => { trafficCells.forEach(cell => {
let traffic = cell.textContent.trim(); let traffic = cell.textContent.trim();
let valueInBytes = 0; let valueInBytes = 0;

View File

@@ -8,6 +8,7 @@ import (
// ConnectionStats 结构体用于保存多个连接信息 // ConnectionStats 结构体用于保存多个连接信息
type ConnectionStats struct { type ConnectionStats struct {
Id int `gorm:"primaryKey;autoIncrement"` Id int `gorm:"primaryKey;autoIncrement"`
Ps string
LocalPort string LocalPort string
RemoteAddr string RemoteAddr string
RemotePort string RemotePort string

View File

@@ -39,6 +39,7 @@ func Run() {
RemotePort: c.PostForm("remotePort"), RemotePort: c.PostForm("remotePort"),
RemoteAddr: c.PostForm("remoteAddr"), RemoteAddr: c.PostForm("remoteAddr"),
Protocol: c.PostForm("protocol"), Protocol: c.PostForm("protocol"),
Ps: c.PostForm("ps"),
} }
if utils.AddForward(f) { if utils.AddForward(f) {
c.HTML(200, "msg.tmpl", gin.H{ c.HTML(200, "msg.tmpl", gin.H{