cast badtls

This commit is contained in:
dyhkwong 2024-01-15 23:07:30 +08:00
parent f91a90cad8
commit 254b60778c
2 changed files with 8 additions and 0 deletions

View File

@ -11,3 +11,7 @@ import (
func NewReadWaitConn(conn tls.Conn) (tls.Conn, error) {
return nil, os.ErrInvalid
}
type ReadWaitConn struct {
tls.Conn
}

View File

@ -11,6 +11,7 @@ import (
"time"
"unsafe"
"github.com/sagernet/sing-box/common/badtls"
C "github.com/sagernet/sing-box/constant"
"github.com/sagernet/sing/common"
"github.com/sagernet/sing/common/buf"
@ -68,6 +69,9 @@ func NewVisionConn(conn net.Conn, tlsConn net.Conn, userUUID [16]byte, logger lo
reflectPointer uintptr
netConn net.Conn
)
if badtlsConn, ok := common.Cast[*badtls.ReadWaitConn](tlsConn); ok {
tlsConn = badtlsConn.Conn
}
for _, tlsCreator := range tlsRegistry {
loaded, netConn, reflectType, reflectPointer = tlsCreator(tlsConn)
if loaded {