mirror of
https://github.com/wyx2685/V2bX.git
synced 2026-02-04 20:50:09 +00:00
update
initial support for hysteria update config update api change user email format ...
This commit is contained in:
42
core/hy/user.go
Normal file
42
core/hy/user.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package hy
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"github.com/Yuzuki616/V2bX/core"
|
||||
)
|
||||
|
||||
func (h *Hy) AddUsers(p *core.AddUsersParams) (int, error) {
|
||||
s, ok := h.servers.Load(p.Tag)
|
||||
if !ok {
|
||||
return 0, errors.New("the node not have")
|
||||
}
|
||||
u := &s.(*Server).users
|
||||
for i := range p.UserInfo {
|
||||
u.Store(p.UserInfo[i].Uuid, struct{}{})
|
||||
}
|
||||
return len(p.UserInfo), nil
|
||||
}
|
||||
|
||||
func (h *Hy) GetUserTraffic(tag, uuid string, reset bool) (up int64, down int64) {
|
||||
s, _ := h.servers.Load(tag)
|
||||
c := &s.(*Server).counter
|
||||
up = c.getCounters(uuid).UpCounter.Load()
|
||||
down = c.getCounters(uuid).DownCounter.Load()
|
||||
if reset {
|
||||
c.Reset(uuid)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (h *Hy) DelUsers(users []string, tag string) error {
|
||||
v, e := h.servers.Load(tag)
|
||||
if !e {
|
||||
return errors.New("the node is not have")
|
||||
}
|
||||
s := v.(*Server)
|
||||
for i := range users {
|
||||
s.users.Delete(users[i])
|
||||
s.counter.Delete(users[i])
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user