33 lines
848 B
Go
33 lines
848 B
Go
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"
|
|
)
|
|
|
|
type table struct {
|
|
command contract.Command
|
|
}
|
|
|
|
func New(command contract.Command) nft.Table {
|
|
return &table{
|
|
command: command,
|
|
}
|
|
}
|
|
|
|
func (t *table) Add(family family.Type, tableName string) error {
|
|
args := []string{"add", "table", family.String(), tableName}
|
|
return t.command.Run(args...)
|
|
}
|
|
|
|
func (t *table) Delete(family family.Type, tableName string) error {
|
|
args := []string{"delete", "table", family.String(), tableName}
|
|
return t.command.Run(args...)
|
|
}
|
|
|
|
func (t *table) Clear(family family.Type, tableName string) error {
|
|
args := []string{"flush", "table", family.String(), tableName}
|
|
return t.command.Run(args...)
|
|
}
|