mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-04-30 17:38:41 +00:00
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:
parent
8a439bf3f2
commit
53e5814d19
13 changed files with 901 additions and 269 deletions
|
@ -54,6 +54,20 @@ func (s *routingServer) OverrideBalancerTarget(ctx context.Context, request *Ove
|
|||
return nil, newError("unsupported router implementation")
|
||||
}
|
||||
|
||||
func (s *routingServer) AddRule(ctx context.Context, request *AddRuleRequest) (*AddRuleResponse, error) {
|
||||
if bo, ok := s.router.(routing.Router); ok {
|
||||
return &AddRuleResponse{}, bo.AddRule(request.Config, request.ShouldAppend)
|
||||
}
|
||||
return nil, newError("unsupported router implementation")
|
||||
|
||||
}
|
||||
func (s *routingServer) RemoveRule(ctx context.Context, request *RemoveRuleRequest) (*RemoveRuleResponse, error) {
|
||||
if bo, ok := s.router.(routing.Router); ok {
|
||||
return &RemoveRuleResponse{}, bo.RemoveRule(request.RuleTag)
|
||||
}
|
||||
return nil, newError("unsupported router implementation")
|
||||
}
|
||||
|
||||
// NewRoutingServer creates a statistics service with statistics manager.
|
||||
func NewRoutingServer(router routing.Router, routingStats stats.Channel) RoutingServiceServer {
|
||||
return &routingServer{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue