Add tls fragment support

This commit is contained in:
世界
2025-01-26 09:01:00 +08:00
parent 7ecc62f2e0
commit 420d8d144a
15 changed files with 16194 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
package tf
import (
"context"
"syscall"
"time"
"github.com/sagernet/sing/common/control"
"golang.org/x/sys/unix"
)
func waitAck(ctx context.Context, conn syscall.Conn, fallbackDelay time.Duration) error {
return control.Conn(conn, func(fd uintptr) error {
start := time.Now()
for {
select {
case <-ctx.Done():
return ctx.Err()
default:
}
tcpInfo, err := unix.GetsockoptTCPInfo(int(fd), unix.IPPROTO_TCP, unix.TCP_INFO)
if err != nil {
return err
}
if tcpInfo.Unacked == 0 {
if time.Since(start) <= 20*time.Millisecond {
// under transparent proxy
time.Sleep(fallbackDelay)
}
return nil
}
time.Sleep(10 * time.Millisecond)
}
})
}