Add MASQUE/CONNECT-UDP support (RFC 9298)

Implement UDP tunneling over HTTP/3 using HTTP Datagrams (RFC 9297):
- Add masque handler for server-side CONNECT-UDP
- Add masque connector and h3-masque dialer for client-side
- Add enableDatagrams option to HTTP/3 listener
- Add shared utilities for datagram connections and path parsing

Resource management and connection caching:
- Add deferred stream cleanup in connector on error paths
- Add IsClosed() and Close() methods to Client for proper session management
- Clean up stale cached clients in dialer before reuse
- Close underlying stream when DatagramConn is closed
- Move RequestStream opening from connector to dialer to enable dead
  connection detection and cache invalidation (follows QUIC dialer pattern)
This commit is contained in:
David Manouchehri
2025-12-28 21:13:30 +00:00
committed by ginuerzh
parent b3b5986b63
commit 7625973ca1
11 changed files with 1283 additions and 1 deletions
+3 -1
View File
@@ -75,8 +75,10 @@ func (l *http3Listener) Init(md md.Metadata) (err error) {
},
MaxIncomingStreams: int64(l.md.maxStreams),
Allow0RTT: true,
EnableDatagrams: l.md.enableDatagrams,
},
Handler: http.HandlerFunc(l.handleFunc),
EnableDatagrams: l.md.enableDatagrams,
Handler: http.HandlerFunc(l.handleFunc),
}
ln, err := quic.ListenAddrEarly(addr, http3.ConfigureTLSConfig(l.server.TLSConfig), l.server.QUICConfig.Clone())
+2
View File
@@ -19,6 +19,7 @@ type metadata struct {
maxIdleTimeout time.Duration
handshakeTimeout time.Duration
maxStreams int
enableDatagrams bool
}
func (l *http3Listener) parseMetadata(md mdata.Metadata) (err error) {
@@ -46,6 +47,7 @@ func (l *http3Listener) parseMetadata(md mdata.Metadata) (err error) {
l.md.handshakeTimeout = mdutil.GetDuration(md, handshakeTimeout)
l.md.maxIdleTimeout = mdutil.GetDuration(md, maxIdleTimeout)
l.md.maxStreams = mdutil.GetInt(md, maxStreams)
l.md.enableDatagrams = mdutil.GetBool(md, "enableDatagrams")
return
}