Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
ddef41dfca | ||
6c6b40593e | |||
45d83da5c7 | |||
4fa123baa8 | |||
c7a56b1dde | |||
37446ea958 | |||
1b28b196a0 | |||
1a5ab341ab | |||
299ec93199 | |||
32f61a0eef |
56
.gitignore
vendored
56
.gitignore
vendored
@@ -233,33 +233,33 @@ fabric.properties
|
||||
# vendor/
|
||||
|
||||
# Go workspace file
|
||||
go.work
|
||||
./go.work
|
||||
|
||||
.idea
|
||||
web/.idea
|
||||
./.idea
|
||||
./web/.idea
|
||||
|
||||
web/node_modules
|
||||
web/.DS_Store
|
||||
web/dist
|
||||
web/dist-ssr
|
||||
web/*.local
|
||||
web/.eslintcache
|
||||
web/report.html
|
||||
web/vite.config.*.timestamp*
|
||||
./web/node_modules
|
||||
./web/.DS_Store
|
||||
./web/dist
|
||||
./web/dist-ssr
|
||||
./web/*.local
|
||||
./web/.eslintcache
|
||||
./web/report.html
|
||||
./web/vite.config.*.timestamp*
|
||||
|
||||
web/yarn.lock
|
||||
web/npm-debug.log*
|
||||
web/.pnpm-error.log*
|
||||
web/.pnpm-debug.log
|
||||
web/tests/**/coverage/
|
||||
web/.vscode/
|
||||
./web/yarn.lock
|
||||
./web/npm-debug.log*
|
||||
./web/.pnpm-error.log*
|
||||
./web/.pnpm-debug.log
|
||||
./web/tests/**/coverage/
|
||||
./web/.vscode/
|
||||
|
||||
# Editor directories and files
|
||||
web/*.suo
|
||||
web/*.ntvs*
|
||||
web/*.njsproj
|
||||
web/*.sln
|
||||
web/tsconfig.tsbuildinfo
|
||||
./web/*.suo
|
||||
./web/*.ntvs*
|
||||
./web/*.njsproj
|
||||
./web/*.sln
|
||||
./web/tsconfig.tsbuildinfo
|
||||
|
||||
dist/assets
|
||||
dist/resource
|
||||
@@ -267,10 +267,10 @@ dist/favicon.png
|
||||
dist/favicon.svg
|
||||
dist/index.html
|
||||
|
||||
template/tmp/*
|
||||
logs/*
|
||||
app.yaml
|
||||
*.db
|
||||
.env
|
||||
*.env
|
||||
./template/tmp/*
|
||||
./logs/*
|
||||
./app.yaml
|
||||
./*.db
|
||||
./.env
|
||||
./*.env
|
||||
|
||||
|
@@ -3,6 +3,7 @@ package api
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
"strings"
|
||||
"time"
|
||||
"wireguard-ui/component"
|
||||
"wireguard-ui/http/param"
|
||||
@@ -77,17 +78,25 @@ func (DashboardApi) ConnectionList(c *gin.Context) {
|
||||
for _, iaip := range peer.AllowedIPs {
|
||||
ipAllocation += iaip.String() + ","
|
||||
}
|
||||
// 去除一下最右边的逗号
|
||||
if len(ipAllocation) > 0 {
|
||||
ipAllocation = strings.TrimRight(ipAllocation, ",")
|
||||
}
|
||||
connections = append(connections, vo.DataTraffic{
|
||||
Name: clientInfo.Name,
|
||||
Email: clientInfo.Email,
|
||||
IpAllocation: clientInfo.IpAllocation,
|
||||
IpAllocation: ipAllocation,
|
||||
Online: time.Since(peer.LastHandshakeTime).Minutes() < 3,
|
||||
ReceiveBytes: utils.FlowCalculation().Parse(peer.TransmitBytes),
|
||||
TransmitBytes: utils.FlowCalculation().Parse(peer.ReceiveBytes),
|
||||
ConnectEndpoint: ipAllocation,
|
||||
ConnectEndpoint: peer.Endpoint.String(),
|
||||
LastHandAt: peer.LastHandshakeTime.Format("2006-01-02 15:04:05"),
|
||||
})
|
||||
}
|
||||
|
||||
if len(connections) <= 0 {
|
||||
connections = []vo.DataTraffic{}
|
||||
}
|
||||
|
||||
response.R(c).OkWithData(connections)
|
||||
}
|
||||
|
@@ -50,13 +50,13 @@ func Authorization() gin.HandlerFunc {
|
||||
// 查询用户
|
||||
user, err := service.User().GetUserById(userClaims.ID)
|
||||
if err != nil {
|
||||
response.R(c).FailedWithError("用户不存在")
|
||||
response.R(c).AuthorizationFailed("用户不存在")
|
||||
c.Abort()
|
||||
return
|
||||
}
|
||||
|
||||
if user.Status != constant.Enabled {
|
||||
response.R(c).FailedWithError("用户状态异常,请联系管理员处理!")
|
||||
response.R(c).AuthorizationFailed("用户状态异常,请联系管理员处理!")
|
||||
c.Abort()
|
||||
return
|
||||
}
|
||||
|
@@ -52,8 +52,8 @@ func RequestLog() gin.HandlerFunc {
|
||||
method := c.Request.Method // 请求方式
|
||||
ip := c.ClientIP() // 取出IP
|
||||
// 处理实际客户端IP
|
||||
if c.Request.Header.Get("X-Real-IP") != "" {
|
||||
ip = c.Request.Header.Get("X-Real-IP") // 这个是网关Nginx自定义的Header头
|
||||
if c.Request.Header.Get("X-Real-Ip") != "" {
|
||||
ip = c.Request.Header.Get("X-Real-Ip") // 这个是网关Nginx自定义的Header头
|
||||
} else if c.Request.Header.Get("X-Forwarded-For") != "" {
|
||||
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,
|
||||
PublicKey: client.Keys.PublicKey,
|
||||
PresharedKey: client.Keys.PresharedKey,
|
||||
AllowedIPS: client.AllowedIpsStr,
|
||||
AllowedIPS: client.IpAllocationStr,
|
||||
Endpoint: client.Endpoint,
|
||||
CreateUser: client.CreateUser,
|
||||
Enabled: cast.ToBool(client.Enabled),
|
||||
|
@@ -37,7 +37,6 @@ export async function addDynamicRoutes() {
|
||||
// 有token的情况
|
||||
const userStore = useUserStore()
|
||||
try {
|
||||
|
||||
const permissionStore = usePermissionStore()
|
||||
!userStore.id && (await userStore.getUserInfo())
|
||||
|
||||
@@ -49,8 +48,8 @@ export async function addDynamicRoutes() {
|
||||
router.addRoute(NOT_FOUND_ROUTE)
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
$message.error('初始化用户信息失败: ' + error)
|
||||
userStore.logout()
|
||||
$message.error('初始化用户信息失败: ' + error)
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -6,6 +6,7 @@ export default {
|
||||
component: Layout,
|
||||
redirect: '/client',
|
||||
meta: {
|
||||
title: '客户端',
|
||||
order: 2,
|
||||
},
|
||||
children: [
|
||||
|
@@ -6,6 +6,7 @@ export default {
|
||||
component: Layout,
|
||||
redirect: '/setting',
|
||||
meta: {
|
||||
title: '设置',
|
||||
order: 3,
|
||||
},
|
||||
children: [
|
||||
|
@@ -6,6 +6,7 @@ export default {
|
||||
component: Layout,
|
||||
redirect: '/user',
|
||||
meta: {
|
||||
title: '管理员',
|
||||
order: 1,
|
||||
},
|
||||
children: [
|
||||
|
@@ -6,6 +6,7 @@ export default {
|
||||
component: Layout,
|
||||
redirect: '/workbench',
|
||||
meta: {
|
||||
title: '工作台',
|
||||
order: 0,
|
||||
},
|
||||
children: [
|
||||
|
4838
web/stats.html
Normal file
4838
web/stats.html
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user