mirror of
https://github.com/wyx2685/V2bX.git
synced 2026-02-04 04:30:08 +00:00
fix user tag
This commit is contained in:
@@ -3,6 +3,7 @@ package hy
|
||||
import (
|
||||
"encoding/base64"
|
||||
"errors"
|
||||
"github.com/Yuzuki616/V2bX/api/panel"
|
||||
"github.com/Yuzuki616/V2bX/core"
|
||||
)
|
||||
|
||||
@@ -30,15 +31,15 @@ func (h *Hy) GetUserTraffic(tag, uuid string, reset bool) (up int64, down int64)
|
||||
return
|
||||
}
|
||||
|
||||
func (h *Hy) DelUsers(users []string, tag string) error {
|
||||
func (h *Hy) DelUsers(users []panel.UserInfo, 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])
|
||||
s.users.Delete(users[i].Uuid)
|
||||
s.counter.Delete(base64.StdEncoding.EncodeToString([]byte(users[i].Uuid)))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -18,6 +18,6 @@ type Core interface {
|
||||
DelNode(tag string) error
|
||||
AddUsers(p *AddUsersParams) (added int, err error)
|
||||
GetUserTraffic(tag, uuid string, reset bool) (up int64, down int64)
|
||||
DelUsers(users []string, tag string) error
|
||||
DelUsers(users []panel.UserInfo, tag string) error
|
||||
Protocols() []string
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ func (s *Selector) GetUserTraffic(tag, uuid string, reset bool) (up int64, down
|
||||
return s.cores[t.(int)].GetUserTraffic(tag, uuid, reset)
|
||||
}
|
||||
|
||||
func (s *Selector) DelUsers(users []string, tag string) error {
|
||||
func (s *Selector) DelUsers(users []panel.UserInfo, tag string) error {
|
||||
t, e := s.nodes.Load(tag)
|
||||
if !e {
|
||||
return errors.New("the node is not have")
|
||||
|
||||
@@ -3,6 +3,7 @@ package xray
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/Yuzuki616/V2bX/api/panel"
|
||||
"github.com/Yuzuki616/V2bX/common/builder"
|
||||
vCore "github.com/Yuzuki616/V2bX/core"
|
||||
"github.com/xtls/xray-core/common/protocol"
|
||||
@@ -25,13 +26,13 @@ func (c *Core) GetUserManager(tag string) (proxy.UserManager, error) {
|
||||
return userManager, nil
|
||||
}
|
||||
|
||||
func (c *Core) DelUsers(users []string, tag string) error {
|
||||
func (c *Core) DelUsers(users []panel.UserInfo, tag string) error {
|
||||
userManager, err := c.GetUserManager(tag)
|
||||
if err != nil {
|
||||
return fmt.Errorf("get user manager error: %s", err)
|
||||
}
|
||||
for _, email := range users {
|
||||
err = userManager.RemoveUser(context.Background(), email)
|
||||
for i := range users {
|
||||
err = userManager.RemoveUser(context.Background(), builder.BuildUserTag(tag, users[i].Uuid))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user