Freedom: Combine fragmented tlshello if interval is 0 (#3663)

Co-authored-by: RPRX <63339210+RPRX@users.noreply.github.com>
Co-authored-by: Ahmadreza Dorkhah <djahmadfire@gmail.com>
This commit is contained in:
风扇滑翔翼 2024-08-10 13:06:00 +08:00 committed by GitHub
parent 96e8b8b279
commit 9e93c19161
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -402,6 +402,7 @@ func (f *FragmentWriter) Write(b []byte) (int, error) {
}
data := b[5:recordLen]
buf := make([]byte, 1024)
var hello []byte
for from := 0; ; {
to := from + int(randBetween(int64(f.fragment.LengthMin), int64(f.fragment.LengthMax)))
if to > len(data) {
@ -413,12 +414,22 @@ func (f *FragmentWriter) Write(b []byte) (int, error) {
from = to
buf[3] = byte(l >> 8)
buf[4] = byte(l)
if f.fragment.IntervalMax == 0 { // combine fragmented tlshello if interval is 0
hello = append(hello, buf[:5+l]...)
} else {
_, err := f.writer.Write(buf[:5+l])
time.Sleep(time.Duration(randBetween(int64(f.fragment.IntervalMin), int64(f.fragment.IntervalMax))) * time.Millisecond)
if err != nil {
return 0, err
}
}
if from == len(data) {
if len(hello) > 0 {
_, err := f.writer.Write(hello)
if err != nil {
return 0, err
}
}
if len(b) > recordLen {
n, err := f.writer.Write(b[recordLen:])
if err != nil {