Add table implementation with Add, Delete, and Clear methods
This commit is contained in:
@@ -0,0 +1,33 @@
|
|||||||
|
package table
|
||||||
|
|
||||||
|
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 table struct {
|
||||||
|
command contract.CommandRun
|
||||||
|
}
|
||||||
|
|
||||||
|
func New(command contract.CommandRun) nft.Table {
|
||||||
|
return &table{
|
||||||
|
command: command,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *table) Add(family family.Type, tableName string) error {
|
||||||
|
args := nftCommand.TableAdd(family, tableName)
|
||||||
|
return t.command.Run(args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *table) Delete(family family.Type, tableName string) error {
|
||||||
|
args := nftCommand.TableDelete(family, tableName)
|
||||||
|
return t.command.Run(args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *table) Clear(family family.Type, tableName string) error {
|
||||||
|
args := nftCommand.TableClear(family, tableName)
|
||||||
|
return t.command.Run(args...)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user