Add Rule API for managing nftables rules, including Add, Insert, Replace, and Delete operations
This commit is contained in:
10
nft.go
10
nft.go
@@ -7,6 +7,7 @@ import (
|
||||
|
||||
"git.kor-elf.net/kor-elf-shield/go-nftables-client/internal/chain"
|
||||
"git.kor-elf.net/kor-elf-shield/go-nftables-client/internal/command"
|
||||
"git.kor-elf.net/kor-elf-shield/go-nftables-client/internal/rule"
|
||||
"git.kor-elf.net/kor-elf-shield/go-nftables-client/internal/table"
|
||||
)
|
||||
|
||||
@@ -33,12 +34,16 @@ type NFT interface {
|
||||
|
||||
// Chain returns an API for working with chains.
|
||||
Chain() chain.API
|
||||
|
||||
// Rule returns an API for working with rules.
|
||||
Rule() rule.API
|
||||
}
|
||||
|
||||
type nft struct {
|
||||
command command.NFT
|
||||
table table.API
|
||||
chain chain.API
|
||||
rule rule.API
|
||||
}
|
||||
|
||||
// New Returns a client for working with nftables.
|
||||
@@ -66,6 +71,7 @@ func NewWithPath(path string) (NFT, error) {
|
||||
command: nftCommand,
|
||||
table: table.New(nftCommand),
|
||||
chain: chain.New(nftCommand),
|
||||
rule: rule.New(nftCommand),
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -116,6 +122,10 @@ func (n *nft) Chain() chain.API {
|
||||
return n.chain
|
||||
}
|
||||
|
||||
func (n *nft) Rule() rule.API {
|
||||
return n.rule
|
||||
}
|
||||
|
||||
func (n *nft) Command() command.NFT {
|
||||
return n.command
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user