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

Method writeRecord

conn.go:1118–1133  ·  view source on GitHub ↗

writeRecord writes a TLS record with the given type and payload to the connection and updates the record layer state. ONLY used by REALITY

(typ recordType, data []byte)

Source from the content-addressed store, hash-verified

1116// connection and updates the record layer state.
1117// ONLY used by REALITY
1118func (c *Conn) writeRecord(typ recordType, data []byte) (int, error) {
1119 c.out.Lock()
1120 defer c.out.Unlock()
1121
1122 if typ == recordTypeHandshake && c.out.handshakeBuf != nil &&
1123 len(data) > 0 && data[0] != typeServerHello {
1124 c.out.handshakeBuf = append(c.out.handshakeBuf, data...)
1125 if data[0] != typeFinished {
1126 return len(data), nil
1127 }
1128 data = c.out.handshakeBuf
1129 c.out.handshakeBuf = nil
1130 }
1131
1132 return c.writeRecordLocked(typ, data)
1133}
1134
1135// writeChangeCipherRecord writes a ChangeCipherSpec message to the connection and
1136// updates the record layer state.

Callers 2

handshakeMethod · 0.80
sendServerParametersMethod · 0.80

Calls 1

writeRecordLockedMethod · 0.95

Tested by

no test coverage detected