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. --- listeners.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'listeners.go') diff --git a/listeners.go b/listeners.go index ae1873f..0bbee8a 100644 --- a/listeners.go +++ b/listeners.go @@ -386,6 +386,19 @@ func JoinNetworkAddress(network, host, port string) string { return a } +// ListenerWrapper is a type that wraps a listener +// so it can modify the input listener's methods. +// Modules that implement this interface are found +// in the caddy.listeners namespace. Usually, to +// wrap a listener, you will define your own struct +// type that embeds the input listener, then +// implement your own methods that you want to wrap, +// calling the underlying listener's methods where +// appropriate. +type ListenerWrapper interface { + WrapListener(net.Listener) net.Listener +} + var ( listeners = make(map[string]*globalListener) listenersMu sync.Mutex -- cgit v1.2.3