1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2025-12-27 20:45:28 -05:00

code ready for selective routing

This commit is contained in:
V2Ray
2015-11-22 17:41:52 +01:00
parent f4ec19625e
commit 12e72509a5
8 changed files with 106 additions and 24 deletions

View File

@@ -11,21 +11,23 @@ import (
)
var (
InvalidRule = errors.New("Invalid Rule")
EmptyTag = pointconfig.DetourTag("")
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) (pointconfig.DetourTag, error) {
for _, rule := range this.rules {
if rule.Apply(dest) {
return rule.Tag(), nil
}
}
return &EmptyTag, nil
return EmptyTag, NoRuleApplicable
}
type RouterFactory struct {