derp: clean up derphttp client code, use contexts

Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
Brad Fitzpatrick
2020-02-28 13:18:10 -08:00
parent cdc10b74f1
commit 752146a70f
3 changed files with 123 additions and 79 deletions

View File

@@ -97,10 +97,13 @@ func (s *Server) isClosed() bool {
return s.closed
}
// Accept adds a new connection to the server.
// Accept adds a new connection to the server and serves it.
//
// The provided bufio ReadWriter must be already connected to nc.
// Accept blocks until the Server is closed or the connection closes
// on its own.
//
// Accept closes nc.
func (s *Server) Accept(nc net.Conn, brw *bufio.ReadWriter) {
closed := make(chan struct{})