Feature: add xtls support for VLESS
This commit is contained in:
25
transport/vless/xtls.go
Normal file
25
transport/vless/xtls.go
Normal 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
|
||||
}
|
Reference in New Issue
Block a user