This commit is contained in:
yuzuki999
2022-08-12 18:44:56 +08:00
parent c0e0945c8b
commit f00682e58e
4 changed files with 17 additions and 22 deletions

View File

@@ -5,10 +5,8 @@ import (
"fmt"
"github.com/Yuzuki616/V2bX/api"
"github.com/Yuzuki616/V2bX/app/limiter"
"github.com/Yuzuki616/V2bX/core/app/dispatcher"
"github.com/xtls/xray-core/core"
"github.com/xtls/xray-core/features/inbound"
"github.com/xtls/xray-core/features/routing"
)
func (p *Core) RemoveInbound(tag string) error {
@@ -32,14 +30,12 @@ func (p *Core) AddInbound(config *core.InboundHandlerConfig) error {
}
func (p *Core) AddInboundLimiter(tag string, nodeInfo *api.NodeInfo, userList []api.UserInfo) error {
dispather := p.Server.GetFeature(routing.DispatcherType()).(*dispatcher.DefaultDispatcher)
err := dispather.Limiter.AddInboundLimiter(tag, nodeInfo, userList)
err := p.dispatcher.Limiter.AddInboundLimiter(tag, nodeInfo, userList)
return err
}
func (p *Core) GetInboundLimiter(tag string) (*limiter.InboundInfo, error) {
dispather := p.Server.GetFeature(routing.DispatcherType()).(*dispatcher.DefaultDispatcher)
limit, ok := dispather.Limiter.InboundInfo.Load(tag)
limit, ok := p.dispatcher.Limiter.InboundInfo.Load(tag)
if ok {
return limit.(*limiter.InboundInfo), nil
}
@@ -47,13 +43,11 @@ func (p *Core) GetInboundLimiter(tag string) (*limiter.InboundInfo, error) {
}
func (p *Core) UpdateInboundLimiter(tag string, nodeInfo *api.NodeInfo, updatedUserList []api.UserInfo) error {
dispather := p.Server.GetFeature(routing.DispatcherType()).(*dispatcher.DefaultDispatcher)
err := dispather.Limiter.UpdateInboundLimiter(tag, nodeInfo, updatedUserList)
err := p.dispatcher.Limiter.UpdateInboundLimiter(tag, nodeInfo, updatedUserList)
return err
}
func (p *Core) DeleteInboundLimiter(tag string) error {
dispather := p.Server.GetFeature(routing.DispatcherType()).(*dispatcher.DefaultDispatcher)
err := dispather.Limiter.DeleteInboundLimiter(tag)
err := p.dispatcher.Limiter.DeleteInboundLimiter(tag)
return err
}