Refactor to consolidate APIs into contract package and introduce NFT interface for better modularity and maintainability.
This commit is contained in:
+4
-30
@@ -3,42 +3,16 @@ package rule
|
||||
import (
|
||||
"strconv"
|
||||
|
||||
"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"
|
||||
)
|
||||
|
||||
type API interface {
|
||||
// Add adds a new rule.
|
||||
//
|
||||
// This command is equivalent to:
|
||||
// nft add rule (ip|ip6|inet|arp|bridge) {table_name} {chain_name} '{ expr }'
|
||||
Add(family family.Type, tableName string, chainName string, expr ...string) error
|
||||
|
||||
// Insert inserts a new rule.
|
||||
// Inserted rules are placed at the beginning of the chain, by default.
|
||||
//
|
||||
// This command is equivalent to:
|
||||
// nft insert rule (ip|ip6|inet|arp|bridge) {table_name} {chain_name} '{ expr }'
|
||||
Insert(family family.Type, tableName string, chainName string, expr ...string) error
|
||||
|
||||
// Replace replaces a rule.
|
||||
//
|
||||
// This command is equivalent to:
|
||||
// nft replace rule (ip|ip6|inet|arp|bridge) {table_name} {chain_name} {handle} '{ expr }'
|
||||
Replace(family family.Type, tableName string, chainName string, handle uint64, expr ...string) error
|
||||
|
||||
// Delete deletes a rule.
|
||||
//
|
||||
// This command is equivalent to:
|
||||
// nft delete rule (ip|ip6|inet|arp|bridge) {table_name} {chain_name} {handle}
|
||||
Delete(family family.Type, tableName string, chainName string, handle uint64) error
|
||||
}
|
||||
|
||||
type rule struct {
|
||||
command command.NFT
|
||||
command contract.Command
|
||||
}
|
||||
|
||||
func New(command command.NFT) API {
|
||||
func New(command contract.Command) nft.Rule {
|
||||
return &rule{
|
||||
command: command,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user