sequence

package
v5.3.1 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2023 License: GPL-3.0 Imports: 11 Imported by: 1

Documentation

Index

Constants

View Source
const PluginType = "sequence"

Variables

This section is empty.

Functions

func Init

func Init(bp *coremain.BP, args any) (any, error)

func MustRegExecQuickSetup

func MustRegExecQuickSetup(typ string, f ExecQuickSetupFunc)

func MustRegMatchQuickSetup

func MustRegMatchQuickSetup(typ string, f MatchQuickSetupFunc)

func RegExecQuickSetup

func RegExecQuickSetup(typ string, f ExecQuickSetupFunc) error

func RegMatchQuickSetup

func RegMatchQuickSetup(typ string, f MatchQuickSetupFunc) error

Types

type ActionAccept

type ActionAccept struct{}

func (ActionAccept) Exec

type ActionGoto

type ActionGoto struct {
	To []*ChainNode
}

func (ActionGoto) Exec

type ActionJump

type ActionJump struct {
	To []*ChainNode
}

func (*ActionJump) Exec

func (a *ActionJump) Exec(ctx context.Context, qCtx *query_context.Context, next ChainWalker) error

type ActionReject

type ActionReject struct {
	Rcode int
}

func (ActionReject) Exec

type ActionReturn

type ActionReturn struct{}

func (ActionReturn) Exec

type Args

type Args = []RuleArgs

type BQ

type BQ interface {
	// M returns a non-nil *coremain.Mosdns.
	M() *coremain.Mosdns
	// L returns a non-nil *zap.Logger.
	L() *zap.Logger
}

func NewBQ

func NewBQ(m *coremain.Mosdns, l *zap.Logger) BQ

type ChainNode

type ChainNode struct {
	Matches []Matcher // Can be empty, indicates this node has no match specified.

	// At least one of E or RE must not nil.
	// In case both are set. E is preferred.
	E  Executable
	RE RecursiveExecutable
}

type ChainWalker

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

func NewChainWalker

func NewChainWalker(chain []*ChainNode, jumpBack *ChainWalker) ChainWalker

func (*ChainWalker) ExecNext

func (w *ChainWalker) ExecNext(ctx context.Context, qCtx *query_context.Context) error

type ExecQuickSetupFunc

type ExecQuickSetupFunc func(bq BQ, args string) (any, error)

ExecQuickSetupFunc configures an Executable or RecursiveExecutable with a simple string args.

func GetExecQuickSetup

func GetExecQuickSetup(typ string) ExecQuickSetupFunc

type Executable

type Executable interface {
	Exec(ctx context.Context, qCtx *query_context.Context) error
}

Executable represents something that is executable.

func ToExecutable

func ToExecutable(v any) Executable

type ExecutableFunc

type ExecutableFunc func(ctx context.Context, qCtx *query_context.Context) error

func (ExecutableFunc) Exec

type MatchAlwaysFalse

type MatchAlwaysFalse struct{}

func (MatchAlwaysFalse) Match

type MatchAlwaysTrue

type MatchAlwaysTrue struct{}

func (MatchAlwaysTrue) Match

type MatchConfig

type MatchConfig struct {
	Tag     string `yaml:"tag"`
	Type    string `yaml:"type"`
	Args    string `yaml:"args"`
	Reverse bool   `yaml:"reverse"`
}

type MatchFunc

type MatchFunc func(ctx context.Context, qCtx *query_context.Context) (bool, error)

func (MatchFunc) Match

func (f MatchFunc) Match(ctx context.Context, qCtx *query_context.Context) (bool, error)

type MatchQuickSetupFunc

type MatchQuickSetupFunc func(bq BQ, args string) (Matcher, error)

MatchQuickSetupFunc configures a Matcher with a simple string args.

func GetMatchQuickSetup

func GetMatchQuickSetup(typ string) MatchQuickSetupFunc

type Matcher

type Matcher interface {
	Match(ctx context.Context, qCtx *query_context.Context) (bool, error)
}

Matcher represents a matcher that can match a certain patten in Context.

type QuickConfigurableExec

type QuickConfigurableExec interface {
	QuickConfigureExec(args string) (any, error)
}

QuickConfigurableExec can configure an exiting plugin with additional args. Expecting return is an Executable or RecursiveExecutable.

type QuickConfigurableMatch

type QuickConfigurableMatch interface {
	QuickConfigureMatch(args string) (Matcher, error)
}

QuickConfigurableMatch can configure an exiting plugin with additional args.

type RecursiveExecutable

type RecursiveExecutable interface {
	Exec(ctx context.Context, qCtx *query_context.Context, next ChainWalker) error
}

RecursiveExecutable represents something that is executable and requires stack.

type RecursiveExecutableFunc

type RecursiveExecutableFunc func(ctx context.Context, qCtx *query_context.Context, next ChainWalker) error

func (RecursiveExecutableFunc) Exec

type RuleArgs

type RuleArgs struct {
	Matches []string `yaml:"matches"`
	Exec    string   `yaml:"exec"`
}

type RuleConfig

type RuleConfig struct {
	Matches []MatchConfig `yaml:"matches"`
	Tag     string        `yaml:"tag"`
	Type    string        `yaml:"type"`
	Args    string        `yaml:"args"`
}

type Sequence

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

func NewSequence

func NewSequence(bq BQ, ra []RuleArgs) (*Sequence, error)

func (*Sequence) Close

func (s *Sequence) Close() error

func (*Sequence) Exec

func (s *Sequence) Exec(ctx context.Context, qCtx *query_context.Context) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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