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

renamed Then to FilterAction

parent 8e6945d8
Branches
Tags
No related merge requests found
...@@ -54,7 +54,7 @@ func TestAddPath(t *testing.T) { ...@@ -54,7 +54,7 @@ func TestAddPath(t *testing.T) {
prefix: net.NewPfx(0, 0), prefix: net.NewPfx(0, 0),
path: &route.Path{}, path: &route.Path{},
term: &Term{ term: &Term{
then: []Then{ then: []FilterAction{
&actions.AcceptAction{}, &actions.AcceptAction{},
}, },
}, },
...@@ -66,7 +66,7 @@ func TestAddPath(t *testing.T) { ...@@ -66,7 +66,7 @@ func TestAddPath(t *testing.T) {
prefix: net.NewPfx(0, 0), prefix: net.NewPfx(0, 0),
path: &route.Path{}, path: &route.Path{},
term: &Term{ term: &Term{
then: []Then{ then: []FilterAction{
&actions.RejectAction{}, &actions.RejectAction{},
}, },
}, },
...@@ -78,7 +78,7 @@ func TestAddPath(t *testing.T) { ...@@ -78,7 +78,7 @@ func TestAddPath(t *testing.T) {
prefix: net.NewPfx(0, 0), prefix: net.NewPfx(0, 0),
path: &route.Path{}, path: &route.Path{},
term: &Term{ term: &Term{
then: []Then{ then: []FilterAction{
&mockAction{}, &mockAction{},
&actions.AcceptAction{}, &actions.AcceptAction{},
}, },
...@@ -127,7 +127,7 @@ func TestRemovePath(t *testing.T) { ...@@ -127,7 +127,7 @@ func TestRemovePath(t *testing.T) {
prefix: net.NewPfx(0, 0), prefix: net.NewPfx(0, 0),
path: &route.Path{}, path: &route.Path{},
term: &Term{ term: &Term{
then: []Then{ then: []FilterAction{
&actions.AcceptAction{}, &actions.AcceptAction{},
}, },
}, },
...@@ -139,7 +139,7 @@ func TestRemovePath(t *testing.T) { ...@@ -139,7 +139,7 @@ func TestRemovePath(t *testing.T) {
prefix: net.NewPfx(0, 0), prefix: net.NewPfx(0, 0),
path: &route.Path{}, path: &route.Path{},
term: &Term{ term: &Term{
then: []Then{ then: []FilterAction{
&actions.RejectAction{}, &actions.RejectAction{},
}, },
}, },
...@@ -151,7 +151,7 @@ func TestRemovePath(t *testing.T) { ...@@ -151,7 +151,7 @@ func TestRemovePath(t *testing.T) {
prefix: net.NewPfx(0, 0), prefix: net.NewPfx(0, 0),
path: &route.Path{}, path: &route.Path{},
term: &Term{ term: &Term{
then: []Then{ then: []FilterAction{
&mockAction{}, &mockAction{},
&actions.AcceptAction{}, &actions.AcceptAction{},
}, },
......
...@@ -5,14 +5,18 @@ import ( ...@@ -5,14 +5,18 @@ import (
"github.com/bio-routing/bio-rd/route" "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 // Term matches a path against a list of conditions and performs actions if it matches
type Term struct { type Term struct {
from []*From from []*From
then []Then then []FilterAction
} }
// NewTerm creates a new term // NewTerm creates a new term
func NewTerm(from []*From, then []Then) *Term { func NewTerm(from []*From, then []FilterAction) *Term {
t := &Term{ t := &Term{
from: from, from: from,
then: then, then: then,
......
...@@ -25,7 +25,7 @@ func TestProcess(t *testing.T) { ...@@ -25,7 +25,7 @@ func TestProcess(t *testing.T) {
prefix net.Prefix prefix net.Prefix
path *route.Path path *route.Path
from []*From from []*From
then []Then then []FilterAction
expectReject bool expectReject bool
expectModified bool expectModified bool
}{ }{
...@@ -34,7 +34,7 @@ func TestProcess(t *testing.T) { ...@@ -34,7 +34,7 @@ func TestProcess(t *testing.T) {
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: []*From{},
then: []Then{ then: []FilterAction{
&actions.AcceptAction{}, &actions.AcceptAction{},
}, },
expectReject: false, expectReject: false,
...@@ -53,7 +53,7 @@ func TestProcess(t *testing.T) { ...@@ -53,7 +53,7 @@ func TestProcess(t *testing.T) {
}, },
}, },
}, },
then: []Then{ then: []FilterAction{
&actions.AcceptAction{}, &actions.AcceptAction{},
}, },
expectReject: false, expectReject: false,
...@@ -72,7 +72,7 @@ func TestProcess(t *testing.T) { ...@@ -72,7 +72,7 @@ func TestProcess(t *testing.T) {
}, },
}, },
}, },
then: []Then{ then: []FilterAction{
&actions.AcceptAction{}, &actions.AcceptAction{},
}, },
expectReject: true, expectReject: true,
...@@ -91,7 +91,7 @@ func TestProcess(t *testing.T) { ...@@ -91,7 +91,7 @@ func TestProcess(t *testing.T) {
}, },
}, },
}, },
then: []Then{ then: []FilterAction{
&mockAction{}, &mockAction{},
}, },
expectReject: false, expectReject: false,
...@@ -110,7 +110,7 @@ func TestProcess(t *testing.T) { ...@@ -110,7 +110,7 @@ func TestProcess(t *testing.T) {
}, },
}, },
}, },
then: []Then{ then: []FilterAction{
&mockAction{}, &mockAction{},
&actions.AcceptAction{}, &actions.AcceptAction{},
}, },
...@@ -137,7 +137,7 @@ func TestProcess(t *testing.T) { ...@@ -137,7 +137,7 @@ func TestProcess(t *testing.T) {
}, },
}, },
}, },
then: []Then{ then: []FilterAction{
&actions.AcceptAction{}, &actions.AcceptAction{},
}, },
expectReject: false, expectReject: false,
......
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)
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment