Skip to content
Snippets Groups Projects
Commit 223eebab authored by Daniel Czerwonk's avatar Daniel Czerwonk
Browse files

some renaming

parent 5dab1a2c
Branches
Tags
No related merge requests found
...@@ -11,12 +11,12 @@ type FilterAction interface { ...@@ -11,12 +11,12 @@ type FilterAction interface {
// Term matches a path against a list of conditions and performs actions if it matches // Term matches a path against a list of conditions and performs actions if it matches
type Term struct { type Term struct {
from []*From from []*TermCondition
then []FilterAction then []FilterAction
} }
// NewTerm creates a new term // NewTerm creates a new term
func NewTerm(from []*From, then []FilterAction) *Term { func NewTerm(from []*TermCondition, then []FilterAction) *Term {
t := &Term{ t := &Term{
from: from, from: from,
then: then, then: then,
......
...@@ -5,16 +5,16 @@ import ( ...@@ -5,16 +5,16 @@ import (
"github.com/bio-routing/bio-rd/route" "github.com/bio-routing/bio-rd/route"
) )
type From struct { type TermCondition struct {
prefixLists []*PrefixList prefixLists []*PrefixList
routeFilters []*RouteFilter routeFilters []*RouteFilter
} }
func (f *From) Matches(p net.Prefix, pa *route.Path) bool { func (f *TermCondition) Matches(p net.Prefix, pa *route.Path) bool {
return f.matchesAnyPrefixList(p) || f.machtchesAnyRouteFilter(p) return f.matchesAnyPrefixList(p) || f.machtchesAnyRouteFilter(p)
} }
func (t *From) matchesAnyPrefixList(p net.Prefix) bool { func (t *TermCondition) matchesAnyPrefixList(p net.Prefix) bool {
for _, l := range t.prefixLists { for _, l := range t.prefixLists {
if l.Matches(p) { if l.Matches(p) {
return true return true
...@@ -24,7 +24,7 @@ func (t *From) matchesAnyPrefixList(p net.Prefix) bool { ...@@ -24,7 +24,7 @@ func (t *From) matchesAnyPrefixList(p net.Prefix) bool {
return false return false
} }
func (t *From) machtchesAnyRouteFilter(p net.Prefix) bool { func (t *TermCondition) machtchesAnyRouteFilter(p net.Prefix) bool {
for _, l := range t.routeFilters { for _, l := range t.routeFilters {
if l.Matches(p) { if l.Matches(p) {
return true return true
......
...@@ -109,7 +109,7 @@ func TestMatches(t *testing.T) { ...@@ -109,7 +109,7 @@ func TestMatches(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(te *testing.T) { t.Run(test.name, func(te *testing.T) {
f := &From{ f := &TermCondition{
prefixLists: test.prefixLists, prefixLists: test.prefixLists,
routeFilters: test.routeFilters, routeFilters: test.routeFilters,
} }
......
...@@ -24,7 +24,7 @@ func TestProcess(t *testing.T) { ...@@ -24,7 +24,7 @@ func TestProcess(t *testing.T) {
name string name string
prefix net.Prefix prefix net.Prefix
path *route.Path path *route.Path
from []*From from []*TermCondition
then []FilterAction then []FilterAction
expectReject bool expectReject bool
expectModified bool expectModified bool
...@@ -33,7 +33,7 @@ func TestProcess(t *testing.T) { ...@@ -33,7 +33,7 @@ func TestProcess(t *testing.T) {
name: "empty from", name: "empty from",
prefix: net.NewPfx(strAddr("100.64.0.1"), 8), prefix: net.NewPfx(strAddr("100.64.0.1"), 8),
path: &route.Path{}, path: &route.Path{},
from: []*From{}, from: []*TermCondition{},
then: []FilterAction{ then: []FilterAction{
&actions.AcceptAction{}, &actions.AcceptAction{},
}, },
...@@ -44,7 +44,7 @@ func TestProcess(t *testing.T) { ...@@ -44,7 +44,7 @@ func TestProcess(t *testing.T) {
name: "from matches", name: "from matches",
prefix: net.NewPfx(strAddr("100.64.0.1"), 8), prefix: net.NewPfx(strAddr("100.64.0.1"), 8),
path: &route.Path{}, path: &route.Path{},
from: []*From{ from: []*TermCondition{
{ {
prefixLists: []*PrefixList{ prefixLists: []*PrefixList{
NewPrefixList(net.NewPfx(strAddr("100.64.0.1"), 8)), NewPrefixList(net.NewPfx(strAddr("100.64.0.1"), 8)),
...@@ -61,7 +61,7 @@ func TestProcess(t *testing.T) { ...@@ -61,7 +61,7 @@ func TestProcess(t *testing.T) {
name: "from does not match", name: "from does not match",
prefix: net.NewPfx(strAddr("100.64.0.1"), 8), prefix: net.NewPfx(strAddr("100.64.0.1"), 8),
path: &route.Path{}, path: &route.Path{},
from: []*From{ from: []*TermCondition{
{ {
prefixLists: []*PrefixList{ prefixLists: []*PrefixList{
NewPrefixList(net.NewPfx(0, 32)), NewPrefixList(net.NewPfx(0, 32)),
...@@ -78,7 +78,7 @@ func TestProcess(t *testing.T) { ...@@ -78,7 +78,7 @@ func TestProcess(t *testing.T) {
name: "modified", name: "modified",
prefix: net.NewPfx(strAddr("100.64.0.1"), 8), prefix: net.NewPfx(strAddr("100.64.0.1"), 8),
path: &route.Path{}, path: &route.Path{},
from: []*From{ from: []*TermCondition{
{ {
prefixLists: []*PrefixList{ prefixLists: []*PrefixList{
NewPrefixList(net.NewPfx(strAddr("100.64.0.1"), 8)), NewPrefixList(net.NewPfx(strAddr("100.64.0.1"), 8)),
...@@ -95,7 +95,7 @@ func TestProcess(t *testing.T) { ...@@ -95,7 +95,7 @@ func TestProcess(t *testing.T) {
name: "modified and accepted (2 actions)", name: "modified and accepted (2 actions)",
prefix: net.NewPfx(strAddr("100.64.0.1"), 8), prefix: net.NewPfx(strAddr("100.64.0.1"), 8),
path: &route.Path{}, path: &route.Path{},
from: []*From{ from: []*TermCondition{
{ {
prefixLists: []*PrefixList{ prefixLists: []*PrefixList{
NewPrefixList(net.NewPfx(strAddr("100.64.0.1"), 8)), NewPrefixList(net.NewPfx(strAddr("100.64.0.1"), 8)),
...@@ -113,7 +113,7 @@ func TestProcess(t *testing.T) { ...@@ -113,7 +113,7 @@ func TestProcess(t *testing.T) {
name: "one of the prefix filters matches", name: "one of the prefix filters matches",
prefix: net.NewPfx(strAddr("100.64.0.1"), 8), prefix: net.NewPfx(strAddr("100.64.0.1"), 8),
path: &route.Path{}, path: &route.Path{},
from: []*From{ from: []*TermCondition{
{ {
prefixLists: []*PrefixList{ prefixLists: []*PrefixList{
NewPrefixListWithMatcher(Exact(), net.NewPfx(0, 32)), NewPrefixListWithMatcher(Exact(), net.NewPfx(0, 32)),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment