Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
c7a56b1dde | |||
37446ea958 | |||
1b28b196a0 | |||
1a5ab341ab | |||
299ec93199 | |||
32f61a0eef |
@@ -80,14 +80,18 @@ func (DashboardApi) ConnectionList(c *gin.Context) {
|
|||||||
connections = append(connections, vo.DataTraffic{
|
connections = append(connections, vo.DataTraffic{
|
||||||
Name: clientInfo.Name,
|
Name: clientInfo.Name,
|
||||||
Email: clientInfo.Email,
|
Email: clientInfo.Email,
|
||||||
IpAllocation: clientInfo.IpAllocation,
|
IpAllocation: ipAllocation,
|
||||||
Online: time.Since(peer.LastHandshakeTime).Minutes() < 3,
|
Online: time.Since(peer.LastHandshakeTime).Minutes() < 3,
|
||||||
ReceiveBytes: utils.FlowCalculation().Parse(peer.TransmitBytes),
|
ReceiveBytes: utils.FlowCalculation().Parse(peer.TransmitBytes),
|
||||||
TransmitBytes: utils.FlowCalculation().Parse(peer.ReceiveBytes),
|
TransmitBytes: utils.FlowCalculation().Parse(peer.ReceiveBytes),
|
||||||
ConnectEndpoint: ipAllocation,
|
ConnectEndpoint: peer.Endpoint.String(),
|
||||||
LastHandAt: peer.LastHandshakeTime.Format("2006-01-02 15:04:05"),
|
LastHandAt: peer.LastHandshakeTime.Format("2006-01-02 15:04:05"),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(connections) <= 0 {
|
||||||
|
connections = []vo.DataTraffic{}
|
||||||
|
}
|
||||||
|
|
||||||
response.R(c).OkWithData(connections)
|
response.R(c).OkWithData(connections)
|
||||||
}
|
}
|
||||||
|
@@ -52,8 +52,8 @@ func RequestLog() gin.HandlerFunc {
|
|||||||
method := c.Request.Method // 请求方式
|
method := c.Request.Method // 请求方式
|
||||||
ip := c.ClientIP() // 取出IP
|
ip := c.ClientIP() // 取出IP
|
||||||
// 处理实际客户端IP
|
// 处理实际客户端IP
|
||||||
if c.Request.Header.Get("X-Real-IP") != "" {
|
if c.Request.Header.Get("X-Real-Ip") != "" {
|
||||||
ip = c.Request.Header.Get("X-Real-IP") // 这个是网关Nginx自定义的Header头
|
ip = c.Request.Header.Get("X-Real-Ip") // 这个是网关Nginx自定义的Header头
|
||||||
} else if c.Request.Header.Get("X-Forwarded-For") != "" {
|
} else if c.Request.Header.Get("X-Forwarded-For") != "" {
|
||||||
ip = c.Request.Header.Get("X-Forwarded-For") // 这个是网关Nginx自定义的Header头
|
ip = c.Request.Header.Get("X-Forwarded-For") // 这个是网关Nginx自定义的Header头
|
||||||
}
|
}
|
||||||
|
16
model/oauth_client.go
Normal file
16
model/oauth_client.go
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
// AuthClient
|
||||||
|
// @description: 认证客户端
|
||||||
|
type AuthClient struct {
|
||||||
|
Base
|
||||||
|
Name string `json:"name" gorm:"type:varchar(255);not null;comment: '客户端名称'"`
|
||||||
|
ClientID string `json:"clientID" gorm:"type:varchar(255);not null;comment: '客户端ID'"`
|
||||||
|
ClientKey string `json:"clientKey" gorm:"type:varchar(255);not null;comment: '客户端key'"`
|
||||||
|
ExpireAt string `json:"expireAt" gorm:"type:varchar(255);not null;comment: '过期时间'"`
|
||||||
|
IsEnabled int `json:"isEnabled" gorm:"type:int(1);not null;comment: '是否启用'"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (AuthClient) TableName() string {
|
||||||
|
return "t_oauth_client"
|
||||||
|
}
|
@@ -45,7 +45,7 @@ func (script) GenerateConfig() error {
|
|||||||
Email: client.Email,
|
Email: client.Email,
|
||||||
PublicKey: client.Keys.PublicKey,
|
PublicKey: client.Keys.PublicKey,
|
||||||
PresharedKey: client.Keys.PresharedKey,
|
PresharedKey: client.Keys.PresharedKey,
|
||||||
AllowedIPS: client.AllowedIpsStr,
|
AllowedIPS: client.IpAllocationStr,
|
||||||
Endpoint: client.Endpoint,
|
Endpoint: client.Endpoint,
|
||||||
CreateUser: client.CreateUser,
|
CreateUser: client.CreateUser,
|
||||||
Enabled: cast.ToBool(client.Enabled),
|
Enabled: cast.ToBool(client.Enabled),
|
||||||
|
Reference in New Issue
Block a user