2015-12-07 16:47:47 -05:00
|
|
|
package rules
|
2015-11-21 15:43:40 -05:00
|
|
|
|
|
|
|
import (
|
|
|
|
v2net "github.com/v2ray/v2ray-core/common/net"
|
|
|
|
)
|
|
|
|
|
2016-01-17 10:20:49 -05:00
|
|
|
type Rule struct {
|
|
|
|
Tag string
|
|
|
|
Condition Condition
|
2015-11-21 15:43:40 -05:00
|
|
|
}
|
2015-12-07 16:47:47 -05:00
|
|
|
|
2016-01-17 10:20:49 -05:00
|
|
|
func (this *Rule) Apply(dest v2net.Destination) bool {
|
|
|
|
return this.Condition.Apply(dest)
|
|
|
|
}
|
|
|
|
|
|
|
|
type RouterRuleConfig struct {
|
|
|
|
rules []*Rule
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewRouterRuleConfig() *RouterRuleConfig {
|
|
|
|
return &RouterRuleConfig{
|
|
|
|
rules: make([]*Rule, 0, 16),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *RouterRuleConfig) Add(rule *Rule) *RouterRuleConfig {
|
|
|
|
this.rules = append(this.rules, rule)
|
|
|
|
return this
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *RouterRuleConfig) Rules() []*Rule {
|
|
|
|
return this.rules
|
2015-12-07 16:47:47 -05:00
|
|
|
}
|