diff --git a/routingtable/filter/filter_test.go b/routingtable/filter/filter_test.go index 8b33f125e0824a1e44b5dad7f4b8daf9ec323247..ce9b733e08a0b32959eb23b3230ffeb7cb5c3041 100644 --- a/routingtable/filter/filter_test.go +++ b/routingtable/filter/filter_test.go @@ -54,7 +54,7 @@ func TestAddPath(t *testing.T) { prefix: net.NewPfx(0, 0), path: &route.Path{}, term: &Term{ - then: []Then{ + then: []FilterAction{ &actions.AcceptAction{}, }, }, @@ -66,7 +66,7 @@ func TestAddPath(t *testing.T) { prefix: net.NewPfx(0, 0), path: &route.Path{}, term: &Term{ - then: []Then{ + then: []FilterAction{ &actions.RejectAction{}, }, }, @@ -78,7 +78,7 @@ func TestAddPath(t *testing.T) { prefix: net.NewPfx(0, 0), path: &route.Path{}, term: &Term{ - then: []Then{ + then: []FilterAction{ &mockAction{}, &actions.AcceptAction{}, }, @@ -127,7 +127,7 @@ func TestRemovePath(t *testing.T) { prefix: net.NewPfx(0, 0), path: &route.Path{}, term: &Term{ - then: []Then{ + then: []FilterAction{ &actions.AcceptAction{}, }, }, @@ -139,7 +139,7 @@ func TestRemovePath(t *testing.T) { prefix: net.NewPfx(0, 0), path: &route.Path{}, term: &Term{ - then: []Then{ + then: []FilterAction{ &actions.RejectAction{}, }, }, @@ -151,7 +151,7 @@ func TestRemovePath(t *testing.T) { prefix: net.NewPfx(0, 0), path: &route.Path{}, term: &Term{ - then: []Then{ + then: []FilterAction{ &mockAction{}, &actions.AcceptAction{}, }, diff --git a/routingtable/filter/term.go b/routingtable/filter/term.go index 85a88eb88945581c388f790bcf17631b7f1da9db..2f8a47a92ee0f652e9cbde2971eb8e4128032ed1 100644 --- a/routingtable/filter/term.go +++ b/routingtable/filter/term.go @@ -5,14 +5,18 @@ import ( "github.com/bio-routing/bio-rd/route" ) +type FilterAction interface { + Do(p net.Prefix, pa *route.Path) (modPath *route.Path, reject bool) +} + // Term matches a path against a list of conditions and performs actions if it matches type Term struct { from []*From - then []Then + then []FilterAction } // NewTerm creates a new term -func NewTerm(from []*From, then []Then) *Term { +func NewTerm(from []*From, then []FilterAction) *Term { t := &Term{ from: from, then: then, diff --git a/routingtable/filter/term_test.go b/routingtable/filter/term_test.go index ee55c712c21a055d75dc61468751e1c80b92f81b..bd0a00bebbe0636a78c8b9b7ca5e90cd83aaadd5 100644 --- a/routingtable/filter/term_test.go +++ b/routingtable/filter/term_test.go @@ -25,7 +25,7 @@ func TestProcess(t *testing.T) { prefix net.Prefix path *route.Path from []*From - then []Then + then []FilterAction expectReject bool expectModified bool }{ @@ -34,7 +34,7 @@ func TestProcess(t *testing.T) { prefix: net.NewPfx(strAddr("100.64.0.1"), 8), path: &route.Path{}, from: []*From{}, - then: []Then{ + then: []FilterAction{ &actions.AcceptAction{}, }, expectReject: false, @@ -53,7 +53,7 @@ func TestProcess(t *testing.T) { }, }, }, - then: []Then{ + then: []FilterAction{ &actions.AcceptAction{}, }, expectReject: false, @@ -72,7 +72,7 @@ func TestProcess(t *testing.T) { }, }, }, - then: []Then{ + then: []FilterAction{ &actions.AcceptAction{}, }, expectReject: true, @@ -91,7 +91,7 @@ func TestProcess(t *testing.T) { }, }, }, - then: []Then{ + then: []FilterAction{ &mockAction{}, }, expectReject: false, @@ -110,7 +110,7 @@ func TestProcess(t *testing.T) { }, }, }, - then: []Then{ + then: []FilterAction{ &mockAction{}, &actions.AcceptAction{}, }, @@ -137,7 +137,7 @@ func TestProcess(t *testing.T) { }, }, }, - then: []Then{ + then: []FilterAction{ &actions.AcceptAction{}, }, expectReject: false, diff --git a/routingtable/filter/then.go b/routingtable/filter/then.go deleted file mode 100644 index 920daf43c1cdb121400168cc0ac17460bff42350..0000000000000000000000000000000000000000 --- a/routingtable/filter/then.go +++ /dev/null @@ -1,10 +0,0 @@ -package filter - -import ( - "github.com/bio-routing/bio-rd/net" - "github.com/bio-routing/bio-rd/route" -) - -type Then interface { - Do(p net.Prefix, pa *route.Path) (modPath *route.Path, reject bool) -}