This commit is contained in:
parent
a424a5e0b3
commit
8dab976cba
@ -13,12 +13,11 @@ import (
|
||||
// offlineMonitoring
|
||||
// @description: 离线监听任务
|
||||
func offlineMonitoring() {
|
||||
for {
|
||||
devices, err := client.WireguardClient.Devices()
|
||||
if err != nil {
|
||||
time.Sleep(5 * time.Minute) // 休眠五分钟再执行
|
||||
offlineMonitoring()
|
||||
continue
|
||||
return
|
||||
}
|
||||
|
||||
// 遍历客户端数据,并渲染数据信息
|
||||
@ -48,9 +47,8 @@ func offlineMonitoring() {
|
||||
|
||||
content := fmt.Sprintf("客户端:%s\r\n", clientInfo.Name)
|
||||
content += fmt.Sprintf("客户端IP:%s\r\n", ipAllocation)
|
||||
content += fmt.Sprintf("端点IP:%s", p.Endpoint.String())
|
||||
content += fmt.Sprintf("端点IP:%s\r\n", p.Endpoint.String())
|
||||
content += fmt.Sprintf("最后握手时间:%s\r\n", p.LastHandshakeTime.Format("2006-01-02 15:04:05"))
|
||||
content += fmt.Sprintf("离线时间:%s\r\n", time.Now().Format("2006-01-02 15:04:05"))
|
||||
|
||||
// 离线并且配置了邮箱,准备发送邮件
|
||||
err = utils.Mail().SendMail(clientInfo.Email, fmt.Sprintf("客户端离线通知"), content, "")
|
||||
@ -61,5 +59,5 @@ func offlineMonitoring() {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
3
main.go
3
main.go
@ -7,7 +7,6 @@ import (
|
||||
"net/http"
|
||||
"time"
|
||||
"wireguard-dashboard/config"
|
||||
"wireguard-dashboard/cron_task"
|
||||
"wireguard-dashboard/initialize"
|
||||
"wireguard-dashboard/queues"
|
||||
"wireguard-dashboard/route"
|
||||
@ -20,7 +19,7 @@ func init() {
|
||||
log.Errorf("执行脚本失败: %v", err.Error())
|
||||
}
|
||||
go queues.StartConsumer() // 启动队列
|
||||
go cron_task.StartCronTask() // 启动定时任务
|
||||
//go cron_task.StartCronTask() // 启动定时任务
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
Loading…
Reference in New Issue
Block a user