fix user tag

This commit is contained in:
yuzuki999
2023-06-19 10:31:42 +08:00
parent adf5c60c2a
commit 95a141ef59
9 changed files with 16 additions and 38 deletions

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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")

View File

@@ -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
}