Commit 620f9687 authored by Matthew Holt's avatar Matthew Holt

Merge branch 'reload-ln-middleware'

parents 2c436167 4f5df39b
......@@ -354,6 +354,11 @@ type GracefulServer interface {
// address; you must store the address the
// server is to serve on some other way.
Address() string
// WrapListener wraps a listener with the
// listener middlewares configured for this
// server, if any.
WrapListener(net.Listener) net.Listener
}
// Listener is a net.Listener with an underlying file descriptor.
......@@ -729,6 +734,7 @@ func startServers(serverList []Server, inst *Instance, restartFds map[string]res
return err
}
}
ln = gs.WrapListener(ln)
}
}
......@@ -767,6 +773,7 @@ func startServers(serverList []Server, inst *Instance, restartFds map[string]res
return err
}
}
ln = gs.WrapListener(ln)
}
}
......
......@@ -274,16 +274,26 @@ func (s *Server) Listen() (net.Listener, error) {
ln = tcpKeepAliveListener{TCPListener: tcpLn}
}
cln := s.WrapListener(ln)
// Very important to return a concrete caddy.Listener
// implementation for graceful restarts.
return cln.(caddy.Listener), nil
}
// WrapListener wraps ln in the listener middlewares configured
// for this server.
func (s *Server) WrapListener(ln net.Listener) net.Listener {
if ln == nil {
return nil
}
cln := ln.(caddy.Listener)
for _, site := range s.sites {
for _, m := range site.listenerMiddleware {
cln = m(cln)
}
}
// Very important to return a concrete caddy.Listener
// implementation for graceful restarts.
return cln.(caddy.Listener), nil
return cln
}
// ListenPacket creates udp connection for QUIC if it is enabled,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment