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) {
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{},
},
......
......@@ -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,
......
......@@ -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,
......
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