summaryrefslogtreecommitdiff
path: root/tcpproxy.go
diff options
context:
space:
mode:
Diffstat (limited to 'tcpproxy.go')
-rw-r--r--tcpproxy.go9
1 files changed, 7 insertions, 2 deletions
diff --git a/tcpproxy.go b/tcpproxy.go
index 1f03e32..745e2ba 100644
--- a/tcpproxy.go
+++ b/tcpproxy.go
@@ -355,16 +355,21 @@ func tcpConn(c net.Conn) (t *net.TCPConn, ok bool) {
return nil, false
}
+type closeReader interface{ CloseRead() error }
+type closeWriter interface{ CloseWrite() error }
+
func goCloseConn(c net.Conn) { go c.Close() }
func closeRead(c net.Conn) {
- if c, ok := tcpConn(c); ok {
+ // prefer the interfaces, for compatibility with e.g. gvisor/netstack.
+ if c, ok := UnderlyingConn(c).(closeReader); ok {
c.CloseRead()
}
}
func closeWrite(c net.Conn) {
- if c, ok := tcpConn(c); ok {
+ // prefer the interfaces, for compatibility with e.g. gvisor/netstack.
+ if c, ok := UnderlyingConn(c).(closeWriter); ok {
c.CloseWrite()
}
}