Files

45 lines
1.5 KiB
Go

package chain
import (
chain2 "git.kor-elf.net/kor-elf-shield/go-nftables-client/chain"
"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 chain struct {
command contract.CommandRun
}
func New(command contract.CommandRun) nft.Chain {
return &chain{
command: command,
}
}
func (c *chain) Add(family family.Type, tableName string, chainName string, baseChain chain2.ChainOptions) error {
args := nftCommand.ChainAdd(family, tableName, chainName, baseChain)
return c.command.Run(args...)
}
func (c *chain) Create(family family.Type, tableName string, chainName string, baseChain chain2.ChainOptions) error {
args := nftCommand.ChainCreate(family, tableName, chainName, baseChain)
return c.command.Run(args...)
}
func (c *chain) Delete(family family.Type, tableName string, chainName string) error {
args := nftCommand.ChainDelete(family, tableName, chainName)
return c.command.Run(args...)
}
func (c *chain) Clear(family family.Type, tableName string, chainName string) error {
args := nftCommand.ChainClear(family, tableName, chainName)
return c.command.Run(args...)
}
func (c *chain) Rename(family family.Type, tableName string, oldChainName string, newChainName string) error {
args := nftCommand.ChainRename(family, tableName, oldChainName, newChainName)
return c.command.Run(args...)
}