Files
go-nftables-client/internal/rule/rule.go
T

39 lines
1.2 KiB
Go

package rule
import (
"git.kor-elf.net/kor-elf-shield/go-nftables-client/contract"
"git.kor-elf.net/kor-elf-shield/go-nftables-client/contract/nft"
"git.kor-elf.net/kor-elf-shield/go-nftables-client/family"
nftCommand "git.kor-elf.net/kor-elf-shield/go-nftables-client/internal/pkg/nft"
)
type rule struct {
command contract.Command
}
func New(command contract.Command) nft.Rule {
return &rule{
command: command,
}
}
func (r *rule) Add(family family.Type, tableName string, chainName string, expr ...string) error {
args := nftCommand.RuleAdd(family, tableName, chainName, expr...)
return r.command.Run(args...)
}
func (r *rule) Insert(family family.Type, tableName string, chainName string, expr ...string) error {
args := nftCommand.RuleInsert(family, tableName, chainName, expr...)
return r.command.Run(args...)
}
func (r *rule) Replace(family family.Type, tableName string, chainName string, handle uint64, expr ...string) error {
args := nftCommand.RuleReplace(family, tableName, chainName, handle, expr...)
return r.command.Run(args...)
}
func (r *rule) Delete(family family.Type, tableName string, chainName string, handle uint64) error {
args := nftCommand.RuleDelete(family, tableName, chainName, handle)
return r.command.Run(args...)
}