Skip to content

Commit ed9307c

Browse files
authored
Merge pull request #20 from coder/colin/sock-opts
2 parents 27a458a + 715bf03 commit ed9307c

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

wgengine/netstack/netstack.go

Lines changed: 9 additions & 1 deletion
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)