-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathanchor.go
37 lines (31 loc) · 843 Bytes
/
anchor.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// +build !windows,!plan9,!linux
package pf
// Anchor is a pf firewall anchor struct
type Anchor struct {
Name string
ruleSet RuleSet
}
// NewAnchor returns a new Anchor struct. It requires an anchor name as parameter
func (f *Firewall) NewAnchor(n string) Anchor {
anchorObj := Anchor{
Name: n,
}
return anchorObj
}
// NewRule generates a new Rule with sane defaults
func (a *Anchor) NewRule() Rule {
ar := Rule{}
ar.SetAction(ActionBlock)
return ar
}
// AddRule adds a given rule to the Anchor RuleSet struct rules array. The rule must have the committed
// flag set to true
func (a *Anchor) AddRule(r Rule) {
if r.committed {
a.ruleSet.AddRule(r)
}
}
// RulesString returns a line separated string of all committed rules of the current Anchor
func (a *Anchor) RulesString() string {
return a.ruleSet.RulesString()
}