Last active
May 15, 2018 04:53
-
-
Save nhooyr/311a9d0206fa7c8221f8a9e4f0a9fc81 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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