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

Method writeHandshakeRecord

conn.go:1091–1113  ·  view source on GitHub ↗

writeHandshakeRecord writes a handshake message to the connection and updates the record layer state. If transcript is non-nil the marshaled message is written to it.

(msg handshakeMessage, transcript transcriptHash)

Source from the content-addressed store, hash-verified

1089// the record layer state. If transcript is non-nil the marshaled message is
1090// written to it.
1091func (c *Conn) writeHandshakeRecord(msg handshakeMessage, transcript transcriptHash) (int, error) {
1092 c.out.Lock()
1093 defer c.out.Unlock()
1094
1095 data, err := msg.marshal()
1096 if err != nil {
1097 return 0, err
1098 }
1099 if transcript != nil {
1100 transcript.Write(data)
1101 }
1102
1103 if c.out.handshakeBuf != nil && len(data) > 0 && data[0] != typeServerHello {
1104 c.out.handshakeBuf = append(c.out.handshakeBuf, data...)
1105 if data[0] != typeFinished {
1106 return len(data), nil
1107 }
1108 data = c.out.handshakeBuf
1109 c.out.handshakeBuf = nil
1110 }
1111
1112 return c.writeRecordLocked(recordTypeHandshake, data)
1113}
1114
1115// writeRecord writes a TLS record with the given type and payload to the
1116// connection and updates the record layer state.

Callers 15

clientHandshakeMethod · 0.95
sendSessionTicketMethod · 0.95
doFullHandshakeMethod · 0.80
sendFinishedMethod · 0.80
sendClientCertificateMethod · 0.80
sendClientFinishedMethod · 0.80
doHelloRetryRequestMethod · 0.80
sendServerParametersMethod · 0.80
sendServerCertificateMethod · 0.80
sendServerFinishedMethod · 0.80
doResumeHandshakeMethod · 0.80

Calls 3

writeRecordLockedMethod · 0.95
marshalMethod · 0.65
WriteMethod · 0.65

Tested by

no test coverage detected