forked from quic-go/quic-go
grease transport parameters
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"math/rand"
|
||||
"sort"
|
||||
"time"
|
||||
|
||||
@@ -13,6 +14,10 @@ import (
|
||||
"github.com/lucas-clemente/quic-go/internal/utils"
|
||||
)
|
||||
|
||||
func init() {
|
||||
rand.Seed(time.Now().UTC().UnixNano())
|
||||
}
|
||||
|
||||
type transportParameterID uint16
|
||||
|
||||
const (
|
||||
@@ -204,6 +209,14 @@ func (p *TransportParameters) Marshal() []byte {
|
||||
b := &bytes.Buffer{}
|
||||
b.Write([]byte{0, 0}) // length. Will be replaced later
|
||||
|
||||
// add a greased value
|
||||
utils.BigEndian.WriteUint16(b, uint16(27+31*rand.Intn(100)))
|
||||
len := rand.Intn(16)
|
||||
randomData := make([]byte, len)
|
||||
rand.Read(randomData)
|
||||
utils.BigEndian.WriteUint16(b, uint16(len))
|
||||
b.Write(randomData)
|
||||
|
||||
// initial_max_stream_data_bidi_local
|
||||
p.marshalVarintParam(b, initialMaxStreamDataBidiLocalParameterID, uint64(p.InitialMaxStreamDataBidiLocal))
|
||||
// initial_max_stream_data_bidi_remote
|
||||
|
||||
Reference in New Issue
Block a user