mirror of
https://gitclone.com/github.com/MetaCubeX/Clash.Meta
synced 2024-11-15 05:31:18 +08:00
26 lines
472 B
Go
26 lines
472 B
Go
|
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
|
||
|
}
|