app

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2024 License: AGPL-3.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Info  = 0
	Flush = 1
)

Variables

View Source
var SocketPath *string

Functions

func ActionsManager

func ActionsManager(concurrency int)

func ClientFlush

func ClientFlush(format, streamName, filterName string, patterns []string)

TODO : Show values we just flushed - for now we got no details :

  • % ./reaction flush -l ssh.failedlogin login=".*t"
  • ssh:
  • failedlogin:
  • actions:
  • unban:
  • - "2024-04-30 15:27:28"
  • - "2024-04-30 15:27:28"
  • - "2024-04-30 15:27:28"
  • - "2024-04-30 15:27:28" *

func ClientShow

func ClientShow(format, stream, filter string, kvpatterns []string)

func Daemon

func Daemon(confFilename string)

func DatabaseManager

func DatabaseManager(c *Conf)

func Main

func Main(version, commit string)

func MatchesManager

func MatchesManager()

func SocketManager

func SocketManager(conf *Conf)

Handle connections func SocketManager(streams map[string]*Stream) {

func StreamManager

func StreamManager(s *Stream, endedSignal chan *Stream)

func TestRegex added in v1.4.0

func TestRegex(confFilename, regex, line string)

func WithBrackets added in v1.4.0

func WithBrackets(mm []string) string

Types

type Action

type Action struct {
	Filter *Filter `json:"-"`
	Name   string  `json:"-"`

	Cmd []string `json:"cmd"`

	After string `json:"after"`

	OnExit bool `json:"onexit"`
	// contains filtered or unexported fields
}

func (*Action) GobDecode added in v1.4.0

func (a *Action) GobDecode(b []byte) error

func (*Action) GobEncode added in v1.4.0

func (a *Action) GobEncode() ([]byte, error)

type ActionsMap

type ActionsMap map[PA]map[time.Time]struct{}

type ClientStatus

type ClientStatus map[string]map[string]MapPatternStatus

type ClientStatusFlush

type ClientStatusFlush ClientStatus

func (ClientStatusFlush) MarshalJSON

func (csf ClientStatusFlush) MarshalJSON() ([]byte, error)

type Conf

type Conf struct {
	Concurrency int                 `json:"concurrency"`
	Patterns    map[string]*Pattern `json:"patterns"`
	Streams     map[string]*Stream  `json:"streams"`
	Start       [][]string          `json:"start"`
	Stop        [][]string          `json:"stop"`
}

func (*Conf) RotateDB

func (c *Conf) RotateDB(startup bool) (*WriteDB, *WriteDB)

type Filter

type Filter struct {
	Stream *Stream `json:"-"`
	Name   string  `json:"-"`

	Regex []string `json:"regex"`

	Pattern []*Pattern `json:"-"`

	Retry       int    `json:"retry"`
	RetryPeriod string `json:"retryperiod"`

	Actions map[string]*Action `json:"actions"`
	// contains filtered or unexported fields
}

func (*Filter) GobDecode added in v1.4.0

func (f *Filter) GobDecode(b []byte) error

func (*Filter) GobEncode added in v1.4.0

func (f *Filter) GobEncode() ([]byte, error)

type LilAction added in v1.4.0

type LilAction struct {
	Filter *Filter
	Name   string
}

type LilFilter added in v1.4.0

type LilFilter struct {
	Stream  *Stream
	Name    string
	Pattern []*Pattern
}

those small versions are needed to prevent infinite recursion in gob because of data cycles: Stream <-> Filter, Filter <-> Action

type LilStream added in v1.4.0

type LilStream struct {
	Name string
}

type LogEntry

type LogEntry struct {
	T              time.Time
	S              int64
	Pattern        Match
	Stream, Filter string
	SF             int
	Exec           bool
}

type MapPatternStatus

type MapPatternStatus map[Match]*PatternStatus

type MapPatternStatusFlush

type MapPatternStatusFlush MapPatternStatus

func (MapPatternStatusFlush) MarshalJSON

func (mps MapPatternStatusFlush) MarshalJSON() ([]byte, error)

type Match

type Match string

This is a "\x00" Joined string which contains all matches on a line.

func JoinMatch added in v1.4.0

func JoinMatch(mm []string) Match

func (*Match) Split added in v1.4.0

func (m *Match) Split() []string

type MatchesMap

type MatchesMap map[PF]map[time.Time]struct{}

type PA

type PA struct {
	P Match
	A *Action
}

type PAT

type PAT struct {
	P Match
	A *Action
	T time.Time
}

type PF

type PF struct {
	P Match
	F *Filter
}

type PFT

type PFT struct {
	P Match
	F *Filter
	T time.Time
}

type PSF

type PSF struct {
	P    Match
	S, F string
}

Pattern, Stream, Filter

type Pattern

type Pattern struct {
	Regex  string   `json:"regex"`
	Ignore []string `json:"ignore"`

	IgnoreRegex []string `json:"ignoreregex"`

	Name string `json:"-"`
	// contains filtered or unexported fields
}

type PatternStatus

type PatternStatus struct {
	Matches int                 `json:"matches,omitempty"`
	Actions map[string][]string `json:"actions,omitempty"`
}

type ReadDB

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

type Request

type Request struct {
	Request int
	Flush   PSF
}

type Response

type Response struct {
	Err error
	// Config  Conf
	Matches MatchesMap
	Actions ActionsMap
}

func SendAndRetrieve

func SendAndRetrieve(data Request) Response

type SF

type SF struct{ S, F string }

Helper structs made to carry information Stream, Filter

type Stream

type Stream struct {
	Name string `json:"-"`

	Cmd     []string           `json:"cmd"`
	Filters map[string]*Filter `json:"filters"`
}

func (*Stream) GobDecode added in v1.4.0

func (s *Stream) GobDecode(b []byte) error

func (*Stream) GobEncode added in v1.4.0

func (s *Stream) GobEncode() ([]byte, error)

type WriteDB

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

Jump to

Keyboard shortcuts

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