MCPcopy
hub / github.com/XTLS/REALITY / HandleData

Method HandleData

quic.go:258–293  ·  view source on GitHub ↗

HandleData handles handshake bytes received from the peer. It may produce connection events, which may be read with [QUICConn.NextEvent].

(level QUICEncryptionLevel, data []byte)

Source from the content-addressed store, hash-verified

256// HandleData handles handshake bytes received from the peer.
257// It may produce connection events, which may be read with [QUICConn.NextEvent].
258func (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
295type QUICSessionTicketOptions struct {
296 // EarlyData specifies whether the ticket may be used for 0-RTT.

Callers

nothing calls this directly

Calls 5

quicErrorFunction · 0.85
setErrorLockedMethod · 0.80
BytesMethod · 0.80
WriteMethod · 0.65

Tested by

no test coverage detected