Feature: add xtls support for VLESS

This commit is contained in:
yaling888
2021-07-06 23:55:34 +08:00
parent 56dff65149
commit b4d93c4438
11 changed files with 567 additions and 193 deletions

25
transport/vless/xtls.go Normal file
View File

@ -0,0 +1,25 @@
package vless
import (
"net"
xtls "github.com/xtls/go"
)
type XTLSConfig struct {
Host string
SkipCertVerify bool
NextProtos []string
}
func StreamXTLSConn(conn net.Conn, cfg *XTLSConfig) (net.Conn, error) {
xtlsConfig := &xtls.Config{
ServerName: cfg.Host,
InsecureSkipVerify: cfg.SkipCertVerify,
NextProtos: cfg.NextProtos,
}
xtlsConn := xtls.Client(conn, xtlsConfig)
err := xtlsConn.Handshake()
return xtlsConn, err
}