Skip to content

enhance: allow user to specify v4 and v6 chains independantly #411

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pkg/cfg/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ type BouncerConfig struct {

// specific to iptables, following https://github.com/crowdsecurity/cs-firewall-bouncer/issues/19
IptablesChains []string `yaml:"iptables_chains"`
IptablesV4Chains []string `yaml:"iptables_v4_chains"`
IptablesV6Chains []string `yaml:"iptables_v6_chains"`
IptablesAddRuleComments bool `yaml:"iptables_add_rule_comments"`

SupportedDecisionsTypes []string `yaml:"supported_decisions_types"`
Expand Down
6 changes: 4 additions & 2 deletions pkg/iptables/iptables.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ func NewIPTables(config *cfg.BouncerConfig) (types.Backend, error) {
v4Sets, _ = ipsetcmd.GetSetsStartingWith(config.BlacklistsIpv4)
v6Sets, _ = ipsetcmd.GetSetsStartingWith(config.BlacklistsIpv6)

ipv4Ctx.Chains = config.IptablesChains
config.IptablesV4Chains = append(config.IptablesV4Chains, config.IptablesChains...)
ipv4Ctx.Chains = config.IptablesV4Chains
}

ipv4Ctx.ipsets = v4Sets
Expand Down Expand Up @@ -136,7 +137,8 @@ func NewIPTables(config *cfg.BouncerConfig) (types.Backend, error) {
return nil, errors.New("unable to find ip6tables")
}

ipv6Ctx.Chains = config.IptablesChains
config.IptablesV6Chains = append(config.IptablesV6Chains, config.IptablesChains...)
ipv6Ctx.Chains = config.IptablesV6Chains
}

ipv6Ctx.ipsets = v6Sets
Expand Down
Loading