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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user