title: Intercept tls.Conn's Read() and Write() while retaining tls.Conn functionality
body: <p>I have the following piece of code:</p>
  <pre><code>l, err := tls.Listen(&quot;tcp&quot;, &quot;localhost:0&quot;, cfg)
  dieIf(err)
  c, err := l.Accept()
  dieIf(err)
  err = c.(*tls.Conn).Handshake()
  dieIf(err)
  </code></pre>
  <p>It works just fine, but I'd like to intercept <code>tls.Conn</code>'s reads and writes.</p>
  <p>I thought about doing this:</p>
  <pre><code>type MitmConn struct {
    net.Conn
  }
  
  func (self *MitmConn) Read(b []byte) (n int, err error) {
    ...
  }
  
  func (self *MitmConn) Write(b []byte) (n int, err error) {
    ...
  }
  
  l, err := tls.Listen(&quot;tcp&quot;, &quot;localhost:0&quot;, cfg)
  dieIf(err)
  c, err := l.Accept()
  dieIf(err)
  c = &amp;MitmConn{c}
  </code></pre>
  <p>But then, this would fail:</p>
  <pre><code>// panic: interface conversion: net.Conn is *MitmConn, not *tls.Conn
  err = c.(*tls.Conn).Handshake()
  dieIf(err)
  </code></pre>
  <p>Any ideas?</p>