mirror of
https://github.com/caddyserver/caddy.git
synced 2025-05-24 11:41:19 +08:00
caddyhttp: Enable HTTP/3 by default (#4707)
This commit is contained in:
12
listeners.go
12
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
|
||||
}
|
||||
|
Reference in New Issue
Block a user