gerberos package - github.com/admpub/gerberos - Go Packages

gerberos

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2022 License: MIT Imports: 20 Imported by: 2

README

gerberos

gerberos scans sources for lines matching regular expressions and containing IPv4 or IPv6 addresses and performs actions on those addresses. Possible sources are (not necessarily existant) non-directory files, systemd journals, kernel messages, and standard outputs of arbitrary processes. Addresses can be logged or added to ipsets or nft rulesets that gerberos will manage autonomously.

Minimal additional logic is applied. This is to adhere to the Unix philosophy, but impacts gerberos' out-of-the-box usefulness for specific use cases when compared to tools like fail2ban.

Requirements

ipset backend
  • ipset 6.34
  • iptables 1.6.1
nft backend
  • nftables v0.9.3 (tested on Ubuntu 20.04)
Development only
  • Go 1.18
  • GNU Make 4.3 (optional)
  • pgrep (system tests only, optional)

Build

make build

Test

Unit tests only

make test

Unit and system tests

Requires ipset, iptables, and nftables to be installed.

make test_system

Example configuration file (TOML)

See gerberos.toml.

Example systemd service file

See gerberos.service.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDefaultExecutor added in v0.0.2

func NewDefaultExecutor() *defaultExecutor

func NewTestFaultyExecutor added in v0.0.3

func NewTestFaultyExecutor(output string, exitCode int, err error, name string, args ...string) *testFaultyExecutor

func Register added in v0.0.2

func Register(name string, bfn func(*Runner) Backend)

Types

type Backend added in v0.0.2

type Backend interface {
	Initialize() error
	Ban(ip string, ipv6 bool, d time.Duration) error
	Finalize() error
}

func NewIpsetBackend added in v0.0.2

func NewIpsetBackend(rn *Runner) Backend

func NewNftBackend added in v0.0.2

func NewNftBackend(rn *Runner) Backend

func NewTestBackend added in v0.0.2

func NewTestBackend(rn *Runner) Backend

type Configuration

type Configuration struct {
	Verbose      bool
	Backend      string
	SaveFilePath string
	Rules        map[string]*Rule
}

func (*Configuration) Read

func (c *Configuration) Read(r io.Reader) error

func (*Configuration) ReadFile

func (c *Configuration) ReadFile(path string) error

type Executor added in v0.0.2

type Executor interface {
	Execute(name string, args ...string) (string, int, error)
	ExecuteWithStd(stdin io.Reader, stdout io.Writer, name string, args ...string) (string, int, error)
}

type Rule added in v0.0.3

type Rule struct {
	Source      []string
	Regexp      []string
	Action      []string
	Aggregate   []string
	Occurrences []string
	// contains filtered or unexported fields
}

type Runner added in v0.0.2

type Runner struct {
	Configuration *Configuration

	Executor Executor
	// contains filtered or unexported fields
}

func NewRunner

func NewRunner(c *Configuration) *Runner

func (*Runner) Finalize added in v0.0.2

func (rn *Runner) Finalize() error

func (*Runner) Initialize added in v0.0.2

func (rn *Runner) Initialize() error

func (*Runner) Run added in v0.0.2

func (rn *Runner) Run(requeueWorkers bool)

func (*Runner) Stop added in v0.0.2

func (rn *Runner) Stop()

Directories

Path Synopsis
cmd
gerberos command

Jump to

Keyboard shortcuts

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