vision_reality.go 495 B

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