firewall

package
v0.0.0-...-2ec37ed Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2024 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultConfig = "/etc/opensnitchd/system-fw.json"
)

Functions

func CleanRules

func CleanRules(logErrors bool)

CleanRules deletes the rules we added.

func Deserialize

func Deserialize(sysfw *protocol.SysFirewall) ([]byte, error)

Deserialize transforms firewall json configuration to protobuf

func DisableInterception

func DisableInterception() error

DisableInterception removes the rules to intercept outbound connections.

func EnableInterception

func EnableInterception() error

EnableInterception removes the rules to intercept outbound connections.

func ErrChanEmpty

func ErrChanEmpty() bool

ErrChanEmpty checks if the errors channel is empty.

func ErrorsChan

func ErrorsChan() <-chan string

ErrorsChan returns the channel where the errors are sent to.

func Init

func Init(fwType, configPath, monitorInterval string, qNum *int) (err error)

Init initializes the firewall and loads firewall rules. We'll try to use the firewall configured in the configuration (iptables/nftables). If iptables is not installed, we can add nftables rules directly to the kernel, without relying on any binaries.

func IsRunning

func IsRunning() bool

IsRunning returns if the firewall is running or not.

func Reload

func Reload(fwtype, configPath, monitorInterval string) (err error)

Reload stops current firewall and initializes a new one.

func ReloadSystemRules

func ReloadSystemRules()

ReloadSystemRules deletes existing rules, and add them again

func SaveConfiguration

func SaveConfiguration(rawConfig []byte) error

SaveConfiguration saves configuration string to disk

func Serialize

func Serialize() (*protocol.SysFirewall, error)

Serialize transforms firewall json configuration to protobuf

func Stop

func Stop()

Stop deletes the firewall rules, allowing network traffic.

Types

type Firewall

type Firewall interface {
	Init(*int, string, string)
	Stop()
	Name() string
	IsRunning() bool
	SetQueueNum(num *int)

	SaveConfiguration(rawConfig string) error

	EnableInterception()
	DisableInterception(bool)
	QueueDNSResponses(bool, bool) (error, error)
	QueueConnections(bool, bool) (error, error)
	CleanRules(bool)

	AddSystemRules(bool, bool)
	DeleteSystemRules(bool, bool, bool)

	Serialize() (*protocol.SysFirewall, error)
	Deserialize(sysfw *protocol.SysFirewall) ([]byte, error)

	ErrorsChan() <-chan string
	ErrChanEmpty() bool
}

Firewall is the interface that all firewalls (iptables, nftables) must implement.

Directories

Path Synopsis
Package config provides functionality to load and monitor the system firewall rules.
Package config provides functionality to load and monitor the system firewall rules.

Jump to

Keyboard shortcuts

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