HandleData handles handshake bytes received from the peer. It may produce connection events, which may be read with [QUICConn.NextEvent].
(level QUICEncryptionLevel, data []byte)
| 256 | // HandleData handles handshake bytes received from the peer. |
| 257 | // It may produce connection events, which may be read with [QUICConn.NextEvent]. |
| 258 | func (q *QUICConn) HandleData(level QUICEncryptionLevel, data []byte) error { |
| 259 | c := q.conn |
| 260 | if c.in.level != level { |
| 261 | return quicError(c.in.setErrorLocked(errors.New("tls: handshake data received at wrong level"))) |
| 262 | } |
| 263 | c.quic.readbuf = data |
| 264 | <-c.quic.signalc |
| 265 | _, ok := <-c.quic.blockedc |
| 266 | if ok { |
| 267 | // The handshake goroutine is waiting for more data. |
| 268 | return nil |
| 269 | } |
| 270 | // The handshake goroutine has exited. |
| 271 | c.handshakeMutex.Lock() |
| 272 | defer c.handshakeMutex.Unlock() |
| 273 | c.hand.Write(c.quic.readbuf) |
| 274 | c.quic.readbuf = nil |
| 275 | for q.conn.hand.Len() >= 4 && q.conn.handshakeErr == nil { |
| 276 | b := q.conn.hand.Bytes() |
| 277 | n := int(b[1])<<16 | int(b[2])<<8 | int(b[3]) |
| 278 | if n > maxHandshake { |
| 279 | q.conn.handshakeErr = fmt.Errorf("tls: handshake message of length %d bytes exceeds maximum of %d bytes", n, maxHandshake) |
| 280 | break |
| 281 | } |
| 282 | if len(b) < 4+n { |
| 283 | return nil |
| 284 | } |
| 285 | if err := q.conn.handlePostHandshakeMessage(); err != nil { |
| 286 | q.conn.handshakeErr = err |
| 287 | } |
| 288 | } |
| 289 | if q.conn.handshakeErr != nil { |
| 290 | return quicError(q.conn.handshakeErr) |
| 291 | } |
| 292 | return nil |
| 293 | } |
| 294 | |
| 295 | type QUICSessionTicketOptions struct { |
| 296 | // EarlyData specifies whether the ticket may be used for 0-RTT. |
nothing calls this directly
no test coverage detected