-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathframe_debug.go
727 lines (612 loc) · 18.8 KB
/
frame_debug.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
// Copyright 2023 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build go1.21
package quic
import (
"fmt"
"log/slog"
"strconv"
"time"
)
// A debugFrame is a representation of the contents of a QUIC frame,
// used for debug logs and testing but not the primary serving path.
type debugFrame interface {
String() string
write(w *packetWriter) bool
LogValue() slog.Value
}
func parseDebugFrame(b []byte) (f debugFrame, n int) {
if len(b) == 0 {
return nil, -1
}
switch b[0] {
case frameTypePadding:
f, n = parseDebugFramePadding(b)
case frameTypePing:
f, n = parseDebugFramePing(b)
case frameTypeAck, frameTypeAckECN:
f, n = parseDebugFrameAck(b)
case frameTypeResetStream:
f, n = parseDebugFrameResetStream(b)
case frameTypeStopSending:
f, n = parseDebugFrameStopSending(b)
case frameTypeCrypto:
f, n = parseDebugFrameCrypto(b)
case frameTypeNewToken:
f, n = parseDebugFrameNewToken(b)
case frameTypeStreamBase, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f:
f, n = parseDebugFrameStream(b)
case frameTypeMaxData:
f, n = parseDebugFrameMaxData(b)
case frameTypeMaxStreamData:
f, n = parseDebugFrameMaxStreamData(b)
case frameTypeMaxStreamsBidi, frameTypeMaxStreamsUni:
f, n = parseDebugFrameMaxStreams(b)
case frameTypeDataBlocked:
f, n = parseDebugFrameDataBlocked(b)
case frameTypeStreamDataBlocked:
f, n = parseDebugFrameStreamDataBlocked(b)
case frameTypeStreamsBlockedBidi, frameTypeStreamsBlockedUni:
f, n = parseDebugFrameStreamsBlocked(b)
case frameTypeNewConnectionID:
f, n = parseDebugFrameNewConnectionID(b)
case frameTypeRetireConnectionID:
f, n = parseDebugFrameRetireConnectionID(b)
case frameTypePathChallenge:
f, n = parseDebugFramePathChallenge(b)
case frameTypePathResponse:
f, n = parseDebugFramePathResponse(b)
case frameTypeConnectionCloseTransport:
f, n = parseDebugFrameConnectionCloseTransport(b)
case frameTypeConnectionCloseApplication:
f, n = parseDebugFrameConnectionCloseApplication(b)
case frameTypeHandshakeDone:
f, n = parseDebugFrameHandshakeDone(b)
default:
return nil, -1
}
return f, n
}
// debugFramePadding is a sequence of PADDING frames.
type debugFramePadding struct {
size int
to int // alternate for writing packets: pad to
}
func parseDebugFramePadding(b []byte) (f debugFramePadding, n int) {
for n < len(b) && b[n] == frameTypePadding {
n++
}
f.size = n
return f, n
}
func (f debugFramePadding) String() string {
return fmt.Sprintf("PADDING*%v", f.size)
}
func (f debugFramePadding) write(w *packetWriter) bool {
if w.avail() == 0 {
return false
}
if f.to > 0 {
w.appendPaddingTo(f.to)
return true
}
for i := 0; i < f.size && w.avail() > 0; i++ {
w.b = append(w.b, frameTypePadding)
}
return true
}
func (f debugFramePadding) LogValue() slog.Value {
return slog.GroupValue(
slog.String("frame_type", "padding"),
slog.Int("length", f.size),
)
}
// debugFramePing is a PING frame.
type debugFramePing struct{}
func parseDebugFramePing(b []byte) (f debugFramePing, n int) {
return f, 1
}
func (f debugFramePing) String() string {
return "PING"
}
func (f debugFramePing) write(w *packetWriter) bool {
return w.appendPingFrame()
}
func (f debugFramePing) LogValue() slog.Value {
return slog.GroupValue(
slog.String("frame_type", "ping"),
)
}
// debugFrameAck is an ACK frame.
type debugFrameAck struct {
ackDelay unscaledAckDelay
ranges []i64range[packetNumber]
}
func parseDebugFrameAck(b []byte) (f debugFrameAck, n int) {
f.ranges = nil
_, f.ackDelay, n = consumeAckFrame(b, func(_ int, start, end packetNumber) {
f.ranges = append(f.ranges, i64range[packetNumber]{
start: start,
end: end,
})
})
// Ranges are parsed high to low; reverse ranges slice to order them low to high.
for i := 0; i < len(f.ranges)/2; i++ {
j := len(f.ranges) - 1
f.ranges[i], f.ranges[j] = f.ranges[j], f.ranges[i]
}
return f, n
}
func (f debugFrameAck) String() string {
s := fmt.Sprintf("ACK Delay=%v", f.ackDelay)
for _, r := range f.ranges {
s += fmt.Sprintf(" [%v,%v)", r.start, r.end)
}
return s
}
func (f debugFrameAck) write(w *packetWriter) bool {
return w.appendAckFrame(rangeset[packetNumber](f.ranges), f.ackDelay)
}
func (f debugFrameAck) LogValue() slog.Value {
return slog.StringValue("error: debugFrameAck should not appear as a slog Value")
}
// debugFrameScaledAck is an ACK frame with scaled ACK Delay.
//
// This type is used in qlog events, which need access to the delay as a duration.
type debugFrameScaledAck struct {
ackDelay time.Duration
ranges []i64range[packetNumber]
}
func (f debugFrameScaledAck) LogValue() slog.Value {
var ackDelay slog.Attr
if f.ackDelay >= 0 {
ackDelay = slog.Duration("ack_delay", f.ackDelay)
}
return slog.GroupValue(
slog.String("frame_type", "ack"),
// Rather than trying to convert the ack ranges into the slog data model,
// pass a value that can JSON-encode itself.
slog.Any("acked_ranges", debugAckRanges(f.ranges)),
ackDelay,
)
}
type debugAckRanges []i64range[packetNumber]
// AppendJSON appends a JSON encoding of the ack ranges to b, and returns it.
// This is different than the standard json.Marshaler, but more efficient.
// Since we only use this in cooperation with the qlog package,
// encoding/json compatibility is irrelevant.
func (r debugAckRanges) AppendJSON(b []byte) []byte {
b = append(b, '[')
for i, ar := range r {
start, end := ar.start, ar.end-1 // qlog ranges are closed-closed
if i != 0 {
b = append(b, ',')
}
b = append(b, '[')
b = strconv.AppendInt(b, int64(start), 10)
if start != end {
b = append(b, ',')
b = strconv.AppendInt(b, int64(end), 10)
}
b = append(b, ']')
}
b = append(b, ']')
return b
}
func (r debugAckRanges) String() string {
return string(r.AppendJSON(nil))
}
// debugFrameResetStream is a RESET_STREAM frame.
type debugFrameResetStream struct {
id streamID
code uint64
finalSize int64
}
func parseDebugFrameResetStream(b []byte) (f debugFrameResetStream, n int) {
f.id, f.code, f.finalSize, n = consumeResetStreamFrame(b)
return f, n
}
func (f debugFrameResetStream) String() string {
return fmt.Sprintf("RESET_STREAM ID=%v Code=%v FinalSize=%v", f.id, f.code, f.finalSize)
}
func (f debugFrameResetStream) write(w *packetWriter) bool {
return w.appendResetStreamFrame(f.id, f.code, f.finalSize)
}
func (f debugFrameResetStream) LogValue() slog.Value {
return slog.GroupValue(
slog.String("frame_type", "reset_stream"),
slog.Uint64("stream_id", uint64(f.id)),
slog.Uint64("final_size", uint64(f.finalSize)),
)
}
// debugFrameStopSending is a STOP_SENDING frame.
type debugFrameStopSending struct {
id streamID
code uint64
}
func parseDebugFrameStopSending(b []byte) (f debugFrameStopSending, n int) {
f.id, f.code, n = consumeStopSendingFrame(b)
return f, n
}
func (f debugFrameStopSending) String() string {
return fmt.Sprintf("STOP_SENDING ID=%v Code=%v", f.id, f.code)
}
func (f debugFrameStopSending) write(w *packetWriter) bool {
return w.appendStopSendingFrame(f.id, f.code)
}
func (f debugFrameStopSending) LogValue() slog.Value {
return slog.GroupValue(
slog.String("frame_type", "stop_sending"),
slog.Uint64("stream_id", uint64(f.id)),
slog.Uint64("error_code", uint64(f.code)),
)
}
// debugFrameCrypto is a CRYPTO frame.
type debugFrameCrypto struct {
off int64
data []byte
}
func parseDebugFrameCrypto(b []byte) (f debugFrameCrypto, n int) {
f.off, f.data, n = consumeCryptoFrame(b)
return f, n
}
func (f debugFrameCrypto) String() string {
return fmt.Sprintf("CRYPTO Offset=%v Length=%v", f.off, len(f.data))
}
func (f debugFrameCrypto) write(w *packetWriter) bool {
b, added := w.appendCryptoFrame(f.off, len(f.data))
copy(b, f.data)
return added
}
func (f debugFrameCrypto) LogValue() slog.Value {
return slog.GroupValue(
slog.String("frame_type", "crypto"),
slog.Int64("offset", f.off),
slog.Int("length", len(f.data)),
)
}
// debugFrameNewToken is a NEW_TOKEN frame.
type debugFrameNewToken struct {
token []byte
}
func parseDebugFrameNewToken(b []byte) (f debugFrameNewToken, n int) {
f.token, n = consumeNewTokenFrame(b)
return f, n
}
func (f debugFrameNewToken) String() string {
return fmt.Sprintf("NEW_TOKEN Token=%x", f.token)
}
func (f debugFrameNewToken) write(w *packetWriter) bool {
return w.appendNewTokenFrame(f.token)
}
func (f debugFrameNewToken) LogValue() slog.Value {
return slog.GroupValue(
slog.String("frame_type", "new_token"),
slogHexstring("token", f.token),
)
}
// debugFrameStream is a STREAM frame.
type debugFrameStream struct {
id streamID
fin bool
off int64
data []byte
}
func parseDebugFrameStream(b []byte) (f debugFrameStream, n int) {
f.id, f.off, f.fin, f.data, n = consumeStreamFrame(b)
return f, n
}
func (f debugFrameStream) String() string {
fin := ""
if f.fin {
fin = " FIN"
}
return fmt.Sprintf("STREAM ID=%v%v Offset=%v Length=%v", f.id, fin, f.off, len(f.data))
}
func (f debugFrameStream) write(w *packetWriter) bool {
b, added := w.appendStreamFrame(f.id, f.off, len(f.data), f.fin)
copy(b, f.data)
return added
}
func (f debugFrameStream) LogValue() slog.Value {
var fin slog.Attr
if f.fin {
fin = slog.Bool("fin", true)
}
return slog.GroupValue(
slog.String("frame_type", "stream"),
slog.Uint64("stream_id", uint64(f.id)),
slog.Int64("offset", f.off),
slog.Int("length", len(f.data)),
fin,
)
}
// debugFrameMaxData is a MAX_DATA frame.
type debugFrameMaxData struct {
max int64
}
func parseDebugFrameMaxData(b []byte) (f debugFrameMaxData, n int) {
f.max, n = consumeMaxDataFrame(b)
return f, n
}
func (f debugFrameMaxData) String() string {
return fmt.Sprintf("MAX_DATA Max=%v", f.max)
}
func (f debugFrameMaxData) write(w *packetWriter) bool {
return w.appendMaxDataFrame(f.max)
}
func (f debugFrameMaxData) LogValue() slog.Value {
return slog.GroupValue(
slog.String("frame_type", "max_data"),
slog.Int64("maximum", f.max),
)
}
// debugFrameMaxStreamData is a MAX_STREAM_DATA frame.
type debugFrameMaxStreamData struct {
id streamID
max int64
}
func parseDebugFrameMaxStreamData(b []byte) (f debugFrameMaxStreamData, n int) {
f.id, f.max, n = consumeMaxStreamDataFrame(b)
return f, n
}
func (f debugFrameMaxStreamData) String() string {
return fmt.Sprintf("MAX_STREAM_DATA ID=%v Max=%v", f.id, f.max)
}
func (f debugFrameMaxStreamData) write(w *packetWriter) bool {
return w.appendMaxStreamDataFrame(f.id, f.max)
}
func (f debugFrameMaxStreamData) LogValue() slog.Value {
return slog.GroupValue(
slog.String("frame_type", "max_stream_data"),
slog.Uint64("stream_id", uint64(f.id)),
slog.Int64("maximum", f.max),
)
}
// debugFrameMaxStreams is a MAX_STREAMS frame.
type debugFrameMaxStreams struct {
streamType streamType
max int64
}
func parseDebugFrameMaxStreams(b []byte) (f debugFrameMaxStreams, n int) {
f.streamType, f.max, n = consumeMaxStreamsFrame(b)
return f, n
}
func (f debugFrameMaxStreams) String() string {
return fmt.Sprintf("MAX_STREAMS Type=%v Max=%v", f.streamType, f.max)
}
func (f debugFrameMaxStreams) write(w *packetWriter) bool {
return w.appendMaxStreamsFrame(f.streamType, f.max)
}
func (f debugFrameMaxStreams) LogValue() slog.Value {
return slog.GroupValue(
slog.String("frame_type", "max_streams"),
slog.String("stream_type", f.streamType.qlogString()),
slog.Int64("maximum", f.max),
)
}
// debugFrameDataBlocked is a DATA_BLOCKED frame.
type debugFrameDataBlocked struct {
max int64
}
func parseDebugFrameDataBlocked(b []byte) (f debugFrameDataBlocked, n int) {
f.max, n = consumeDataBlockedFrame(b)
return f, n
}
func (f debugFrameDataBlocked) String() string {
return fmt.Sprintf("DATA_BLOCKED Max=%v", f.max)
}
func (f debugFrameDataBlocked) write(w *packetWriter) bool {
return w.appendDataBlockedFrame(f.max)
}
func (f debugFrameDataBlocked) LogValue() slog.Value {
return slog.GroupValue(
slog.String("frame_type", "data_blocked"),
slog.Int64("limit", f.max),
)
}
// debugFrameStreamDataBlocked is a STREAM_DATA_BLOCKED frame.
type debugFrameStreamDataBlocked struct {
id streamID
max int64
}
func parseDebugFrameStreamDataBlocked(b []byte) (f debugFrameStreamDataBlocked, n int) {
f.id, f.max, n = consumeStreamDataBlockedFrame(b)
return f, n
}
func (f debugFrameStreamDataBlocked) String() string {
return fmt.Sprintf("STREAM_DATA_BLOCKED ID=%v Max=%v", f.id, f.max)
}
func (f debugFrameStreamDataBlocked) write(w *packetWriter) bool {
return w.appendStreamDataBlockedFrame(f.id, f.max)
}
func (f debugFrameStreamDataBlocked) LogValue() slog.Value {
return slog.GroupValue(
slog.String("frame_type", "stream_data_blocked"),
slog.Uint64("stream_id", uint64(f.id)),
slog.Int64("limit", f.max),
)
}
// debugFrameStreamsBlocked is a STREAMS_BLOCKED frame.
type debugFrameStreamsBlocked struct {
streamType streamType
max int64
}
func parseDebugFrameStreamsBlocked(b []byte) (f debugFrameStreamsBlocked, n int) {
f.streamType, f.max, n = consumeStreamsBlockedFrame(b)
return f, n
}
func (f debugFrameStreamsBlocked) String() string {
return fmt.Sprintf("STREAMS_BLOCKED Type=%v Max=%v", f.streamType, f.max)
}
func (f debugFrameStreamsBlocked) write(w *packetWriter) bool {
return w.appendStreamsBlockedFrame(f.streamType, f.max)
}
func (f debugFrameStreamsBlocked) LogValue() slog.Value {
return slog.GroupValue(
slog.String("frame_type", "streams_blocked"),
slog.String("stream_type", f.streamType.qlogString()),
slog.Int64("limit", f.max),
)
}
// debugFrameNewConnectionID is a NEW_CONNECTION_ID frame.
type debugFrameNewConnectionID struct {
seq int64
retirePriorTo int64
connID []byte
token statelessResetToken
}
func parseDebugFrameNewConnectionID(b []byte) (f debugFrameNewConnectionID, n int) {
f.seq, f.retirePriorTo, f.connID, f.token, n = consumeNewConnectionIDFrame(b)
return f, n
}
func (f debugFrameNewConnectionID) String() string {
return fmt.Sprintf("NEW_CONNECTION_ID Seq=%v Retire=%v ID=%x Token=%x", f.seq, f.retirePriorTo, f.connID, f.token[:])
}
func (f debugFrameNewConnectionID) write(w *packetWriter) bool {
return w.appendNewConnectionIDFrame(f.seq, f.retirePriorTo, f.connID, f.token)
}
func (f debugFrameNewConnectionID) LogValue() slog.Value {
return slog.GroupValue(
slog.String("frame_type", "new_connection_id"),
slog.Int64("sequence_number", f.seq),
slog.Int64("retire_prior_to", f.retirePriorTo),
slogHexstring("connection_id", f.connID),
slogHexstring("stateless_reset_token", f.token[:]),
)
}
// debugFrameRetireConnectionID is a NEW_CONNECTION_ID frame.
type debugFrameRetireConnectionID struct {
seq int64
}
func parseDebugFrameRetireConnectionID(b []byte) (f debugFrameRetireConnectionID, n int) {
f.seq, n = consumeRetireConnectionIDFrame(b)
return f, n
}
func (f debugFrameRetireConnectionID) String() string {
return fmt.Sprintf("RETIRE_CONNECTION_ID Seq=%v", f.seq)
}
func (f debugFrameRetireConnectionID) write(w *packetWriter) bool {
return w.appendRetireConnectionIDFrame(f.seq)
}
func (f debugFrameRetireConnectionID) LogValue() slog.Value {
return slog.GroupValue(
slog.String("frame_type", "retire_connection_id"),
slog.Int64("sequence_number", f.seq),
)
}
// debugFramePathChallenge is a PATH_CHALLENGE frame.
type debugFramePathChallenge struct {
data pathChallengeData
}
func parseDebugFramePathChallenge(b []byte) (f debugFramePathChallenge, n int) {
f.data, n = consumePathChallengeFrame(b)
return f, n
}
func (f debugFramePathChallenge) String() string {
return fmt.Sprintf("PATH_CHALLENGE Data=%x", f.data)
}
func (f debugFramePathChallenge) write(w *packetWriter) bool {
return w.appendPathChallengeFrame(f.data)
}
func (f debugFramePathChallenge) LogValue() slog.Value {
return slog.GroupValue(
slog.String("frame_type", "path_challenge"),
slog.String("data", fmt.Sprintf("%x", f.data)),
)
}
// debugFramePathResponse is a PATH_RESPONSE frame.
type debugFramePathResponse struct {
data pathChallengeData
}
func parseDebugFramePathResponse(b []byte) (f debugFramePathResponse, n int) {
f.data, n = consumePathResponseFrame(b)
return f, n
}
func (f debugFramePathResponse) String() string {
return fmt.Sprintf("PATH_RESPONSE Data=%x", f.data)
}
func (f debugFramePathResponse) write(w *packetWriter) bool {
return w.appendPathResponseFrame(f.data)
}
func (f debugFramePathResponse) LogValue() slog.Value {
return slog.GroupValue(
slog.String("frame_type", "path_response"),
slog.String("data", fmt.Sprintf("%x", f.data)),
)
}
// debugFrameConnectionCloseTransport is a CONNECTION_CLOSE frame carrying a transport error.
type debugFrameConnectionCloseTransport struct {
code transportError
frameType uint64
reason string
}
func parseDebugFrameConnectionCloseTransport(b []byte) (f debugFrameConnectionCloseTransport, n int) {
f.code, f.frameType, f.reason, n = consumeConnectionCloseTransportFrame(b)
return f, n
}
func (f debugFrameConnectionCloseTransport) String() string {
s := fmt.Sprintf("CONNECTION_CLOSE Code=%v", f.code)
if f.frameType != 0 {
s += fmt.Sprintf(" FrameType=%v", f.frameType)
}
if f.reason != "" {
s += fmt.Sprintf(" Reason=%q", f.reason)
}
return s
}
func (f debugFrameConnectionCloseTransport) write(w *packetWriter) bool {
return w.appendConnectionCloseTransportFrame(f.code, f.frameType, f.reason)
}
func (f debugFrameConnectionCloseTransport) LogValue() slog.Value {
return slog.GroupValue(
slog.String("frame_type", "connection_close"),
slog.String("error_space", "transport"),
slog.Uint64("error_code_value", uint64(f.code)),
slog.String("reason", f.reason),
)
}
// debugFrameConnectionCloseApplication is a CONNECTION_CLOSE frame carrying an application error.
type debugFrameConnectionCloseApplication struct {
code uint64
reason string
}
func parseDebugFrameConnectionCloseApplication(b []byte) (f debugFrameConnectionCloseApplication, n int) {
f.code, f.reason, n = consumeConnectionCloseApplicationFrame(b)
return f, n
}
func (f debugFrameConnectionCloseApplication) String() string {
s := fmt.Sprintf("CONNECTION_CLOSE AppCode=%v", f.code)
if f.reason != "" {
s += fmt.Sprintf(" Reason=%q", f.reason)
}
return s
}
func (f debugFrameConnectionCloseApplication) write(w *packetWriter) bool {
return w.appendConnectionCloseApplicationFrame(f.code, f.reason)
}
func (f debugFrameConnectionCloseApplication) LogValue() slog.Value {
return slog.GroupValue(
slog.String("frame_type", "connection_close"),
slog.String("error_space", "application"),
slog.Uint64("error_code_value", uint64(f.code)),
slog.String("reason", f.reason),
)
}
// debugFrameHandshakeDone is a HANDSHAKE_DONE frame.
type debugFrameHandshakeDone struct{}
func parseDebugFrameHandshakeDone(b []byte) (f debugFrameHandshakeDone, n int) {
return f, 1
}
func (f debugFrameHandshakeDone) String() string {
return "HANDSHAKE_DONE"
}
func (f debugFrameHandshakeDone) write(w *packetWriter) bool {
return w.appendHandshakeDoneFrame()
}
func (f debugFrameHandshakeDone) LogValue() slog.Value {
return slog.GroupValue(
slog.String("frame_type", "handshake_done"),
)
}