vision_utls.go 495 B

12345678910111213141516171819202122
  1. //go:build with_utls
  2. package vless
  3. import (
  4. "net"
  5. "reflect"
  6. "unsafe"
  7. "github.com/sagernet/sing/common"
  8. utls "github.com/sagernet/utls"
  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[*utls.UConn](conn)
  13. if !loaded {
  14. return
  15. }
  16. return true, tlsConn.NetConn(), reflect.TypeOf(tlsConn.Conn).Elem(), uintptr(unsafe.Pointer(tlsConn.Conn))
  17. })
  18. }