Help us shape the future of Go! Take the 2026 Go Developer Survey

goshorewall

package module
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2026 License: AGPL-3.0 Imports: 11 Imported by: 0

README

go-shorewall

A Go library for managing the Shorewall firewall.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInterfaceAlreadyExists = errors.New("interface already exists")
	ErrInterfaceNotFound      = errors.New("interface not found")
)
View Source
var (
	ErrPolicyAlreadyExists = errors.New("policy already exists")
	ErrPolicyNotFound      = errors.New("policy not found")
)
View Source
var (
	ErrRuleAlreadyExists = errors.New("rule already exists")
	ErrRuleNotFound      = errors.New("rule not found")
)
View Source
var (
	ErrSnatAlreadyExists = errors.New("snat rule already exists")
	ErrSnatNotFound      = errors.New("snat rule not found")
)
View Source
var (
	ErrZoneAlreadyExists = errors.New("zone already exists")
	ErrZoneNotFound      = errors.New("zone not found")
)

Functions

func AddInterface

func AddInterface(iface Interface) error

func AddPolicy

func AddPolicy(policy Policy) error

func AddRule

func AddRule(rule Rule) error

func AddSnat

func AddSnat(snat Snat) error

func AddZone

func AddZone(zone Zone) error

func Reload added in v0.0.2

func Reload() error

func RemoveInterfaceByZone

func RemoveInterfaceByZone(zone string) error

func RemovePolicy

func RemovePolicy(policy Policy) error

func RemoveRule

func RemoveRule(rule Rule) error

func RemoveSnat

func RemoveSnat(snat Snat) error

func RemoveZone

func RemoveZone(zoneName string) error

func Version added in v0.0.7

func Version() (string, error)

Types

type App added in v0.0.7

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

App represents a single application that can manage Shorewall configurations. This solves the problem of having multiple independent application managing Shorewall in the same system. App use a random generated identifier to isolate its configuration from other applications. This identifier must be saved by the application to be able to manage its Shorewall configuration across restarts. App also handles concurrent access to Shorewall configuration files.

func AppFromID added in v0.0.7

func AppFromID(id string) (*App, error)

AppFromID creates an App instance from a previously saved identifier.

func AppFromIDAndBasePath added in v0.0.7

func AppFromIDAndBasePath(id, basePath string) (*App, error)

func NewApp added in v0.0.7

func NewApp() (*App, error)

NewApp creates a new App with a random generated identifier. This must be called only once per application installation. After saving the identifier with App.ID(), the application should use AppFromID to retrieve the App instance on subsequent runs.

func NewAppWithBasePath added in v0.0.7

func NewAppWithBasePath(basePath string) (*App, error)

func (*App) AddInterface added in v0.0.7

func (a *App) AddInterface(iface Interface) error

AddInterface adds a new interface to the Shorewall configuration managed by the App instance.

func (*App) AddPolicy added in v0.0.7

func (a *App) AddPolicy(policy Policy) error

AddPolicy adds a new policy to the Shorewall configuration managed by the App instance.

func (*App) AddRule added in v0.0.7

func (a *App) AddRule(rule Rule) error

AddRule adds a new rule to the Shorewall configuration managed by the App instance.

func (*App) AddSnat added in v0.0.7

func (a *App) AddSnat(snat Snat) error

AddSnat adds a new SNAT to the Shorewall configuration managed by the App instance.

func (*App) AddZone added in v0.0.7

func (a *App) AddZone(zone Zone) error

AddZone adds a new zone to the Shorewall configuration managed by the App instance.

func (*App) BasePath added in v0.0.7

func (a *App) BasePath() string

BasePath returns the Shorewall configuration base path used by the App instance.

func (*App) ID added in v0.0.7

func (a *App) ID() string

ID returns the unique identifier of the App instance.

func (*App) InterfaceFilePath added in v0.0.7

func (a *App) InterfaceFilePath() string

InterfaceFilePath returns the full path to the interfaces file used by the App instance.

func (*App) Interfaces added in v0.0.7

func (a *App) Interfaces() ([]Interface, error)

Interfaces returns the list of interfaces managed by the App instance.

func (*App) Policies added in v0.0.7

func (a *App) Policies() ([]Policy, error)

Policies returns the list of policies managed by the App instance.

func (*App) PolicyFilePath added in v0.0.7

func (a *App) PolicyFilePath() string

PolicyFilePath returns the full path to the policy file used by the App instance.

func (*App) Reload added in v0.0.7

func (a *App) Reload() error

Reload reloads Shorewall configuration.

func (*App) RemoveInterfaceByZone added in v0.0.7

func (a *App) RemoveInterfaceByZone(zone string) error

RemoveInterfaceByZone removes all interfaces associated with the specified zone

func (*App) RemovePolicy added in v0.0.7

func (a *App) RemovePolicy(policy Policy) error

RemovePolicy removes a policy from the Shorewall configuration managed by the App instance.

func (*App) RemoveRule added in v0.0.7

func (a *App) RemoveRule(rule Rule) error

RemoveRule removes a rule from the Shorewall configuration managed by the App instance.

func (*App) RemoveSnat added in v0.0.7

func (a *App) RemoveSnat(snat Snat) error

RemoveSnat removes a SNAT from the Shorewall configuration managed by the App instance.

func (*App) RemoveZone added in v0.0.7

func (a *App) RemoveZone(zoneName string) error

RemoveZone removes a zone from the Shorewall configuration managed by the App instance.

func (*App) Rules added in v0.0.7

func (a *App) Rules() ([]Rule, error)

Rules returns the list of rules managed by the App instance.

func (*App) RulesFilePath added in v0.0.7

func (a *App) RulesFilePath() string

RulesFilePath returns the full path to the rules file used by the App instance.

func (*App) SnatFilePath added in v0.0.7

func (a *App) SnatFilePath() string

SnatFilePath returns the full path to the snat file used by the App instance.

func (*App) Snats added in v0.0.7

func (a *App) Snats() ([]Snat, error)

Snats returns the list of SNATs managed by the App instance.

func (*App) Version added in v0.0.7

func (a *App) Version() (string, error)

Version returns the Shorewall version.

func (*App) Zones added in v0.0.7

func (a *App) Zones() ([]Zone, error)

Zones returns the list of zones managed by the App instance.

func (*App) ZonesFilePath added in v0.0.7

func (a *App) ZonesFilePath() string

ZonesFilePath returns the full path to the zones file used by the App instance.

type Interface

type Interface struct {
	Zone string
	Name string
}

func Interfaces added in v0.0.7

func Interfaces() ([]Interface, error)

func (Interface) Compare added in v0.0.7

func (i Interface) Compare(other Interface) int

func (Interface) Equals added in v0.0.7

func (i Interface) Equals(other Interface) bool

func (Interface) Format added in v0.0.7

func (i Interface) Format() string

type Policy

type Policy struct {
	Source      string
	Destination string
	Policy      string
	Log         string
}

func Policies added in v0.0.7

func Policies() ([]Policy, error)

func (Policy) Compare added in v0.0.7

func (p Policy) Compare(other Policy) int

func (Policy) Equals added in v0.0.7

func (p Policy) Equals(other Policy) bool

func (Policy) Format added in v0.0.7

func (p Policy) Format() string

type Rule

type Rule struct {
	Action      string
	Source      string
	Destination string
	Protocol    string
	Dport       string
	Sport       string
	Origdest    string
}

func Rules added in v0.0.7

func Rules() ([]Rule, error)

func (Rule) Compare added in v0.0.6

func (r Rule) Compare(other Rule) int

func (Rule) Equals added in v0.0.6

func (r Rule) Equals(other Rule) bool

func (Rule) Format added in v0.0.7

func (r Rule) Format() string

type Snat

type Snat struct {
	Action      string
	Source      string
	Destination string
}

func Snats added in v0.0.7

func Snats() ([]Snat, error)

func (Snat) Compare added in v0.0.7

func (s Snat) Compare(other Snat) int

func (Snat) Equals added in v0.0.7

func (s Snat) Equals(other Snat) bool

func (Snat) Format added in v0.0.7

func (s Snat) Format() string

type Zone

type Zone struct {
	Name string
	Type string
}

func Zones added in v0.0.7

func Zones() ([]Zone, error)

Jump to

Keyboard shortcuts

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