🎨加了些注释
This commit is contained in:
@@ -44,6 +44,7 @@ func (ClientApi) Save(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
component.Wireguard().ServerControl("E:\\Workspace\\Go\\wireguard-ui\\template\\tmp\\wg0.conf")
|
||||
response.R(c).OK()
|
||||
}
|
||||
|
||||
@@ -63,6 +64,7 @@ func (ClientApi) Delete(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
component.Wireguard().ServerControl("E:\\Workspace\\Go\\wireguard-ui\\template\\tmp\\wg0.conf")
|
||||
response.R(c).OK()
|
||||
}
|
||||
|
||||
|
@@ -60,32 +60,13 @@ func (DashboardApi) DailyPoetry(c *gin.Context) {
|
||||
// @receiver DashboardApi
|
||||
// @param c
|
||||
func (DashboardApi) ConnectionList(c *gin.Context) {
|
||||
var connections []vo.DataTraffic
|
||||
peers, err := component.Wireguard().GetClients()
|
||||
if err != nil {
|
||||
if len(connections) == 0 {
|
||||
for i := 0; i < 10; i++ {
|
||||
var online bool
|
||||
if i%2 == 0 {
|
||||
online = true
|
||||
}
|
||||
connections = append(connections, vo.DataTraffic{
|
||||
Name: fmt.Sprintf("客户端: %d", i+1),
|
||||
Email: fmt.Sprintf("%d@qq.com", i+1),
|
||||
IpAllocation: fmt.Sprintf("10.100.25.%d/32", i+1),
|
||||
Online: online,
|
||||
ReceiveBytes: utils.FlowCalculation().Parse(12212),
|
||||
TransmitBytes: utils.FlowCalculation().Parse(322212),
|
||||
ConnectEndpoint: "1.14.30.133",
|
||||
LastHandAt: time.Now().Format("2006-01-02 15:04:05"),
|
||||
})
|
||||
}
|
||||
response.R(c).OkWithData(connections)
|
||||
return
|
||||
}
|
||||
response.R(c).FailedWithError("获取失败")
|
||||
return
|
||||
}
|
||||
|
||||
var connections []vo.DataTraffic
|
||||
for _, peer := range peers {
|
||||
// 获取客户端链接信息
|
||||
clientInfo, err := service.Client().GetByPublicKey(peer.PublicKey.String())
|
||||
|
Reference in New Issue
Block a user