更新:1、依赖升级

2、module 名称地址
This commit is contained in:
2025-10-06 00:46:51 +08:00
parent 978a268f93
commit 44d4fcdbc4
11 changed files with 402 additions and 325 deletions

View File

@@ -6,7 +6,8 @@ import (
"strconv"
"strings"
"time"
"zhub/internal/auth"
"gitea.1216.top/lxy/zhub/internal/auth"
)
var AuthManager *auth.PermissionManager
@@ -156,7 +157,7 @@ func messageHandler(v Message) {
}
return
case "broadcast":
Bus.broadcast(rcmd[1], rcmd[2])
Bus.Broadcast(rcmd[1], rcmd[2])
case "delay":
Bus.Delay(rcmd)
default:

View File

@@ -12,7 +12,8 @@ import (
"sync/atomic"
"time"
"unicode/utf8"
"zhub/internal/config"
"gitea.1216.top/lxy/zhub/internal/config"
)
var (
@@ -387,9 +388,9 @@ func (s *ZBus) Publish(topic, msg string) {
}
/*
send broadcast message
send Broadcast message
*/
func (s *ZBus) broadcast(topic, msg string) {
func (s *ZBus) Broadcast(topic, msg string) {
s.RLock()
defer s.RUnlock()
if strings.EqualFold(topic, "lock") {
@@ -422,7 +423,7 @@ func (s *ZBus) _lock(lock *Lock) {
lock.start = time.Now().Unix()
locks = append(locks, lock)
s.locks[lock.key] = locks
s.broadcast("lock", lock.uuid)
s.Broadcast("lock", lock.uuid)
// 设置时间到解锁
locks[0].timer = time.NewTimer(time.Duration(locks[0].duration) * time.Second)
@@ -435,7 +436,7 @@ func (s *ZBus) _lock(lock *Lock) {
} else {
switch lock.cmd {
case "trylock": // send trylock fail message
s.broadcast("trylock", lock.uuid)
s.Broadcast("trylock", lock.uuid)
case "lock":
s.locks[lock.key] = append(locks, lock)
}
@@ -452,7 +453,7 @@ func (s *ZBus) _unlock(l Lock) {
s.locks[l.key] = locks
}
if len(s.locks[l.key]) > 0 { // next lock
s.broadcast("lock", s.locks[l.key][0].uuid)
s.Broadcast("lock", s.locks[l.key][0].uuid)
s.locks[l.key][0].start = time.Now().Unix()
s.locks[l.key][0].timer = time.NewTimer(time.Duration(s.locks[l.key][0].duration) * time.Second)
go func() {