1
0
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:
Darien Raymond
2015-11-30 15:14:38 +00:00
parent f6c486327f
commit 56a79a2190
10 changed files with 60 additions and 22 deletions

View File

@@ -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 {