Adjust limits for iOS

This commit is contained in:
Viktor Liu 2025-01-06 23:53:12 +01:00
parent 4a189a87ce
commit 5ea39dfe8a

View File

@ -4,6 +4,7 @@ import (
"context"
"fmt"
"net"
"runtime"
log "github.com/sirupsen/logrus"
"gvisor.dev/gvisor/pkg/buffer"
@ -20,8 +21,10 @@ import (
)
const (
receiveWindow = 32768
maxInFlight = 1024
defaultReceiveWindow = 32768
defaultMaxInFlight = 1024
iosReceiveWindow = 16384
iosMaxInFlight = 256
)
type Forwarder struct {
@ -108,6 +111,13 @@ func New(iface common.IFaceMapper, logger *nblog.Logger, netstack bool) (*Forwar
ip: iface.Address().IP,
}
receiveWindow := defaultReceiveWindow
maxInFlight := defaultMaxInFlight
if runtime.GOOS == "ios" {
receiveWindow = iosReceiveWindow
maxInFlight = iosMaxInFlight
}
tcpForwarder := tcp.NewForwarder(s, receiveWindow, maxInFlight, f.handleTCP)
s.SetTransportProtocolHandler(tcp.ProtocolNumber, tcpForwarder.HandlePacket)