summaryrefslogtreecommitdiff
path: root/listeners.go
diff options
context:
space:
mode:
authorMatt Holt <mholt@users.noreply.github.com>2022-08-15 12:01:58 -0600
committerGitHub <noreply@github.com>2022-08-15 12:01:58 -0600
commitc79c08627d36e9871dedd3c7d8889d7d710134c2 (patch)
tree886449e2ce6a2cf39c60f58f2e4d420b5e3a8f1b /listeners.go
parente2a5e2293ab0b06e33445a1243f36cd5def1de42 (diff)
caddyhttp: Enable HTTP/3 by default (#4707)
Diffstat (limited to 'listeners.go')
-rw-r--r--listeners.go12
1 files changed, 10 insertions, 2 deletions
diff --git a/listeners.go b/listeners.go
index 3a8d49d..c7d6d52 100644
--- a/listeners.go
+++ b/listeners.go
@@ -88,11 +88,19 @@ func ListenPacket(network, addr string) (net.PacketConn, error) {
// ListenQUIC returns a quic.EarlyListener suitable for use in a Caddy module.
// Note that the context passed to Accept is currently ignored, so using
// a context other than context.Background is meaningless.
-func ListenQUIC(addr string, tlsConf *tls.Config) (quic.EarlyListener, error) {
+func ListenQUIC(addr string, tlsConf *tls.Config, activeRequests *int64) (quic.EarlyListener, error) {
lnKey := listenerKey("udp", addr)
sharedEl, _, err := listenerPool.LoadOrNew(lnKey, func() (Destructor, error) {
- el, err := quic.ListenAddrEarly(addr, http3.ConfigureTLSConfig(tlsConf), &quic.Config{})
+ el, err := quic.ListenAddrEarly(addr, http3.ConfigureTLSConfig(tlsConf), &quic.Config{
+ RequireAddressValidation: func(clientAddr net.Addr) bool {
+ var highLoad bool
+ if activeRequests != nil {
+ highLoad = atomic.LoadInt64(activeRequests) > 1000 // TODO: make tunable?
+ }
+ return highLoad
+ },
+ })
if err != nil {
return nil, err
}