fix(masque): default enableDatagrams to true on HTTP/3 listener and fix CONNECT-UDP error handling

- listener/http3: default enableDatagrams to true when not explicitly set,
  so CONNECT-UDP (RFC 9298) works out of the box without requiring
  ?enableDatagrams=true in the config URL
- handler/masque: dial target before sending 200 OK in handleConnectUDP,
  matching the handleConnectTCP order; if target dial fails, the handler
  can still return an error status instead of having already committed 200
- handler/masque: add missing WriteHeader(BadRequest) when ResolveUDPAddr
  fails, so the client gets a proper HTTP error instead of an opaque
  H3_REQUEST_CANCELLED stream reset

Fixes #103
This commit is contained in:
ginuerzh
2026-06-20 15:01:14 +08:00
parent 296d87a597
commit 1d34d4543a
2 changed files with 43 additions and 38 deletions
+5 -1
View File
@@ -47,7 +47,11 @@ 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")
if mdutil.IsExists(md, "enableDatagrams") {
l.md.enableDatagrams = mdutil.GetBool(md, "enableDatagrams")
} else {
l.md.enableDatagrams = true
}
return
}