conn_test.go 765 B

1234567891011121314151617181920212223242526272829303132
  1. package tf_test
  2. import (
  3. "context"
  4. "crypto/tls"
  5. "net"
  6. "testing"
  7. tf "github.com/sagernet/sing-box/common/tlsfragment"
  8. "github.com/stretchr/testify/require"
  9. )
  10. func TestTLSFragment(t *testing.T) {
  11. t.Parallel()
  12. tcpConn, err := net.Dial("tcp", "1.1.1.1:443")
  13. require.NoError(t, err)
  14. tlsConn := tls.Client(tf.NewConn(tcpConn, context.Background(), false, 0), &tls.Config{
  15. ServerName: "www.cloudflare.com",
  16. })
  17. require.NoError(t, tlsConn.Handshake())
  18. }
  19. func TestTLSRecordFragment(t *testing.T) {
  20. t.Parallel()
  21. tcpConn, err := net.Dial("tcp", "1.1.1.1:443")
  22. require.NoError(t, err)
  23. tlsConn := tls.Client(tf.NewConn(tcpConn, context.Background(), true, 0), &tls.Config{
  24. ServerName: "www.cloudflare.com",
  25. })
  26. require.NoError(t, tlsConn.Handshake())
  27. }