|
@ -6,6 +6,7 @@ import ( |
|
|
|
|
|
|
|
|
"gvisor.dev/gvisor/pkg/tcpip" |
|
|
"gvisor.dev/gvisor/pkg/tcpip" |
|
|
"gvisor.dev/gvisor/pkg/tcpip/adapters/gonet" |
|
|
"gvisor.dev/gvisor/pkg/tcpip/adapters/gonet" |
|
|
|
|
|
"gvisor.dev/gvisor/pkg/tcpip/stack" |
|
|
"gvisor.dev/gvisor/pkg/tcpip/transport/tcp" |
|
|
"gvisor.dev/gvisor/pkg/tcpip/transport/tcp" |
|
|
"gvisor.dev/gvisor/pkg/waiter" |
|
|
"gvisor.dev/gvisor/pkg/waiter" |
|
|
) |
|
|
) |
|
@ -40,11 +41,15 @@ func withTCPHandler() Option { |
|
|
r.Complete(true) |
|
|
r.Complete(true) |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
r.Complete(false) |
|
|
defer r.Complete(false) |
|
|
|
|
|
|
|
|
setKeepalive(ep) |
|
|
setKeepalive(ep) |
|
|
|
|
|
|
|
|
s.handler.HandleTCPConn(gonet.NewTCPConn(&wq, ep)) |
|
|
conn := &tcpConn{ |
|
|
|
|
|
TCPConn: gonet.NewTCPConn(&wq, ep), |
|
|
|
|
|
id: r.ID(), |
|
|
|
|
|
} |
|
|
|
|
|
s.handler.HandleTCPConn(conn) |
|
|
}) |
|
|
}) |
|
|
s.SetTransportProtocolHandler(tcp.ProtocolNumber, tcpForwarder.HandlePacket) |
|
|
s.SetTransportProtocolHandler(tcp.ProtocolNumber, tcpForwarder.HandlePacket) |
|
|
return nil |
|
|
return nil |
|
@ -65,3 +70,12 @@ func setKeepalive(ep tcpip.Endpoint) error { |
|
|
} |
|
|
} |
|
|
return nil |
|
|
return nil |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
type tcpConn struct { |
|
|
|
|
|
*gonet.TCPConn |
|
|
|
|
|
id stack.TransportEndpointID |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (c *tcpConn) ID() *stack.TransportEndpointID { |
|
|
|
|
|
return &c.id |
|
|
|
|
|
} |
|
|