firewall

package
v0.0.0-...-4a7260b Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2025 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AcceptPolicyStrategy   = "ACCEPT"
	DefaultPolicyStrategy  = "default"
	RejectPolicyStrategy   = "REJECT"
	ContinuePolicyStrategy = "CONTINUE"
	DropPolicyStrategy     = "DROP"
)
View Source
const (
	AcceptZoneStrategy   = "ACCEPT"
	DefaultZoneStrategy  = "default"
	RejectZoneStrategy   = "%%REJECT%%"
	ContinueZoneStrategy = "CONTINUE"
	DropZoneStrategy     = "DROP"
)

Variables

View Source
var NotFoundErr = errors.New("not found")

Functions

func AddPolicy

func AddPolicy(policy Policy) error

func AddPortForward

func AddPortForward(zone string, portForward *PortForward, permanent bool) error

func AddTrafficRule

func AddTrafficRule(zone string, rule *TrafficRule, permanent bool) error

func AddZone

func AddZone(zone *Zone) error

func GetDefaultZone

func GetDefaultZone() (string, error)

func GetICMPTypeNames

func GetICMPTypeNames(permanent bool) ([]string, error)

func GetServiceNames

func GetServiceNames(permanent bool) ([]string, error)

func GetZoneNames

func GetZoneNames(permanent bool) ([]string, error)

func Reload

func Reload() error

func RemovePortForward

func RemovePortForward(zone string, portForward *PortForward, permanent bool) error

func RemoveTrafficRule

func RemoveTrafficRule(zone string, rule *TrafficRule, permanent bool) error

func RemoveZone

func RemoveZone(name string) error

func Reset

func Reset() error

func SetDefaultZone

func SetDefaultZone(name string) error

func UpdatePolicy

func UpdatePolicy(name string, policy Policy, permanent bool) error

UpdatePolicy update policy setting, name, short, target and description field only change in permanent

func UpdateZone

func UpdateZone(name string, zone *Zone, permanent bool) error

UpdateZone update zone setting, name, target and description field only change in permanent

Types

type ForwardProtocol

type ForwardProtocol string
const (
	TCPForwardProtocol  ForwardProtocol = "tcp"
	UDPForwardProtocol  ForwardProtocol = "udp"
	SCTPForwardProtocol ForwardProtocol = "sctp"
	DCCPForwardProtocol ForwardProtocol = "dccp"
)

type Policy

type Policy struct {
	Name         string         `json:"name"`
	Short        string         `json:"short"`
	Description  string         `json:"description"`
	Target       string         `json:"target"`
	IngressZones []string       `json:"ingressZones"`
	EgressZones  []string       `json:"egressZones"`
	Services     []string       `json:"services"`
	ICMPBlocks   []string       `json:"icmpBlocks"`
	Priority     int            `json:"priority"`
	Masquerade   bool           `json:"masquerade"`
	ForwardPorts []*PortForward `json:"forwardPorts"`
	RichRules    []string       `json:"richRules"`
	Protocols    []string       `json:"protocols"`
	Ports        []*Port        `json:"ports"`
	SourcePorts  []*Port        `json:"sourcePorts"`
}

func GetPolicies

func GetPolicies(permanent bool) (result []*Policy, err error)

type PolicyStrategy

type PolicyStrategy string

type Port

type Port struct {
	// Port number or range (8080-8085)
	Port string `json:"port"`
	// Protocol tcp or udp
	Protocol string `json:"protocol"`
}

type PortForward

type PortForward struct {
	// Port port number or range
	Port     string          `json:"port"`
	Protocol ForwardProtocol `json:"protocol"`
	// ToPort port number or range
	ToPort    string `json:"toPort"`
	ToAddress string `json:"toAddress"`
}

func GetPortForwards

func GetPortForwards(zone string, permanent bool) ([]*PortForward, error)

type RuleLog

type RuleLog struct {
	Enabled bool   `json:"enabled"`
	Prefix  string `json:"prefix"`
	// Level emerg、alert、crit、error、warning、notice、info or debug
	Level string `json:"level"`
	Limit string `json:"limit"`
}

type RuleStrategy

type RuleStrategy int
const (
	AcceptRuleStrategy RuleStrategy = iota
	RejectRuleStrategy
	DropRuleStrategy
)

type RuleType

type RuleType string
const (
	ServiceRuleType     RuleType = "service"
	PortRuleType        RuleType = "port"
	ProtocolRuleType    RuleType = "protocol"
	MasqueradeRuleType  RuleType = "masquerade"
	IcmpBlockRuleType   RuleType = "icmp-block"
	ForwardPortRuleType RuleType = "forward-port"
	SourcePortRuleType  RuleType = "source-port"
)

type TrafficRule

type TrafficRule struct {
	// Family ipv4 or ipv6, empty means both
	Family string `json:"family"`
	// SrcAddr source address
	SrcAddr       string `json:"srcAddr,omitempty"`
	SrcAddrInvert bool   `json:"srcAddrInvert,omitempty"`
	// DestAddr destination address
	DestAddr       string          `json:"destAddr,omitempty"`
	DestAddrInvert bool            `json:"destAddrInvert,omitempty"`
	Strategy       RuleStrategy    `json:"strategy"`
	Type           RuleType        `json:"type"`
	Value          json.RawMessage `json:"value"`
	Log            RuleLog         `json:"log"`
	Audit          bool            `json:"audit"`
}

func GetTrafficRules

func GetTrafficRules(zone string, permanent bool) ([]*TrafficRule, error)

type Zone

type Zone struct {
	Name               string       `json:"name"`
	Description        string       `json:"description"`
	Target             ZoneStrategy `json:"target"`
	IngressPriority    int          `json:"ingressPriority"`
	EgressPriority     int          `json:"egressPriority"`
	ICMPBlocks         []string     `json:"icmpBlocks"`
	ICMPBlockInversion bool         `json:"icmpBlockInversion"`
	Masquerade         bool         `json:"masquerade"`
	Forward            bool         `json:"forward"`
	Interfaces         []string     `json:"interfaces"`
	Protocols          []string     `json:"protocols"`
}

func GetZone

func GetZone(name string, permanent bool) (*Zone, error)

func GetZones

func GetZones(permanent bool) (result []*Zone, err error)

type ZoneStrategy

type ZoneStrategy string

Jump to

Keyboard shortcuts

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