新增本地用户设置过期时间

This commit is contained in:
wsczx
2022-10-16 02:47:32 +08:00
parent 7b83154245
commit a533ee0a78
8 changed files with 56 additions and 4 deletions

View File

@@ -13,6 +13,7 @@ import (
"github.com/bjdgyc/anylink/base"
"github.com/bjdgyc/anylink/dbdata"
"github.com/bjdgyc/anylink/pkg/utils"
mapset "github.com/deckarep/golang-set"
"github.com/ivpusic/grpool"
atomic2 "go.uber.org/atomic"
)
@@ -113,6 +114,21 @@ func checkSession() {
}()
}
// 状态为过期的用户踢下线
func CloseUserLimittimeSession() {
y := dbdata.CheckUserlimittime()
s := mapset.NewSetFromSlice(y)
for k, v := range sessions {
sessMux.Lock()
v.mux.Lock()
if !v.IsActive && s.Contains(v.Username) {
delete(sessions, k)
}
v.mux.Unlock()
sessMux.Unlock()
}
}
func GenToken() string {
// 生成32位的 token
bToken := make([]byte, 32)