mirror of
https://github.com/SagerNet/sing-box.git
synced 2025-08-21 17:47:37 +08:00
Make ReadWaitConn reader replaceable
This commit is contained in:
parent
f4ed684146
commit
f1dd0dba78
@ -128,6 +128,10 @@ func (c *ReadWaitConn) Upstream() any {
|
|||||||
return c.Conn
|
return c.Conn
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *ReadWaitConn) ReaderReplaceable() bool {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
var tlsRegistry []func(conn net.Conn) (loaded bool, tlsReadRecord func() error, tlsHandlePostHandshakeMessage func() error)
|
var tlsRegistry []func(conn net.Conn) (loaded bool, tlsReadRecord func() error, tlsHandlePostHandshakeMessage func() error)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -6,22 +6,26 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
_ "unsafe"
|
_ "unsafe"
|
||||||
|
|
||||||
"github.com/sagernet/sing/common"
|
|
||||||
|
|
||||||
"github.com/metacubex/utls"
|
"github.com/metacubex/utls"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
tlsRegistry = append(tlsRegistry, func(conn net.Conn) (loaded bool, tlsReadRecord func() error, tlsHandlePostHandshakeMessage func() error) {
|
tlsRegistry = append(tlsRegistry, func(conn net.Conn) (loaded bool, tlsReadRecord func() error, tlsHandlePostHandshakeMessage func() error) {
|
||||||
tlsConn, loaded := common.Cast[*tls.UConn](conn)
|
switch tlsConn := conn.(type) {
|
||||||
if !loaded {
|
case *tls.UConn:
|
||||||
return
|
return true, func() error {
|
||||||
|
return utlsReadRecord(tlsConn.Conn)
|
||||||
|
}, func() error {
|
||||||
|
return utlsHandlePostHandshakeMessage(tlsConn.Conn)
|
||||||
|
}
|
||||||
|
case *tls.Conn:
|
||||||
|
return true, func() error {
|
||||||
|
return utlsReadRecord(tlsConn)
|
||||||
|
}, func() error {
|
||||||
|
return utlsHandlePostHandshakeMessage(tlsConn)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true, func() error {
|
return
|
||||||
return utlsReadRecord(tlsConn.Conn)
|
|
||||||
}, func() error {
|
|
||||||
return utlsHandlePostHandshakeMessage(tlsConn.Conn)
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user