ufw

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2026 License: MIT Imports: 7 Imported by: 0

README

Go-UFW

UFW firewall golang client

Documentation

Index

Constants

View Source
const (
	ModeAllow  Mode = "allow"
	ModeDeny   Mode = "deny"
	ModeReject Mode = "reject"
	ModeLimit  Mode = "limit"

	DirectionIn      Direction = "in"
	DirectionOut     Direction = "out"
	DirectionForward Direction = "fwd"

	ProtoTCP Proto = "tcp"
	ProtoUDP Proto = "udp"

	ProtoAH   Proto = "ah"   // valid without port number
	ProtoESP  Proto = "esp"  // valid without port number
	ProtoGRE  Proto = "gre"  // valid without port number
	ProtoIPV6 Proto = "ipv6" // valid for IPv4 addresses and without port number
	ProtoIGMP Proto = "igmp" // valid for IPv4 addresses and without port number
)

Variables

Functions

func Default

func Default(mode Mode, direction Direction) error

func Delete

func Delete(rule Rule) error

func DeleteNumber

func DeleteNumber(n int) error

func Disable

func Disable() error

func DisableLogging

func DisableLogging() error

func Enable

func Enable() error

func EnableLogging

func EnableLogging() error

func Reload

func Reload() error

func Reset

func Reset() error

func Set

func Set(rule Rule) error

Types

type Direction

type Direction string

func (Direction) IsValid

func (v Direction) IsValid() bool

func (Direction) Name

func (v Direction) Name() string

type Host

type Host struct {
	Address   string   `json:"address"`
	Ports     []string `json:"ports"`
	Proto     Proto    `json:"proto"`
	Interface string   `json:"interface"`
	IPV6      bool     `json:"ipv6"`
}

func (Host) Command

func (v Host) Command() []string

type Mode

type Mode string

func (Mode) IsValid

func (v Mode) IsValid() bool

type Proto

type Proto string

func (Proto) IsValid

func (v Proto) IsValid() bool

type Rule

type Rule struct {
	IsRoute   bool      `json:"is_route"`
	Insert    int       `json:"insert"`
	Mode      Mode      `json:"mode"`
	Direction Direction `json:"direction"`
	From      Host      `json:"from"`
	To        Host      `json:"to"`
	Comment   string    `json:"comment"`
}

func Status

func Status() ([]Rule, error)

func (Rule) Command

func (v Rule) Command() []string

func (Rule) IsValid

func (v Rule) IsValid() error

type UFW

type UFW struct {
	Bin string
}

func (UFW) Default

func (ufw UFW) Default(mode Mode, direction Direction) error

Default change the default policy for traffic going DIRECTION

func (UFW) Delete

func (ufw UFW) Delete(rule Rule) error

Delete the corresponding rule

func (UFW) DeleteNumber

func (ufw UFW) DeleteNumber(n int) error

DeleteNumber the corresponding rule number

func (UFW) Disable

func (ufw UFW) Disable() error

Disable unloads firewall and disables firewall on boot

func (UFW) DisableLogging

func (ufw UFW) DisableLogging() error

DisableLogging Logged packets use the LOG_KERN syslog facility

func (UFW) Enable

func (ufw UFW) Enable() error

Enable reloads firewall and enables firewall on boot

func (UFW) EnableLogging

func (ufw UFW) EnableLogging() error

EnableLogging Logged packets use the LOG_KERN syslog facility

func (UFW) Reload

func (ufw UFW) Reload() error

Reload reloads firewall

func (UFW) Reset

func (ufw UFW) Reset() error

Reset Disables and resets firewall to installation defaults.

func (UFW) Set

func (ufw UFW) Set(rule Rule) error

Set add rule

func (UFW) Status

func (ufw UFW) Status() ([]Rule, error)

Status return list of rules

Jump to

Keyboard shortcuts

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