🎨加了些注释
This commit is contained in:
parent
864cf2f3f8
commit
49a851ac92
@ -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())
|
||||
|
@ -6,6 +6,12 @@ func Paginate() paginate {
|
||||
return paginate{}
|
||||
}
|
||||
|
||||
// Generate
|
||||
// @description: 生成页码
|
||||
// @receiver paginate
|
||||
// @param count
|
||||
// @param size
|
||||
// @return int
|
||||
func (paginate) Generate(count int64, size int) int {
|
||||
totalPage := 0
|
||||
if count > 0 {
|
||||
|
@ -12,6 +12,11 @@ func Random() random {
|
||||
return random{}
|
||||
}
|
||||
|
||||
// RandStr
|
||||
// @description: 随机字符串
|
||||
// @receiver random
|
||||
// @param len
|
||||
// @return string
|
||||
func (random) RandStr(len int) string {
|
||||
var container string
|
||||
var str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"
|
||||
|
@ -7,6 +7,12 @@ type website struct{}
|
||||
func WebSite() website {
|
||||
return website{}
|
||||
}
|
||||
|
||||
// GetHost
|
||||
// @description: 获取主机host
|
||||
// @receiver website
|
||||
// @param addr
|
||||
// @return string
|
||||
func (website) GetHost(addr string) string {
|
||||
uu, err := url.Parse(addr)
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user