l4vars

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HandleVars

type HandleVars map[string]any

HandleVars is able to set custom context variables to have values that can be used in the Layer 4 connection handler chain. The primary way to access variables is with placeholders, which have the form: `{l4.vars.variable_name}`, or with the `vars` and `vars_regexp` connection matchers.

The key is the variable name, and the value is the value of the variable. Both the name and value may use or contain placeholders.

func (*HandleVars) CaddyModule

func (*HandleVars) CaddyModule() caddy.ModuleInfo

CaddyModule returns the Caddy module information.

func (*HandleVars) Handle

func (h *HandleVars) Handle(cx *layer4.Connection, next layer4.Handler) error

Handle sets custom context variables for the connection.

func (*HandleVars) UnmarshalCaddyfile

func (h *HandleVars) UnmarshalCaddyfile(d *caddyfile.Dispenser) error

UnmarshalCaddyfile sets up the HandleVars from Caddyfile tokens. Syntax:

vars [<variable> <value>] {
    <variable> <value>
    ...
}

type MatchVars

type MatchVars map[string][]string

MatchVars is able to match connections based on variables in the context or placeholder values. The key is the placeholder or name of the variable, and the values are possible values the variable can be in order to match (logical OR'ed).

If the key is surrounded by `{ }`, it is assumed to be a placeholder. Otherwise, it will be considered a variable name.

Placeholders in the keys are not expanded, but placeholders in the values are.

func (*MatchVars) CaddyModule

func (*MatchVars) CaddyModule() caddy.ModuleInfo

CaddyModule returns the Caddy module information.

func (*MatchVars) Match

func (m *MatchVars) Match(cx *layer4.Connection) (bool, error)

Match returns true if the connection satisfies the applicable criteria, i.e. variables in the context or placeholder values have the given values.

func (*MatchVars) UnmarshalCaddyfile

func (m *MatchVars) UnmarshalCaddyfile(d *caddyfile.Dispenser) error

UnmarshalCaddyfile sets up the MatchVars from Caddyfile tokens. Syntax:

vars <variable> <values...>

type MatchVarsRE

type MatchVarsRE map[string]*layer4.MatchRegexp

MatchVarsRE matches variables in the context or placeholder values against a given regular expression.

Upon a match, it adds placeholders to the connection: `{l4.regexp.name.capture_group}` where `name` is the regular expression's name, and `capture_group` is either the named or positional capture group from the expression itself. If no name is given, then the placeholder omits the name: `{l4.regexp.capture_group}` (potentially leading to collisions).

func (*MatchVarsRE) CaddyModule

func (*MatchVarsRE) CaddyModule() caddy.ModuleInfo

CaddyModule returns the Caddy module information.

func (*MatchVarsRE) Match

func (m *MatchVarsRE) Match(cx *layer4.Connection) (bool, error)

Match returns true if the connection satisfies the applicable criteria, i.e. the context variables or placeholders match the given regular expressions.

func (*MatchVarsRE) Provision

func (m *MatchVarsRE) Provision(ctx caddy.Context) error

Provision compiles m's regular expressions.

func (*MatchVarsRE) UnmarshalCaddyfile

func (m *MatchVarsRE) UnmarshalCaddyfile(d *caddyfile.Dispenser) error

UnmarshalCaddyfile sets up the MatchVarsRE from Caddyfile tokens. Syntax:

vars_regexp [<name>] <variable> <regexp>

func (*MatchVarsRE) Validate

func (m *MatchVarsRE) Validate() error

Validate validates m's regular expressions.

Jump to

Keyboard shortcuts

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