github.com/sagernet/sing-box@v1.9.0-rc.20/transport/vless/vision_utls.go (about)

     1  //go:build with_utls
     2  
     3  package vless
     4  
     5  import (
     6  	"net"
     7  	"reflect"
     8  	"unsafe"
     9  
    10  	"github.com/sagernet/sing/common"
    11  	utls "github.com/sagernet/utls"
    12  )
    13  
    14  func init() {
    15  	tlsRegistry = append(tlsRegistry, func(conn net.Conn) (loaded bool, netConn net.Conn, reflectType reflect.Type, reflectPointer uintptr) {
    16  		tlsConn, loaded := common.Cast[*utls.UConn](conn)
    17  		if !loaded {
    18  			return
    19  		}
    20  		return true, tlsConn.NetConn(), reflect.TypeOf(tlsConn.Conn).Elem(), uintptr(unsafe.Pointer(tlsConn.Conn))
    21  	})
    22  }