core

package
v0.0.0-...-338bb97 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2022 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const CRIME_PAYLOAD_DATE_KEY = "DATE_KEY"
View Source
const CRIME_PAYLOAD_MSG_KEY = "MSG_KEY"

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Hoods []*Hood `yaml:"hood"`
}

func Load

func Load(path string) (*Config, error)

type Crime

type Crime struct {
	ID           uint
	ReportedTime time.Time
	Type         string
	Payload      map[string]string
}

func NewCrime

func NewCrime(crimeType string, payload map[string]string) *Crime

type HeadQuarter

type HeadQuarter interface {
	Listen()
	ReportCrime() chan *Crime
	ReportError() chan error
}

type Hood

type Hood struct {
	Name      string      `yaml:"name"`
	IsEnabled bool        `yaml:"enabled"`
	Path      string      `yaml:"path"`
	Interval  int         `yaml:"interval"`
	Reporting bool        `yaml:"reporting"`
	Rules     []*HoodRule `yaml:"rules"`
	Hq        HeadQuarter `yaml:"-"`
	Inspector Inspector   `yaml:"-"`
	// contains filtered or unexported fields
}

func (*Hood) HoodInit

func (h *Hood) HoodInit(hq HeadQuarter, l hclog.Logger) error

func (*Hood) Watch

func (h *Hood) Watch()

type HoodRule

type HoodRule struct {
	Name        string         `yaml:"name"`
	Descriotion string         `yaml:"description"`
	Regex       string         `yaml:"regex"`
	Reporting   bool           `yaml:"reporting"`
	Tokens      []string       `yaml:"tokens"`
	Regexp      *regexp.Regexp `yaml:"-"`
}

type Hq

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

func NewHq

func NewHq(l hclog.Logger) *Hq

func (*Hq) Listen

func (hq *Hq) Listen()

func (*Hq) ReportCrime

func (hq *Hq) ReportCrime() chan *Crime

func (*Hq) ReportError

func (hq *Hq) ReportError() chan error

type Inspector

type Inspector interface {
	Investigate()
	OnError(err error)
	ReportCrime(c *Crime)
}

type Investigator

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

func NewInvestigator

func NewInvestigator(event chan *Crime, e chan error, fPath string, rules []*HoodRule, freq int, l hclog.Logger) *Investigator

func (*Investigator) Investigate

func (i *Investigator) Investigate()

func (*Investigator) OnError

func (i *Investigator) OnError(e error)

func (*Investigator) ReportCrime

func (i *Investigator) ReportCrime(c *Crime)

Jump to

Keyboard shortcuts

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