Set random length of the tls packets

This commit is contained in:
9seconds
2021-03-26 14:12:05 +03:00
parent 40b483357f
commit e2e464d32c
+3 -2
View File
@@ -3,6 +3,7 @@ package faketls
import ( import (
"bytes" "bytes"
"fmt" "fmt"
"math/rand"
"net" "net"
"github.com/9seconds/mtg/v2/mtglib/internal/faketls/record" "github.com/9seconds/mtg/v2/mtglib/internal/faketls/record"
@@ -50,8 +51,8 @@ func (c *Conn) Write(p []byte) (int, error) {
written := 0 written := 0
for len(p) > 0 { for len(p) > 0 {
chunkSize := record.TLSMaxRecordSize chunkSize := rand.Intn(record.TLSMaxRecordSize)
if chunkSize > len(p) { if chunkSize > len(p) || chunkSize == 0 {
chunkSize = len(p) chunkSize = len(p)
} }