Fix25.1: стабилизирован auth_id flow и unlimited-семантика, усилен bootstrap secrets
This commit is contained in:
+16
-14
@@ -83,10 +83,7 @@ func saveAccountTraffic(apiPort int64, trafficStatsSecret string) {
|
||||
|
||||
peer, peerErr := dao.GetPeer("auth_id = ?", key)
|
||||
if peerErr != nil {
|
||||
peer, peerErr = dao.GetPeer("name = ?", key)
|
||||
if peerErr != nil {
|
||||
continue
|
||||
}
|
||||
continue
|
||||
}
|
||||
if peer.Id == nil {
|
||||
continue
|
||||
@@ -133,32 +130,37 @@ func kickAccount(apiPort int64, trafficStatsSecret string) {
|
||||
}
|
||||
if len(users) > 0 {
|
||||
i := 0
|
||||
usernames := make([]string, len(users))
|
||||
authIDs := make([]string, len(users))
|
||||
for k := range users {
|
||||
usernames[i] = k
|
||||
authIDs[i] = k
|
||||
i++
|
||||
}
|
||||
usernameLists := util.SplitArr(usernames, 10)
|
||||
authIDLists := util.SplitArr(authIDs, 10)
|
||||
var wg sync.WaitGroup
|
||||
for _, usernameList := range usernameLists {
|
||||
for _, authIDList := range authIDLists {
|
||||
wg.Add(1)
|
||||
go func(usernameList []string) {
|
||||
go func(authIDList []string) {
|
||||
defer wg.Done()
|
||||
now := time.Now().UnixMilli()
|
||||
peers, err := dao.ListPeer("name in ? and (disabled = 1 or (quota_bytes > 0 and quota_bytes < download_bytes + upload_bytes) or ? > expires_at or ? < banned_until)", usernameList, now, now)
|
||||
peers, err := dao.ListPeer(`auth_id in ? and (
|
||||
disabled = 1
|
||||
or (quota_bytes > 0 and quota_bytes < download_bytes + upload_bytes)
|
||||
or (expires_at > 0 and ? > expires_at)
|
||||
or ? < banned_until
|
||||
)`, authIDList, now, now)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
kickUsernames := make([]string, len(peers))
|
||||
kickAuthIDs := make([]string, len(peers))
|
||||
j := 0
|
||||
for _, item := range peers {
|
||||
kickUsernames[j] = *item.Name
|
||||
kickAuthIDs[j] = *item.AuthId
|
||||
j++
|
||||
}
|
||||
if err = proxy.NewHysteria2Api(apiPort).KickUsers(kickUsernames, trafficStatsSecret); err != nil {
|
||||
if err = proxy.NewHysteria2Api(apiPort).KickUsers(kickAuthIDs, trafficStatsSecret); err != nil {
|
||||
return
|
||||
}
|
||||
}(usernameList)
|
||||
}(authIDList)
|
||||
}
|
||||
wg.Wait()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user