mirror of
https://github.com/SagerNet/sing-mux.git
synced 2025-04-01 19:17:36 +03:00
Fix h2mux open
This commit is contained in:
parent
802d9510a7
commit
9bfb33698b
3 changed files with 7 additions and 12 deletions
|
@ -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
|
||||
}
|
||||
|
|
6
h2mux.go
6
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()
|
||||
}
|
||||
}()
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue