fix(masque): address review findings for PR #76

- Return errors from MasqueConn.Read/Write instead of silently
  succeeding (prevents infinite busy-loops and silent data loss
  if these methods are accidentally called).
- Set recorder Network field in protocol dispatch switch rather
  than hardcoding "udp", so early errors don't misreport type.
- Clarify that DatagramConn context-ID handling only supports
  context ID 0 (sufficient for CONNECT-UDP per RFC 9298).
This commit is contained in:
ginuerzh
2026-05-21 22:36:30 +08:00
parent 66b53580af
commit 01a2bbaa11
3 changed files with 15 additions and 11 deletions
+2 -1
View File
@@ -107,7 +107,7 @@ func (h *masqueHandler) Handle(ctx context.Context, conn net.Conn, opts ...handl
start := time.Now()
ro := &xrecorder.HandlerRecorderObject{
Network: "udp",
Network: "",
Service: h.options.Service,
RemoteAddr: conn.RemoteAddr().String(),
LocalAddr: conn.LocalAddr().String(),
@@ -183,6 +183,7 @@ func (h *masqueHandler) Handle(ctx context.Context, conn net.Conn, opts ...handl
switch r.Proto {
case "connect-udp":
// Extended CONNECT for UDP (RFC 9298)
ro.Network = "udp"
return h.handleConnectUDP(ctx, w, r, conn.LocalAddr(), ro, log)
case "HTTP/3.0", "":
// Standard CONNECT for TCP (RFC 9114)