firewall

package
v0.0.0-...-9933dd3 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrIPTablesVersionTooShort = errors.New("iptables version string is too short")
	ErrPolicyUnknown           = errors.New("unknown policy")
	ErrNeedIP6Tables           = errors.New("ip6tables is required, please upgrade your kernel to support it")
)
View Source
var (
	ErrNetAdminMissing      = errors.New("NET_ADMIN capability is missing")
	ErrTestRuleCleanup      = errors.New("failed cleaning up test rule")
	ErrInputPolicyNotFound  = errors.New("input policy not found")
	ErrIPTablesNotSupported = errors.New("no iptables supported found")
)
View Source
var ErrChainListMalformed = errors.New("iptables chain list output is malformed")
View Source
var ErrChainRuleMalformed = errors.New("chain rule is malformed")
View Source
var ErrIptablesCommandMalformed = errors.New("iptables command is malformed")
View Source
var ErrLineNumberIsZero = errors.New("line number is zero")
View Source
var ErrMetricSizeMalformed = errors.New("metric size is malformed")
View Source
var ErrPolicyNotValid = errors.New("policy is not valid")
View Source
var ErrProtocolUnknown = errors.New("unknown protocol")
View Source
var ErrTargetUnknown = errors.New("unknown target")

Functions

This section is empty.

Types

type CmdRunner

type CmdRunner interface {
	Run(cmd *exec.Cmd) (output string, err error)
}

type Config

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

func NewConfig

func NewConfig(ctx context.Context, logger Logger,
	runner CmdRunner, defaultRoutes []routing.DefaultRoute,
	localNetworks []routing.LocalNetwork,
) (config *Config, err error)

NewConfig creates a new Config instance and returns an error if no iptables implementation is available.

func (*Config) RedirectPort

func (c *Config) RedirectPort(ctx context.Context, intf string, sourcePort,
	destinationPort uint16,
) (err error)

RedirectPort redirects a source port to a destination port on the interface intf. If intf is empty, it is set to "*" which means all interfaces. If a redirection for the source port given already exists, it is removed first. If the destination port is zero, the redirection for the source port is removed and no new redirection is added.

func (*Config) RemoveAllowedPort

func (c *Config) RemoveAllowedPort(ctx context.Context, port uint16) (err error)

func (*Config) SetAllowedPort

func (c *Config) SetAllowedPort(ctx context.Context, port uint16, intf string) (err error)

func (*Config) SetEnabled

func (c *Config) SetEnabled(ctx context.Context, enabled bool) (err error)

func (*Config) SetOutboundSubnets

func (c *Config) SetOutboundSubnets(ctx context.Context, subnets []netip.Prefix) (err error)

func (*Config) SetVPNConnection

func (c *Config) SetVPNConnection(ctx context.Context,
	connection models.Connection, vpnIntf string,
) (err error)

func (*Config) Version

func (c *Config) Version(ctx context.Context) (string, error)

Version obtains the version of the installed iptables.

type Logger

type Logger interface {
	Debug(s string)
	Info(s string)
	Warn(s string)
	Error(s string)
}

Jump to

Keyboard shortcuts

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