Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
0964384b52 | |||
cbe1188e51 |
@@ -23,16 +23,6 @@ func offlineMonitoring() {
|
|||||||
// 遍历客户端数据,并渲染数据信息
|
// 遍历客户端数据,并渲染数据信息
|
||||||
for _, d := range devices {
|
for _, d := range devices {
|
||||||
for _, p := range d.Peers {
|
for _, p := range d.Peers {
|
||||||
clientInfo, err := repository.Client().GetByPublicKey(p.PublicKey.String())
|
|
||||||
if err != nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
// 没有启用离线监听时,即使客户端已经离线则也不执行
|
|
||||||
if clientInfo.OfflineMonitoring == nil || *clientInfo.OfflineMonitoring != 1 || clientInfo.Email == "" {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
var ipAllocation string
|
var ipAllocation string
|
||||||
for _, iaip := range p.AllowedIPs {
|
for _, iaip := range p.AllowedIPs {
|
||||||
ipAllocation += iaip.String() + ","
|
ipAllocation += iaip.String() + ","
|
||||||
@@ -45,6 +35,16 @@ func offlineMonitoring() {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clientInfo, err := repository.Client().GetByPublicKey(p.PublicKey.String())
|
||||||
|
if err != nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
// 没有启用离线监听时,即使客户端已经离线则也不执行
|
||||||
|
if clientInfo.OfflineMonitoring == nil || *clientInfo.OfflineMonitoring != 1 || clientInfo.Email == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
content := fmt.Sprintf("客户端:%s\r\n", clientInfo.Name)
|
content := fmt.Sprintf("客户端:%s\r\n", clientInfo.Name)
|
||||||
content += fmt.Sprintf("客户端IP:%s\r\n", ipAllocation)
|
content += fmt.Sprintf("客户端IP:%s\r\n", ipAllocation)
|
||||||
content += fmt.Sprintf("端点IP:%s\r\n", p.Endpoint.String())
|
content += fmt.Sprintf("端点IP:%s\r\n", p.Endpoint.String())
|
||||||
|
@@ -72,9 +72,9 @@ func initDatabase() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
logLevel := gl.Info
|
logLevel := gl.Info
|
||||||
if os.Getenv("GIN_MODE") == "release" {
|
//if os.Getenv("GIN_MODE") == "release" {
|
||||||
logLevel = gl.Error
|
// logLevel = gl.Error
|
||||||
}
|
//}
|
||||||
|
|
||||||
db, err := gorm.Open(dbDialector, &gorm.Config{
|
db, err := gorm.Open(dbDialector, &gorm.Config{
|
||||||
Logger: logger.NewGormLoggerWithConfig(gl.Config{
|
Logger: logger.NewGormLoggerWithConfig(gl.Config{
|
||||||
|
3
main.go
3
main.go
@@ -7,7 +7,6 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
"wireguard-dashboard/config"
|
"wireguard-dashboard/config"
|
||||||
"wireguard-dashboard/cron_task"
|
|
||||||
"wireguard-dashboard/initialize"
|
"wireguard-dashboard/initialize"
|
||||||
"wireguard-dashboard/queues"
|
"wireguard-dashboard/queues"
|
||||||
"wireguard-dashboard/route"
|
"wireguard-dashboard/route"
|
||||||
@@ -20,7 +19,7 @@ func init() {
|
|||||||
log.Errorf("执行脚本失败: %v", err.Error())
|
log.Errorf("执行脚本失败: %v", err.Error())
|
||||||
}
|
}
|
||||||
go queues.StartConsumer() // 启动队列
|
go queues.StartConsumer() // 启动队列
|
||||||
go cron_task.StartCronTask() // 启动定时任务
|
//go cron_task.StartCronTask() // 启动定时任务
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
Reference in New Issue
Block a user