API - Add | Remove Routing Rules (#3189)

* add RuleTag to routing rules

* add router pb commands

* add and remove routing rules api

* cleanup

* fix

* improve error msg

* add append flag
apply balancer config
This commit is contained in:
Hossin Asaadi 2024-03-29 19:17:36 +04:00 committed by GitHub
parent 8a439bf3f2
commit 53e5814d19
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 901 additions and 269 deletions

View file

@ -2,6 +2,7 @@ package routing
import (
"github.com/xtls/xray-core/common"
"github.com/xtls/xray-core/common/serial"
"github.com/xtls/xray-core/features"
)
@ -13,6 +14,8 @@ type Router interface {
// PickRoute returns a route decision based on the given routing context.
PickRoute(ctx Context) (Route, error)
AddRule(config *serial.TypedMessage, shouldAppend bool) error
RemoveRule(tag string) error
}
// Route is the routing result of Router feature.
@ -49,6 +52,16 @@ func (DefaultRouter) PickRoute(ctx Context) (Route, error) {
return nil, common.ErrNoClue
}
// AddRule implements Router.
func (DefaultRouter) AddRule(config *serial.TypedMessage, shouldAppend bool) error {
return common.ErrNoClue
}
// RemoveRule implements Router.
func (DefaultRouter) RemoveRule(tag string) error {
return common.ErrNoClue
}
// Start implements common.Runnable.
func (DefaultRouter) Start() error {
return nil