Skip to content

Commit 715bf03

Browse files
committed
feat(netstack): allow setting gvisor socket options on ForwardTCPIn
1 parent 27a458a commit 715bf03

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

wgengine/netstack/netstack.go

+9-1
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ type Impl struct {
8383
// TODO(bradfitz): provide mechanism for tsnet to reject a
8484
// port other than accepting it and closing it.
8585
ForwardTCPIn func(c net.Conn, port uint16)
86+
// ForwardTCPSockOpts, if non-nil, allows setting gvisor socket options on the
87+
// created TCPConn before calling ForwardTCPIn.
88+
ForwardTCPSockOpts func(port uint16) []tcpip.SettableSocketOption
8689

8790
// ProcessLocalIPs is whether netstack should handle incoming
8891
// traffic directed at the Node.Addresses (local IPs).
@@ -900,7 +903,12 @@ func (ns *Impl) acceptTCP(r *tcp.ForwarderRequest) {
900903
}
901904

902905
if ns.ForwardTCPIn != nil {
903-
c := createConn()
906+
opts := []tcpip.SettableSocketOption{}
907+
if ns.ForwardTCPSockOpts != nil {
908+
opts = ns.ForwardTCPSockOpts(reqDetails.LocalPort)
909+
}
910+
911+
c := createConn(opts...)
904912
if c == nil {
905913
return
906914
}

0 commit comments

Comments
 (0)