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