mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-12-28 04:55:37 -05:00
remove DetourTag and add more test cases
This commit is contained in:
@@ -7,27 +7,24 @@ import (
|
||||
"github.com/v2ray/v2ray-core/app/router/rules/config"
|
||||
"github.com/v2ray/v2ray-core/app/router/rules/config/json"
|
||||
v2net "github.com/v2ray/v2ray-core/common/net"
|
||||
pointconfig "github.com/v2ray/v2ray-core/shell/point/config"
|
||||
)
|
||||
|
||||
var (
|
||||
InvalidRule = errors.New("Invalid Rule")
|
||||
NoRuleApplicable = errors.New("No rule applicable")
|
||||
|
||||
EmptyTag = pointconfig.DetourTag("")
|
||||
)
|
||||
|
||||
type Router struct {
|
||||
rules []config.Rule
|
||||
}
|
||||
|
||||
func (this *Router) TakeDetour(dest v2net.Destination) (pointconfig.DetourTag, error) {
|
||||
func (this *Router) TakeDetour(dest v2net.Destination) (string, error) {
|
||||
for _, rule := range this.rules {
|
||||
if rule.Apply(dest) {
|
||||
return rule.Tag(), nil
|
||||
}
|
||||
}
|
||||
return EmptyTag, NoRuleApplicable
|
||||
return "", NoRuleApplicable
|
||||
}
|
||||
|
||||
type RouterFactory struct {
|
||||
|
||||
Reference in New Issue
Block a user