mirror of
https://github.com/SagerNet/sing-box.git
synced 2025-06-08 03:34:13 +08:00
33 lines
765 B
Go
33 lines
765 B
Go
package tf_test
|
|
|
|
import (
|
|
"context"
|
|
"crypto/tls"
|
|
"net"
|
|
"testing"
|
|
|
|
tf "github.com/sagernet/sing-box/common/tlsfragment"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestTLSFragment(t *testing.T) {
|
|
t.Parallel()
|
|
tcpConn, err := net.Dial("tcp", "1.1.1.1:443")
|
|
require.NoError(t, err)
|
|
tlsConn := tls.Client(tf.NewConn(tcpConn, context.Background(), false, 0), &tls.Config{
|
|
ServerName: "www.cloudflare.com",
|
|
})
|
|
require.NoError(t, tlsConn.Handshake())
|
|
}
|
|
|
|
func TestTLSRecordFragment(t *testing.T) {
|
|
t.Parallel()
|
|
tcpConn, err := net.Dial("tcp", "1.1.1.1:443")
|
|
require.NoError(t, err)
|
|
tlsConn := tls.Client(tf.NewConn(tcpConn, context.Background(), true, 0), &tls.Config{
|
|
ServerName: "www.cloudflare.com",
|
|
})
|
|
require.NoError(t, tlsConn.Handshake())
|
|
}
|