mirror of
https://github.com/wyx2685/V2bX.git
synced 2026-02-04 04:30:08 +00:00
fix some bugs
support ip limit for hy
This commit is contained in:
30
node/user.go
30
node/user.go
@@ -2,9 +2,39 @@ package node
|
||||
|
||||
import (
|
||||
"github.com/Yuzuki616/V2bX/api/panel"
|
||||
"log"
|
||||
"runtime"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func (c *Controller) reportUserTrafficTask() (err error) {
|
||||
// Get User traffic
|
||||
userTraffic := make([]panel.UserTraffic, 0)
|
||||
for i := range c.userList {
|
||||
up, down := c.server.GetUserTraffic(c.Tag, c.userList[i].Uuid, true)
|
||||
if up > 0 || down > 0 {
|
||||
if c.LimitConfig.EnableDynamicSpeedLimit {
|
||||
c.userList[i].Traffic += up + down
|
||||
}
|
||||
userTraffic = append(userTraffic, panel.UserTraffic{
|
||||
UID: (c.userList)[i].Id,
|
||||
Upload: up,
|
||||
Download: down})
|
||||
}
|
||||
}
|
||||
if len(userTraffic) > 0 && !c.DisableUploadTraffic {
|
||||
err = c.apiClient.ReportUserTraffic(userTraffic)
|
||||
if err != nil {
|
||||
log.Printf("Report user traffic faild: %s", err)
|
||||
} else {
|
||||
log.Printf("[%s] Report %d online users", c.Tag, len(userTraffic))
|
||||
}
|
||||
}
|
||||
userTraffic = nil
|
||||
runtime.GC()
|
||||
return nil
|
||||
}
|
||||
|
||||
func compareUserList(old, new []panel.UserInfo) (deleted, added []panel.UserInfo) {
|
||||
tmp := map[string]struct{}{}
|
||||
tmp2 := map[string]struct{}{}
|
||||
|
||||
Reference in New Issue
Block a user