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

     1  //go:build with_reality_server
     2  
     3  package vless
     4  
     5  import (
     6  	"net"
     7  	"reflect"
     8  	"unsafe"
     9  
    10  	"github.com/sagernet/reality"
    11  	"github.com/sagernet/sing/common"
    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[*reality.Conn](conn)
    17  		if !loaded {
    18  			return
    19  		}
    20  		return true, tlsConn.NetConn(), reflect.TypeOf(tlsConn).Elem(), uintptr(unsafe.Pointer(tlsConn))
    21  	})
    22  }