Refactor to consolidate APIs into contract package and introduce NFT interface for better modularity and maintainability.

This commit is contained in:
2026-04-22 21:54:59 +05:00
parent 92803286f5
commit 3c47e7566b
12 changed files with 182 additions and 154 deletions
+4 -24
View File
@@ -1,36 +1,16 @@
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"
"git.kor-elf.net/kor-elf-shield/go-nftables-client/internal/command"
)
// API for working with tables.
type API interface {
// AddTable adds a new table.
//
// This command is equivalent to:
// nft add table (ip|ip6|inet|arp|bridge) {table_name}
Add(family family.Type, tableName string) error
// DeleteTable deletes a table.
//
// This command is equivalent to:
// nft delete table (ip|ip6|inet|arp|bridge) {table_name}
Delete(family family.Type, tableName string) error
// ClearTable clears all rules in a table.
//
// This command is equivalent to:
// nft flush table (ip|ip6|inet|arp|bridge) {table_name}
Clear(family family.Type, tableName string) error
}
type table struct {
command command.NFT
command contract.Command
}
func New(command command.NFT) API {
func New(command contract.Command) nft.Table {
return &table{
command: command,
}