diff --git a/client.go b/client.go index 519f7cd..a7896e0 100644 --- a/client.go +++ b/client.go @@ -113,7 +113,7 @@ func (c *Client) openStream(ctx context.Context) (net.Conn, error) { if err != nil { continue } - stream, err = session.OpenContext(ctx) + stream, err = session.Open() if err != nil { continue } @@ -206,7 +206,7 @@ func (c *Client) offerNew(ctx context.Context) (abstractSession, error) { } func (c *Client) brutalExchange(ctx context.Context, sessionConn net.Conn, session abstractSession) error { - stream, err := session.OpenContext(ctx) + stream, err := session.Open() if err != nil { return err } diff --git a/h2mux.go b/h2mux.go index f328648..54c3c70 100644 --- a/h2mux.go +++ b/h2mux.go @@ -64,7 +64,7 @@ func (s *h2MuxServerSession) ServeHTTP(writer http.ResponseWriter, request *http } } -func (s *h2MuxServerSession) OpenContext(ctx context.Context) (net.Conn, error) { +func (s *h2MuxServerSession) Open() (net.Conn, error) { return nil, os.ErrInvalid } @@ -197,7 +197,7 @@ func (s *h2MuxClientSession) MarkDead(conn *http2.ClientConn) { s.Close() } -func (s *h2MuxClientSession) OpenContext(ctx context.Context) (net.Conn, error) { +func (s *h2MuxClientSession) Open() (net.Conn, error) { pipeInReader, pipeInWriter := io.Pipe() request := &http.Request{ Method: http.MethodConnect, @@ -212,7 +212,7 @@ func (s *h2MuxClientSession) OpenContext(ctx context.Context) (net.Conn, error) select { case <-requestDone: return - case <-ctx.Done(): + case <-time.After(TCPTimeout): cancel() } }() diff --git a/session.go b/session.go index 524f573..2dc37b3 100644 --- a/session.go +++ b/session.go @@ -1,7 +1,6 @@ package mux import ( - "context" "io" "net" "reflect" @@ -13,7 +12,7 @@ import ( ) type abstractSession interface { - OpenContext(ctx context.Context) (net.Conn, error) + Open() (net.Conn, error) Accept() (net.Conn, error) NumStreams() int Close() error @@ -81,7 +80,7 @@ type smuxSession struct { *smux.Session } -func (s *smuxSession) OpenContext(context.Context) (net.Conn, error) { +func (s *smuxSession) Open() (net.Conn, error) { return s.OpenStream() } @@ -97,10 +96,6 @@ type yamuxSession struct { *yamux.Session } -func (y *yamuxSession) OpenContext(context.Context) (net.Conn, error) { - return y.OpenStream() -} - func (y *yamuxSession) CanTakeNewRequest() bool { return true }