From 223eebabd78841d571f9d23a4e3db769553a23e7 Mon Sep 17 00:00:00 2001 From: Daniel Czerwonk <daniel@dan-nrw.de> Date: Mon, 14 May 2018 15:20:05 +0200 Subject: [PATCH] some renaming --- routingtable/filter/term.go | 4 ++-- routingtable/filter/{from.go => term_condition.go} | 8 ++++---- .../{from_test.go => term_condition_test.go} | 2 +- routingtable/filter/term_test.go | 14 +++++++------- 4 files changed, 14 insertions(+), 14 deletions(-) rename routingtable/filter/{from.go => term_condition.go} (64%) rename routingtable/filter/{from_test.go => term_condition_test.go} (99%) diff --git a/routingtable/filter/term.go b/routingtable/filter/term.go index 2f8a47a9..0d546be8 100644 --- a/routingtable/filter/term.go +++ b/routingtable/filter/term.go @@ -11,12 +11,12 @@ type FilterAction interface { // Term matches a path against a list of conditions and performs actions if it matches type Term struct { - from []*From + from []*TermCondition then []FilterAction } // NewTerm creates a new term -func NewTerm(from []*From, then []FilterAction) *Term { +func NewTerm(from []*TermCondition, then []FilterAction) *Term { t := &Term{ from: from, then: then, diff --git a/routingtable/filter/from.go b/routingtable/filter/term_condition.go similarity index 64% rename from routingtable/filter/from.go rename to routingtable/filter/term_condition.go index 61212204..92c3616a 100644 --- a/routingtable/filter/from.go +++ b/routingtable/filter/term_condition.go @@ -5,16 +5,16 @@ import ( "github.com/bio-routing/bio-rd/route" ) -type From struct { +type TermCondition struct { prefixLists []*PrefixList 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) } -func (t *From) matchesAnyPrefixList(p net.Prefix) bool { +func (t *TermCondition) matchesAnyPrefixList(p net.Prefix) bool { for _, l := range t.prefixLists { if l.Matches(p) { return true @@ -24,7 +24,7 @@ func (t *From) matchesAnyPrefixList(p net.Prefix) bool { return false } -func (t *From) machtchesAnyRouteFilter(p net.Prefix) bool { +func (t *TermCondition) machtchesAnyRouteFilter(p net.Prefix) bool { for _, l := range t.routeFilters { if l.Matches(p) { return true diff --git a/routingtable/filter/from_test.go b/routingtable/filter/term_condition_test.go similarity index 99% rename from routingtable/filter/from_test.go rename to routingtable/filter/term_condition_test.go index acffa60a..876746a2 100644 --- a/routingtable/filter/from_test.go +++ b/routingtable/filter/term_condition_test.go @@ -109,7 +109,7 @@ func TestMatches(t *testing.T) { for _, test := range tests { t.Run(test.name, func(te *testing.T) { - f := &From{ + f := &TermCondition{ prefixLists: test.prefixLists, routeFilters: test.routeFilters, } diff --git a/routingtable/filter/term_test.go b/routingtable/filter/term_test.go index 9720dbe3..967480e7 100644 --- a/routingtable/filter/term_test.go +++ b/routingtable/filter/term_test.go @@ -24,7 +24,7 @@ func TestProcess(t *testing.T) { name string prefix net.Prefix path *route.Path - from []*From + from []*TermCondition then []FilterAction expectReject bool expectModified bool @@ -33,7 +33,7 @@ func TestProcess(t *testing.T) { name: "empty from", prefix: net.NewPfx(strAddr("100.64.0.1"), 8), path: &route.Path{}, - from: []*From{}, + from: []*TermCondition{}, then: []FilterAction{ &actions.AcceptAction{}, }, @@ -44,7 +44,7 @@ func TestProcess(t *testing.T) { name: "from matches", prefix: net.NewPfx(strAddr("100.64.0.1"), 8), path: &route.Path{}, - from: []*From{ + from: []*TermCondition{ { prefixLists: []*PrefixList{ NewPrefixList(net.NewPfx(strAddr("100.64.0.1"), 8)), @@ -61,7 +61,7 @@ func TestProcess(t *testing.T) { name: "from does not match", prefix: net.NewPfx(strAddr("100.64.0.1"), 8), path: &route.Path{}, - from: []*From{ + from: []*TermCondition{ { prefixLists: []*PrefixList{ NewPrefixList(net.NewPfx(0, 32)), @@ -78,7 +78,7 @@ func TestProcess(t *testing.T) { name: "modified", prefix: net.NewPfx(strAddr("100.64.0.1"), 8), path: &route.Path{}, - from: []*From{ + from: []*TermCondition{ { prefixLists: []*PrefixList{ NewPrefixList(net.NewPfx(strAddr("100.64.0.1"), 8)), @@ -95,7 +95,7 @@ func TestProcess(t *testing.T) { name: "modified and accepted (2 actions)", prefix: net.NewPfx(strAddr("100.64.0.1"), 8), path: &route.Path{}, - from: []*From{ + from: []*TermCondition{ { prefixLists: []*PrefixList{ NewPrefixList(net.NewPfx(strAddr("100.64.0.1"), 8)), @@ -113,7 +113,7 @@ func TestProcess(t *testing.T) { name: "one of the prefix filters matches", prefix: net.NewPfx(strAddr("100.64.0.1"), 8), path: &route.Path{}, - from: []*From{ + from: []*TermCondition{ { prefixLists: []*PrefixList{ NewPrefixListWithMatcher(Exact(), net.NewPfx(0, 32)), -- GitLab