Files
x/dialer/http3/masque/metadata.go
T
David Manouchehri 7625973ca1 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)
2026-04-21 19:53:07 +08:00

44 lines
1.0 KiB
Go

package masque
import (
"time"
mdata "github.com/go-gost/core/metadata"
mdutil "github.com/go-gost/x/metadata/util"
)
const (
mdKeyHost = "host"
mdKeyKeepAlive = "keepAlive"
mdKeyKeepAlivePeriod = "ttl"
mdKeyHandshakeTimeout = "handshakeTimeout"
mdKeyMaxIdleTimeout = "maxIdleTimeout"
mdKeyMaxStreams = "maxStreams"
)
type metadata struct {
host string
// QUIC config options
keepAlivePeriod time.Duration
maxIdleTimeout time.Duration
handshakeTimeout time.Duration
maxStreams int
}
func (d *masqueDialer) parseMetadata(md mdata.Metadata) (err error) {
d.md.host = mdutil.GetString(md, mdKeyHost)
if mdutil.GetBool(md, mdKeyKeepAlive) {
d.md.keepAlivePeriod = mdutil.GetDuration(md, mdKeyKeepAlivePeriod)
if d.md.keepAlivePeriod <= 0 {
d.md.keepAlivePeriod = 10 * time.Second
}
}
d.md.handshakeTimeout = mdutil.GetDuration(md, mdKeyHandshakeTimeout)
d.md.maxIdleTimeout = mdutil.GetDuration(md, mdKeyMaxIdleTimeout)
d.md.maxStreams = mdutil.GetInt(md, mdKeyMaxStreams)
return nil
}