Documentation ¶
Index ¶
- Constants
- func Apply(nft Nft) error
- func ApplyFromFile(cfg string) error
- func Drop(family Family, table, chain string, handle int) error
- func IPv4Set(family Family, table string, name string, ips ...string) error
- func IPv4SetDel(family Family, table, name string, ips ...string) error
- func IPv4SetGet(family Family, table, name string) ([]string, error)
- type API
- type And
- type Chain
- type ChainFilter
- type Chains
- type Family
- type FamilyFilter
- type Filter
- type FilterRule
- type IPMatchFilter
- type IntMatchFilter
- type MarkFilter
- type MetaMatchFilter
- type NetworkMatchFilter
- type Nft
- type NftChainBlock
- type NftJsonBlock
- type NftRuleBlock
- type NftSetBlock
- type NftTableBlock
- type Or
- type Port
- type Rule
- type Set
- type Sets
- type Table
- type TableFilter
- type Type
Constants ¶
View Source
const ( NFT = iota TABLE CHAIN FamilyIP = Family("ip") FamilyIP6 = Family("ip6") FamilyNET = Family("net") FamilyINET = Family("inet") FamilyARP = Family("arp") FamilyBridge = Family("bridge") TypeSkipCreate = Type("") TypeNAT = Type("nat") TypeFilter = Type("filter") )
View Source
const ( //NFTDebug if true, nft files will not be deleted for inspection NFTDebug = false )
Variables ¶
This section is empty.
Functions ¶
func ApplyFromFile ¶
ApplyFromFile applies nft rules from a file
func IPv4SetDel ¶ added in v1.5.0
IPv4SetDel delete ips from a ipv4_addr set
Types ¶
type API ¶ added in v1.5.0
type API interface { Apply(nft Nft) error Drop(family Family, table, chain string, handle int) error Find(filter ...Filter) ([]FilterRule, error) IPv4Set(family Family, table string, name string, ips ...string) error IPv4SetDel(family Family, table, name string, ips ...string) error }
API defines nft api
type And ¶ added in v1.5.0
type And []Filter
And allows grouping filters in an And op
func (And) Match ¶ added in v1.5.0
func (f And) Match(rule *NftRuleBlock) bool
type ChainFilter ¶ added in v1.5.0
type ChainFilter struct {
Chain string
}
func (*ChainFilter) Match ¶ added in v1.5.0
func (f *ChainFilter) Match(rule *NftRuleBlock) bool
type FamilyFilter ¶ added in v1.5.0
type FamilyFilter struct {
Family Family
}
func (*FamilyFilter) Match ¶ added in v1.5.0
func (f *FamilyFilter) Match(rule *NftRuleBlock) bool
type Filter ¶ added in v1.5.0
type Filter interface {
Match(rule *NftRuleBlock) bool
}
Filter interface
type FilterRule ¶ added in v1.5.0
func Find ¶ added in v1.5.0
func Find(f ...Filter) ([]FilterRule, error)
type IPMatchFilter ¶ added in v1.5.0
func (*IPMatchFilter) Match ¶ added in v1.5.0
func (f *IPMatchFilter) Match(rule *NftRuleBlock) bool
type IntMatchFilter ¶ added in v1.5.0
MatchFilter is a simple match rule
func (*IntMatchFilter) Match ¶ added in v1.5.0
func (f *IntMatchFilter) Match(rule *NftRuleBlock) bool
type MarkFilter ¶ added in v1.5.0
type MarkFilter struct {
Mark uint32
}
MetaFilter find a rule by meta mark
func (*MarkFilter) Match ¶ added in v1.5.0
func (f *MarkFilter) Match(rule *NftRuleBlock) bool
type MetaMatchFilter ¶ added in v1.5.0
func (*MetaMatchFilter) Match ¶ added in v1.5.0
func (f *MetaMatchFilter) Match(rule *NftRuleBlock) bool
type NetworkMatchFilter ¶ added in v1.5.0
func (*NetworkMatchFilter) Match ¶ added in v1.5.0
func (f *NetworkMatchFilter) Match(rule *NftRuleBlock) bool
type Nft ¶
func (Nft) MarshalText ¶
type NftChainBlock ¶ added in v1.5.0
type NftChainBlock struct { /* {'hook': 'prerouting', 'family': 'ip', 'prio': 0, 'table': 'nat', 'name': 'pre', 'handle': 1, 'type': 'nat', 'policy': 'accept'} */ Hook string `json:"hook"` Family Family `json:"family"` Priority int `json:"prio"` Table string `json:"table"` Name string `json:"name"` Handle int `json:"handle"` Type Type `json:"type"` Policy string `json:"policy"` }
type NftJsonBlock ¶ added in v1.5.0
type NftJsonBlock map[string]json.RawMessage
NftJsonBlock defines a nft json block
type NftRuleBlock ¶ added in v1.5.0
type NftRuleBlock struct { /* {'family': 'inet', 'expr': [{'match': {'right': {'set': ['established', 'related']}, 'left': {'ct': {'key': 'state'}}}}, {'accept': None}], 'table': 'filter', 'handle': 5, 'chain': 'input'} */ Family Family `json:"family"` Expresion []NftJsonBlock `json:"expr"` Table string `json:"table"` Handle int `json:"handle"` Chain string `json:"chain"` }
type NftSetBlock ¶ added in v1.5.0
type NftTableBlock ¶ added in v1.5.0
type Or ¶ added in v1.5.0
type Or []Filter
func (Or) Match ¶ added in v1.5.0
func (f Or) Match(rule *NftRuleBlock) bool
type TableFilter ¶ added in v1.5.0
type TableFilter struct {
Table string
}
func (*TableFilter) Match ¶ added in v1.5.0
func (f *TableFilter) Match(rule *NftRuleBlock) bool
Source Files ¶
Click to show internal directories.
Click to hide internal directories.