Browse Source

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>
pull/3671/head
风扇滑翔翼 3 months ago committed by GitHub
parent
commit
9e93c19161
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 19
      proxy/freedom/freedom.go

19
proxy/freedom/freedom.go

@ -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)
_, 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 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 {

Loading…
Cancel
Save