Skip to content

Instantly share code, notes, and snippets.

@nhooyr
Last active May 15, 2018 04:53
Show Gist options
  • Save nhooyr/311a9d0206fa7c8221f8a9e4f0a9fc81 to your computer and use it in GitHub Desktop.
Save nhooyr/311a9d0206fa7c8221f8a9e4f0a9fc81 to your computer and use it in GitHub Desktop.
func (b *backend) handle(c1 *tls.Conn, c *net.TCPConn) {
c2, err := net.DialTCP("tcp", nil, b.addr)
if err != nil {
c1.Close()
return
}
go func() {
err := io.Copy(c2, c1)
if err != nil {
log.Print(err)
}
c.CloseWrite()
c1.CloseRead()
}()
err := io.Copy(c1, c2)
if err != nil {
log.Print(err)
}
c.CloseWrite()
c2.CloseRead()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment