github.com/sagernet/sing-box@v1.9.0-rc.20/common/badtls/read_wait_utls.go (about)

     1  //go:build go1.21 && !without_badtls && with_utls
     2  
     3  package badtls
     4  
     5  import (
     6  	"net"
     7  	_ "unsafe"
     8  
     9  	"github.com/sagernet/sing/common"
    10  	"github.com/sagernet/utls"
    11  )
    12  
    13  func init() {
    14  	tlsRegistry = append(tlsRegistry, func(conn net.Conn) (loaded bool, tlsReadRecord func() error, tlsHandlePostHandshakeMessage func() error) {
    15  		tlsConn, loaded := common.Cast[*tls.UConn](conn)
    16  		if !loaded {
    17  			return
    18  		}
    19  		return true, func() error {
    20  				return utlsReadRecord(tlsConn.Conn)
    21  			}, func() error {
    22  				return utlsHandlePostHandshakeMessage(tlsConn.Conn)
    23  			}
    24  	})
    25  }
    26  
    27  //go:linkname utlsReadRecord github.com/sagernet/utls.(*Conn).readRecord
    28  func utlsReadRecord(c *tls.Conn) error
    29  
    30  //go:linkname utlsHandlePostHandshakeMessage github.com/sagernet/utls.(*Conn).handlePostHandshakeMessage
    31  func utlsHandlePostHandshakeMessage(c *tls.Conn) error