Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // VarsCtxKey is the key used to store the variables table // in a Connection's context. VarsCtxKey caddy.CtxKey = "vars" // ReplacerCtxKey is the key used to store the replacer. ReplacerCtxKey caddy.CtxKey = "replacer" )
Functions ¶
This section is empty.
Types ¶
type App ¶
type App struct { Servers map[string]*Server `json:"servers,omitempty"` // contains filtered or unexported fields }
App is a Caddy app that operates closest to layer 4 of the OSI model.
func (App) CaddyModule ¶
func (App) CaddyModule() caddy.ModuleInfo
CaddyModule returns the Caddy module information.
type ConnMatcher ¶
type ConnMatcher interface { // Match returns true if the given connection matches. // It should read from the connection as little as possible: // only as much as necessary to determine a match. Match(*Connection) (bool, error) }
ConnMatcher is a type that can match a connection.
type Connection ¶
type Connection struct { // The underlying connection. net.Conn // The context for the connection. Context context.Context // contains filtered or unexported fields }
Connection contains information about the connection as it passes through various handlers. It also has the capability of recording and rewinding when necessary.
A Connection can be used as a net.Conn because it embeds a net.Conn; but when wrapping underlying connections, usually you want to be careful to replace the embedded Conn, not this entire Connection value.
Connection structs are NOT safe for concurrent use.
func WrapConnection ¶
func WrapConnection(underlying net.Conn, buf *bytes.Buffer) *Connection
WrapConnection wraps an underlying connection into a layer4 connection that supports recording and rewinding, as well as adding context with a replacer and variable table. This function is intended for use at the start of a connection handler chain where the underlying connection is not yet a layer4 Connection value.
func (Connection) GetVar ¶
func (cx Connection) GetVar(key string) interface{}
GetVar gets a value from the context's variable table with the given key. It returns the value if found, and true if it found a value with that key; false otherwise.
func (*Connection) Read ¶
func (cx *Connection) Read(p []byte) (n int, err error)
Read implements io.Reader in such a way that reads first deplete any associated buffer from the prior recording, and once depleted (or if there isn't one), it continues reading from the underlying connection.
func (Connection) SetVar ¶
func (cx Connection) SetVar(key string, value interface{})
SetVar sets a value in the context's variable table with the given key. It overwrites any previous value with the same key.
func (*Connection) Wrap ¶
func (cx *Connection) Wrap(conn net.Conn) *Connection
Wrap wraps conn in a new Connection based on cx (reusing cx's existing buffer and context). This is useful after a connection is wrapped by a package that does not support our Connection type (for example, `tls.Server()`).
type Handler ¶
type Handler interface {
Handle(*Connection) error
}
Handler is a type that can handle connections.
type HandlerFunc ¶
type HandlerFunc func(*Connection) error
HandlerFunc can turn a function into a Handler type.
func (HandlerFunc) Handle ¶
func (h HandlerFunc) Handle(cx *Connection) error
Handle handles a connection; it implements the Handler interface.
type MatchIP ¶
type MatchIP struct { Ranges []string `json:"ranges,omitempty"` // contains filtered or unexported fields }
MatchIP matches requests by remote IP (or CIDR range).
func (MatchIP) CaddyModule ¶
func (MatchIP) CaddyModule() caddy.ModuleInfo
CaddyModule returns the Caddy module information.
type MatcherSet ¶
type MatcherSet []ConnMatcher
MatcherSet is a set of matchers which must all match in order for the request to be matched successfully.
func (MatcherSet) Match ¶
func (mset MatcherSet) Match(cx *Connection) (matched bool, err error)
Match returns true if the connection matches all matchers in mset or if there are no matchers. Any error terminates matching.
type MatcherSets ¶
type MatcherSets []MatcherSet
MatcherSets is a group of matcher sets capable of checking whether a connection matches any of the sets.
func (MatcherSets) AnyMatch ¶
func (mss MatcherSets) AnyMatch(cx *Connection) (matched bool, err error)
AnyMatch returns true if the connection matches any of the matcher sets in mss or if there are no matchers, in which case the request always matches. Any error terminates matching.
func (*MatcherSets) FromInterface ¶
func (mss *MatcherSets) FromInterface(matcherSets interface{}) error
FromInterface fills ms from an interface{} value obtained from LoadModule.
type Middleware ¶
Middleware is a function that wraps a handler.
type NextHandler ¶
type NextHandler interface {
Handle(*Connection, Handler) error
}
NextHandler is a type that can handle connections as part of a middleware chain.
type RawMatcherSets ¶
type RawMatcherSets []caddy.ModuleMap
RawMatcherSets is a group of matcher sets in their raw JSON form.
type Route ¶
type Route struct { MatcherSetsRaw []caddy.ModuleMap `json:"match,omitempty" caddy:"namespace=layer4.matchers"` HandlersRaw []json.RawMessage `json:"handle,omitempty" caddy:"namespace=layer4.handlers inline_key=handler"` // contains filtered or unexported fields }
Route represents a collection of handlers that are gated by matching and other kinds of logic.
type RouteList ¶
type RouteList []*Route
RouteList is a list of connection routes that can create a middleware chain.