MCPcopy Create free account
hub / github.com/LagrangeDev/LagrangeGo / Pack

Method Pack

utils/binary/builder.go:52–69  ·  view source on GitHub ↗

Pack TLV with tea encryption if key is set GC 安全, 返回的数据在 Builder 被销毁之后仍能被正确读取, 调用后 Builder 仍有效

(typ uint16)

Source from the content-addressed store, hash-verified

50// GC 安全, 返回的数据在 Builder 被销毁之后仍能被正确读取,
51// 调用后 Builder 仍有效
52func (b *Builder) Pack(typ uint16) (data []byte) {
53 b.p(func(buf *pbuf.UserBuffer[teacfg]) {
54 data = make([]byte, buf.Len()+2+2+16)
55
56 n := 0
57 if buf.DAT.usetea {
58 n = buf.DAT.key.EncryptTo(buf.Bytes(), data[2+2:])
59 } else {
60 n = copy(data[2+2:], buf.Bytes())
61 }
62
63 binary.BigEndian.PutUint16(data[0:2], typ) // type
64 binary.BigEndian.PutUint16(data[2:2+2], uint16(n)) // length
65
66 data = data[:n+2+2]
67 })
68 return
69}
70
71func (b *Builder) WriteBool(v bool) *Builder {
72 if v {

Callers 15

QRCodeLoginMethod · 0.80
T18Function · 0.80
T100Function · 0.80
T106Function · 0.80
T107Function · 0.80
T116Function · 0.80
T124Function · 0.80
T128Function · 0.80
T141Function · 0.80
T142Function · 0.80
T144Function · 0.80
T145Function · 0.80

Calls 3

pMethod · 0.95
LenMethod · 0.80
BytesMethod · 0.80

Tested by 1

TestBuilderFunction · 0.64