rule

package
v0.0.0-...-2b49871 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2019 License: GPL-3.0 Imports: 14 Imported by: 1

Documentation

Index

Constants

View Source
const (
	Simple  = Type("simple")
	Regexp  = Type("regexp")
	Complex = Type("complex") // for future use
	List    = Type("list")
)
View Source
const (
	OpTrue                = Operand("true")
	OpProcessPath         = Operand("process.path")
	OpProcessCmd          = Operand("process.command")
	OpProcessEnvPrefix    = Operand("process.env.")
	OpProcessEnvPrefixLen = 12
	OpUserId              = Operand("user.id")
	OpDstIP               = Operand("dest.ip")
	OpDstHost             = Operand("dest.host")
	OpDstPort             = Operand("dest.port")
	OpList                = Operand("list")
)
View Source
const (
	Allow = Action("allow")
	Deny  = Action("deny")
)
View Source
const (
	Once    = Duration("once")
	Restart = Duration("until restart")
	Always  = Duration("always")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action string

type Duration

type Duration string

type Loader

type Loader struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewLoader

func NewLoader(liveReload bool) (*Loader, error)

func (*Loader) Add

func (l *Loader) Add(rule *Rule, saveToDisk bool) error

func (*Loader) FindFirstMatch

func (l *Loader) FindFirstMatch(con *conman.Connection) (match *Rule)

func (*Loader) Load

func (l *Loader) Load(path string) error

func (*Loader) NumRules

func (l *Loader) NumRules() int

func (*Loader) Reload

func (l *Loader) Reload() error

func (*Loader) Save

func (l *Loader) Save(rule *Rule, path string) error

type Operand

type Operand string

type Operator

type Operator struct {
	Type    Type       `json:"type"`
	Operand Operand    `json:"operand"`
	Data    string     `json:"data"`
	List    []Operator `json:"list"`
	// contains filtered or unexported fields
}

func NewOperator

func NewOperator(t Type, o Operand, data string, list []Operator) Operator

func (*Operator) Compile

func (o *Operator) Compile()

func (*Operator) Match

func (o *Operator) Match(con *conman.Connection) bool

func (*Operator) String

func (o *Operator) String() string

type Rule

type Rule struct {
	Created  time.Time `json:"created"`
	Updated  time.Time `json:"updated"`
	Name     string    `json:"name"`
	Enabled  bool      `json:"enabled"`
	Action   Action    `json:"action"`
	Duration Duration  `json:"duration"`
	Operator Operator  `json:"operator"`
}

func Create

func Create(name string, action Action, duration Duration, op Operator) *Rule

func Deserialize

func Deserialize(reply *protocol.Rule) *Rule

func (*Rule) Match

func (r *Rule) Match(con *conman.Connection) bool

func (*Rule) Serialize

func (r *Rule) Serialize() *protocol.Rule

func (*Rule) String

func (r *Rule) String() string

type Type

type Type string

Jump to

Keyboard shortcuts

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