Open
Description
Hi there, congratulations on getting this project to this state, it looks quite promising!
As part of the development of Outline and Outline SDK, I played with interfaces a lot. One thing that became clear to me is that the Go dial API isn't that great.
Most critically, Dial
returns a net.Conn
, which doesn't support TCP semantics. To support TCP, you need to be able to close the write end (which sends a FIN). While TCPConn
has CloseRead()
and CloseWrite()
, net.Conn
does not. That's a big omission, and the reason why we use StreamConn
instead in the Outline SDK. You must be able to indicate you are done sending without tearing down the entire connection.
Other less important issues, perhaps personal preference:
DialContext
is unnecessarily verbose, and having two Dials is redundant and confusing. Just makeDial
take acontext.Context
.- The
network
parameter in the Dial is unnecessary, and a violation of the encapsulation. It leaks the implementation of the Dialer. Want to dial using TCP? Use a TCP dialer. Want to use IPv6? Use a dialer that uses IPv6. In the Outline SDK, we explicitly have different calls for stream and datagram (packet) dial and connections to give the developer stronger typing, since the connections are semantically different.