Skip to content

Commit e435d67

Browse files
committed
proxy: imp code
1 parent ec403a1 commit e435d67

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

proxy/serverquic.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ func (p *Proxy) handleQUICStream(ctx context.Context, stream *quic.Stream, conn
358358
return
359359
}
360360

361-
if !validQUICMsg(conn, req, p.logger) {
361+
if !validQUICMsg(ctx, conn, req, p.logger) {
362362
// If a peer encounters such an error condition, it is considered a
363363
// fatal error. It SHOULD forcibly abort the connection using QUIC's
364364
// CONNECTION_CLOSE mechanism and SHOULD use the DoQ error code
@@ -425,7 +425,7 @@ func (p *Proxy) respondQUIC(d *DNSContext) error {
425425

426426
// validQUICMsg validates the incoming DNS message and returns false if
427427
// something is wrong with the message. conn, req, and l must not be nil.
428-
func validQUICMsg(conn *quic.Conn, req *dns.Msg, l *slog.Logger) (ok bool) {
428+
func validQUICMsg(ctx context.Context, conn *quic.Conn, req *dns.Msg, l *slog.Logger) (ok bool) {
429429
// See https://www.rfc-editor.org/rfc/rfc9250.html#name-protocol-errors
430430

431431
// 1. a client or server receives a message with a non-zero Message ID.
@@ -453,7 +453,7 @@ func validQUICMsg(conn *quic.Conn, req *dns.Msg, l *slog.Logger) (ok bool) {
453453
for _, option := range opt.Option {
454454
// Check for EDNS TCP keepalive option
455455
if option.Option() == dns.EDNS0TCPKEEPALIVE {
456-
l.Debug("client sent edns0 tcp keepalive option")
456+
l.DebugContext(ctx, "client sent edns0 tcp keepalive option")
457457

458458
return false
459459
}
@@ -470,7 +470,11 @@ func validQUICMsg(conn *quic.Conn, req *dns.Msg, l *slog.Logger) (ok bool) {
470470
// processed from 0-RTT early data. Any other transaction received as early
471471
// data is treated as a protocol error and aborts the connection.
472472
if isNonReplayableEarlyData(conn, req) {
473-
l.Debug("client sent non-replayable transaction as 0-rtt data", "opcode", req.Opcode)
473+
l.DebugContext(
474+
ctx,
475+
"client sent non-replayable transaction as 0-rtt data",
476+
"opcode", req.Opcode,
477+
)
474478

475479
return false
476480
}

0 commit comments

Comments
 (0)