Clash.Meta/transport/vmess/tls.go

25 lines
448 B
Go
Raw Normal View History

2020-04-03 16:04:24 +08:00
package vmess
import (
"crypto/tls"
"net"
)
type TLSConfig struct {
Host string
SkipCertVerify bool
NextProtos []string
2020-04-03 16:04:24 +08:00
}
func StreamTLSConn(conn net.Conn, cfg *TLSConfig) (net.Conn, error) {
tlsConfig := &tls.Config{
ServerName: cfg.Host,
InsecureSkipVerify: cfg.SkipCertVerify,
NextProtos: cfg.NextProtos,
2020-04-03 16:04:24 +08:00
}
tlsConn := tls.Client(conn, tlsConfig)
err := tlsConn.Handshake()
return tlsConn, err
}