Improve multiplex

This commit is contained in:
世界
2023-04-20 11:16:22 +08:00
parent f61c5600e0
commit 9c287094e2
14 changed files with 346 additions and 47 deletions

View File

@@ -9,6 +9,8 @@ import (
"github.com/sagernet/sing/common/bufio"
N "github.com/sagernet/sing/common/network"
"github.com/sagernet/smux"
"github.com/hashicorp/yamux"
)
type abstractSession interface {
@@ -17,6 +19,7 @@ type abstractSession interface {
NumStreams() int
Close() error
IsClosed() bool
CanTakeNewRequest() bool
}
var _ abstractSession = (*smuxSession)(nil)
@@ -33,6 +36,18 @@ func (s *smuxSession) Accept() (net.Conn, error) {
return s.AcceptStream()
}
func (s *smuxSession) CanTakeNewRequest() bool {
return true
}
type yamuxSession struct {
*yamux.Session
}
func (y *yamuxSession) CanTakeNewRequest() bool {
return true
}
type protocolConn struct {
net.Conn
protocol Protocol