mirror of
https://github.com/wyx2685/V2bX.git
synced 2025-01-25 19:18:13 -05:00
695da4f4c5
change to uniproxy api refactor build inbound refactor limiter and rule add ss2022 support add speedlimit support and more...
54 lines
1.5 KiB
Go
54 lines
1.5 KiB
Go
package core
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"github.com/Yuzuki616/V2bX/api/panel"
|
|
"github.com/Yuzuki616/V2bX/core/app/dispatcher"
|
|
"github.com/xtls/xray-core/core"
|
|
"github.com/xtls/xray-core/features/inbound"
|
|
)
|
|
|
|
func (p *Core) RemoveInbound(tag string) error {
|
|
return p.ihm.RemoveHandler(context.Background(), tag)
|
|
}
|
|
|
|
func (p *Core) AddInbound(config *core.InboundHandlerConfig) error {
|
|
rawHandler, err := core.CreateObject(p.Server, config)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
handler, ok := rawHandler.(inbound.Handler)
|
|
if !ok {
|
|
return fmt.Errorf("not an InboundHandler: %s", err)
|
|
}
|
|
if err := p.ihm.AddHandler(context.Background(), handler); err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (p *Core) AddInboundLimiter(tag string, nodeInfo *panel.NodeInfo, users []panel.UserInfo) error {
|
|
return p.dispatcher.Limiter.AddInboundLimiter(tag, nodeInfo, users)
|
|
}
|
|
|
|
func (p *Core) GetInboundLimiter(tag string) (*dispatcher.InboundInfo, error) {
|
|
limit, ok := p.dispatcher.Limiter.InboundInfo.Load(tag)
|
|
if ok {
|
|
return limit.(*dispatcher.InboundInfo), nil
|
|
}
|
|
return nil, fmt.Errorf("not found limiter")
|
|
}
|
|
|
|
func (p *Core) UpdateInboundLimiter(tag string, added []panel.UserInfo, deleted []panel.UserInfo) error {
|
|
return p.dispatcher.Limiter.UpdateInboundLimiter(tag, added, deleted)
|
|
}
|
|
|
|
func (p *Core) DeleteInboundLimiter(tag string) error {
|
|
return p.dispatcher.Limiter.DeleteInboundLimiter(tag)
|
|
}
|
|
|
|
func (p *Core) UpdateRule(tag string, newRuleList []panel.DestinationRule) error {
|
|
return p.dispatcher.RuleManager.UpdateRule(tag, newRuleList)
|
|
}
|