+18
-3
lines changedFilter options
+18
-3
lines changed Original file line number Diff line number Diff line change
@@ -494,6 +494,12 @@ func (o *Operation) Bytes() uint16 {
494
494
if o.CertID != "" {
495
495
add(tlvLen(len([]byte(o.CertID))))
496
496
}
497
+
if o.CustomFuncName != "" {
498
+
add(tlvLen(len([]byte(o.CustomFuncName))))
499
+
}
500
+
if o.JaegerSpan != nil {
501
+
add(tlvLen(len(o.JaegerSpan)))
502
+
}
497
503
if int(length)+headerSize < paddedLength {
498
504
// TODO: Are we sure that's the right behavior?
499
505
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
1
1
package protocol
2
2
3
3
import (
4
+
"bytes"
5
+
"crypto/rand"
4
6
"crypto/sha1"
5
7
"crypto/sha256"
6
8
"net"
@@ -12,24 +14,31 @@ import (
12
14
func TestMarshalBinary(t *testing.T) {
13
15
require := require.New(t)
14
16
17
+
// we want to push the payload over the paddedLength of 1024
18
+
// to ensure that the size is calculated correctly.
19
+
extra := make([]byte, 100)
20
+
payload := make([]byte, 1000)
21
+
rand.Read(extra)
22
+
rand.Read(payload)
15
23
op := Operation{
16
24
Opcode: OpECDSASignSHA256,
17
-
Payload: []byte("Payload"),
18
-
Extra: []byte("Extra"),
25
+
Payload: payload,
26
+
Extra: extra,
19
27
Digest: sha256.Sum256([]byte("Digest")),
20
28
SKI: sha1.Sum([]byte("SKI")),
21
29
ClientIP: net.ParseIP("1.1.1.1").To4(),
22
30
ServerIP: net.ParseIP("2.2.2.2").To4(),
23
31
SNI: "SNI",
24
32
CertID: "SNI",
25
33
CustomFuncName: "CustomFuncName",
34
+
JaegerSpan: []byte("615f730ad5fe896f:615f730ad5fe896f:1"),
26
35
}
27
36
pkt := NewPacket(42, op)
28
37
b, err := pkt.MarshalBinary()
29
38
require.NoError(err)
30
39
31
40
var pkt2 Packet
32
-
err = pkt2.UnmarshalBinary(b)
41
+
_, err = pkt2.ReadFrom(bytes.NewReader(b))
33
42
require.NoError(err)
34
43
require.Equal(pkt.ID, pkt2.ID)
35
44
require.Equal(op, pkt2.Operation)
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4