biz

package
v0.3.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 25, 2024 License: Apache-2.0 Imports: 12 Imported by: 1

Documentation

Index

Constants

View Source
const (
	TableFilter = `filter`
	TableNAT    = `nat`
	TableMangle = `mangle`
	TableRaw    = `raw`
)
View Source
const (
	ChainInput       = `INPUT`
	ChainOutput      = `OUTPUT`
	ChainForward     = `FORWARD`
	ChainPreRouting  = `PREROUTING`
	ChainPostRouting = `POSTROUTING`
)
View Source
const (
	ApplyTypeHTTP = `http`
	ApplyTypeSMTP = `smtp`
	ApplyTypeDNS  = `smtp`
)
View Source
const (
	SET_TRUST     = 1   // add filterSetTrustIP
	SET_MANAGER   = 2   // add filterSetManagerIP
	SET_FORWARD   = 4   // add filterSetForwardIP
	SET_BLACKLIST = 8   // add filterSetBlacklistIP
	SET_ALL       = 512 // add filterSetTrustIP filterSetManagerIP filterSetForwardIP filterSetBlacklistIP
)
View Source
const (
	RULE_LOCAL_IFACE        = 1
	RULE_WAN_IFACE          = 2
	RULE_SDN                = 4
	RULE_SDN_FORWARD        = 8
	RULE_NAT                = 16
	RULE_BLACKLIST          = 32
	RULE_INPUT_LOCAL_IFACE  = 64
	RULE_OUTPUT_LOCAL_IFACE = 128
	RULE_ALL                = 512
)

Variables

Functions

This section is empty.

Types

type Config

type Config struct {
	Enabled          bool
	NetworkNamespace string
	DefaultPolicy    string // accept / drop
	TablePrefix      string
	TableSuffix      string
	Applies          []string
	MyIface          string
	MyPort           uint16
	ClearRuleset     bool
	DisableInitSet   bool
	Ifaces           []string
	TrustPorts       []uint16
}

Config for nftables.

func (*Config) CanApply

func (c *Config) CanApply(name string) bool

type INFTables

type INFTables interface {
	// UpdateTrustIPs updates filterSetTrustIP.
	UpdateTrustIPs(del, add []net.IP) error

	// UpdateManagerIPs updates filterSetManagerIP.
	UpdateManagerIPs(del, add []net.IP) error

	// UpdateMyForwardWanIPs updates filterSetForwardIP.
	UpdateForwardWanIPs(del, add []net.IP) error

	// Ban adding ip to backlist.
	Ban(ipAddresses []string, timeout time.Duration) error

	// Cleanup rules to default policy filtering.
	Cleanup() error

	// WanIP returns ip address of wan interface.
	WanIP() net.IP

	// IfacesIPs returns ip addresses list of additional ifaces.
	IfacesIPs() ([]net.IP, error)

	TableFilter() *nftables.Table
	ChainInput() *nftables.Chain
	ChainForward() *nftables.Chain
	ChainOutput() *nftables.Chain

	TableNAT() *nftables.Table
	ChainPrerouting() *nftables.Chain
	ChainPostrouting() *nftables.Chain

	FilterSetTrustIP() *nftables.Set
	FilterSetManagerIP() *nftables.Set
	FilterSetForwardIP() *nftables.Set
	FilterSetBlacklistIP() *nftables.Set

	Do(f func(conn *nftables.Conn) error) error
}

type NFTables

type NFTables struct {
	// contains filtered or unexported fields
}

NFTables struct.

func New

func New(tableFamily nftables.TableFamily, c Config, managerPorts []uint16) *NFTables

func (*NFTables) ApplyBase

func (nft *NFTables) ApplyBase(c *nftables.Conn) error

func (*NFTables) ApplyDefault

func (nft *NFTables) ApplyDefault(flag int) error

func (*NFTables) ApplyFilterRule added in v0.2.2

func (nft *NFTables) ApplyFilterRule(c *nftables.Conn, flag int) (err error)

func (*NFTables) Ban added in v0.2.2

func (nft *NFTables) Ban(ipAddresses []string, timeout time.Duration) error

Ban adding ip to backlist.

func (*NFTables) ChainForward

func (nft *NFTables) ChainForward() *nftables.Chain

func (*NFTables) ChainInput

func (nft *NFTables) ChainInput() *nftables.Chain

func (*NFTables) ChainOutput

func (nft *NFTables) ChainOutput() *nftables.Chain

func (*NFTables) ChainPostrouting

func (nft *NFTables) ChainPostrouting() *nftables.Chain

func (*NFTables) ChainPrerouting

func (nft *NFTables) ChainPrerouting() *nftables.Chain

func (*NFTables) Cleanup

func (nft *NFTables) Cleanup() error

Cleanup rules to default policy filtering.

func (*NFTables) DeleteAll added in v0.3.0

func (nft *NFTables) DeleteAll(c *nftables.Conn)

func (*NFTables) DeleteChain added in v0.3.0

func (nft *NFTables) DeleteChain(c *nftables.Conn, chains ...*nftables.Chain)

func (*NFTables) DeleteSet added in v0.3.0

func (nft *NFTables) DeleteSet(c *nftables.Conn, sets ...*nftables.Set)

func (*NFTables) Do

func (nft *NFTables) Do(f func(conn *nftables.Conn) error) error

func (*NFTables) FilterSetBlacklistIP added in v0.2.2

func (nft *NFTables) FilterSetBlacklistIP() *nftables.Set

func (*NFTables) FilterSetForwardIP added in v0.2.2

func (nft *NFTables) FilterSetForwardIP() *nftables.Set

func (*NFTables) FilterSetManagerIP added in v0.2.2

func (nft *NFTables) FilterSetManagerIP() *nftables.Set

func (*NFTables) FilterSetTrustIP

func (nft *NFTables) FilterSetTrustIP() *nftables.Set

func (*NFTables) FlushChain added in v0.3.0

func (nft *NFTables) FlushChain(c *nftables.Conn, chains ...*nftables.Chain)

func (*NFTables) FlushSet added in v0.3.0

func (nft *NFTables) FlushSet(c *nftables.Conn, sets ...*nftables.Set)

func (*NFTables) IfacesIPs

func (nft *NFTables) IfacesIPs() ([]net.IP, error)

IfacesIPs returns ip addresses list of additional ifaces.

func (*NFTables) Init

func (nft *NFTables) Init() error

Init nftables firewall.

func (*NFTables) InitSet added in v0.1.3

func (nft *NFTables) InitSet(c *nftables.Conn, flag int) error

InitSet init sets example: InitSet(c, SET_TRUST|SET_MANAGER)

func (*NFTables) TableFilter

func (nft *NFTables) TableFilter() *nftables.Table

func (*NFTables) TableNAT

func (nft *NFTables) TableNAT() *nftables.Table

func (*NFTables) UpdateForwardWanIPs added in v0.2.2

func (nft *NFTables) UpdateForwardWanIPs(del, add []net.IP) error

UpdateForwardWanIPs updates filterSetForwardIP.

func (*NFTables) UpdateManagerIPs added in v0.2.2

func (nft *NFTables) UpdateManagerIPs(del, add []net.IP) error

UpdateManagerIPs updates filterSetManagerIP.

func (*NFTables) UpdateTrustIPs

func (nft *NFTables) UpdateTrustIPs(del, add []net.IP) error

UpdateTrustIPs updates filterSetTrustIP.

func (*NFTables) WanIP

func (nft *NFTables) WanIP() net.IP

WanIP returns ip address of wan interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL