Fix: vmess pure TLS mode

This commit is contained in:
Dreamacro
2020-04-03 16:04:24 +08:00
parent 19f809b1c8
commit 5591e15452
2 changed files with 36 additions and 1 deletions

24
component/vmess/tls.go Normal file
View File

@ -0,0 +1,24 @@
package vmess
import (
"crypto/tls"
"net"
)
type TLSConfig struct {
Host string
SkipCertVerify bool
SessionCache tls.ClientSessionCache
}
func StreamTLSConn(conn net.Conn, cfg *TLSConfig) (net.Conn, error) {
tlsConfig := &tls.Config{
ServerName: cfg.Host,
InsecureSkipVerify: cfg.SkipCertVerify,
ClientSessionCache: cfg.SessionCache,
}
tlsConn := tls.Client(conn, tlsConfig)
err := tlsConn.Handshake()
return tlsConn, err
}