read_wait_ech.go 843 B

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