Skip to content

Commit

Permalink
pf: default to no anchor (#142)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmetc authored Feb 16, 2022
1 parent 240d6eb commit b5e02c7
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 9 deletions.
7 changes: 1 addition & 6 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ type bouncerConfig struct {
Ipv6 nftablesFamilyConfig `yaml:"ipv6"`
} `yaml:"nftables"`
PF struct {
AnchorName *string `yaml:"anchor_name"`
AnchorName string `yaml:"anchor_name"`
} `yaml:"pf"`
}

Expand Down Expand Up @@ -116,11 +116,6 @@ func newConfig(configPath string) (*bouncerConfig, error) {
}

func pfConfig(config *bouncerConfig) error {
// to avoid using an anchor, it has to be set to an empty string
// in the config file
if config.PF.AnchorName == nil {
config.PF.AnchorName = types.StrPtr("crowdsec")
}
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion config/crowdsec-firewall-bouncer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ nftables:
# packet filter
pf:
# an empty string disables the anchor
anchor_name: crowdsec
anchor_name: ""
4 changes: 2 additions & 2 deletions pf.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ func newPF(config *bouncerConfig) (backend, error) {
inetCtx := &pfContext{
table: config.BlacklistsIpv4,
proto: "inet",
anchor: *config.PF.AnchorName,
anchor: config.PF.AnchorName,
version: "ipv4",
}

inet6Ctx := &pfContext{
table: config.BlacklistsIpv6,
proto: "inet6",
anchor: *config.PF.AnchorName,
anchor: config.PF.AnchorName,
version: "ipv6",
}

Expand Down

0 comments on commit b5e02c7

Please sign in to comment.