From f596fd77bb6880485d2bfc6b18a775b5572da260 Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Sun, 15 Mar 2020 21:26:17 -0600 Subject: caddyhttp: Add support for listener wrapper modules Wrapping listeners is useful for composing custom behavior related to accepting, closing, reading/writing connections (etc) below the application layer; for example, the PROXY protocol. --- modules/caddyhttp/server.go | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'modules/caddyhttp/server.go') diff --git a/modules/caddyhttp/server.go b/modules/caddyhttp/server.go index 1e22790..461865c 100644 --- a/modules/caddyhttp/server.go +++ b/modules/caddyhttp/server.go @@ -16,6 +16,7 @@ package caddyhttp import ( "context" + "encoding/json" "fmt" "net" "net/http" @@ -38,6 +39,10 @@ type Server struct { // that may include port ranges. Listen []string `json:"listen,omitempty"` + // A list of listener wrapper modules, which can modify the behavior + // of the base listener. They are applied in the given order. + ListenerWrappersRaw []json.RawMessage `json:"listener_wrappers,omitempty" caddy:"namespace=caddy.listeners inline_key=wrapper"` + // How long to allow a read from a client's upload. Setting this // to a short, non-zero value can mitigate slowloris attacks, but // may also affect legitimately slow clients. @@ -106,6 +111,7 @@ type Server struct { primaryHandlerChain Handler errorHandlerChain Handler + listenerWrappers []caddy.ListenerWrapper tlsApp *caddytls.TLS logger *zap.Logger -- cgit v1.2.3