mirror of
https://gitclone.com/github.com/MetaCubeX/Clash.Meta
synced 2024-11-15 13:41:23 +08:00
25 lines
448 B
Go
25 lines
448 B
Go
package vmess
|
|
|
|
import (
|
|
"crypto/tls"
|
|
"net"
|
|
)
|
|
|
|
type TLSConfig struct {
|
|
Host string
|
|
SkipCertVerify bool
|
|
NextProtos []string
|
|
}
|
|
|
|
func StreamTLSConn(conn net.Conn, cfg *TLSConfig) (net.Conn, error) {
|
|
tlsConfig := &tls.Config{
|
|
ServerName: cfg.Host,
|
|
InsecureSkipVerify: cfg.SkipCertVerify,
|
|
NextProtos: cfg.NextProtos,
|
|
}
|
|
|
|
tlsConn := tls.Client(conn, tlsConfig)
|
|
err := tlsConn.Handshake()
|
|
return tlsConn, err
|
|
}
|