Skip to content

Commit

Permalink
feat: Support VLESS XTLS Vision (#406)
Browse files Browse the repository at this point in the history
  • Loading branch information
H1JK authored and wwqgtxx committed Feb 25, 2023
1 parent 5bfad04 commit 8172261
Show file tree
Hide file tree
Showing 7 changed files with 477 additions and 43 deletions.
8 changes: 4 additions & 4 deletions adapter/outbound/vless.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ func (v *Vless) StreamConn(c net.Conn, metadata *C.Metadata) (net.Conn, error) {
func (v *Vless) streamTLSOrXTLSConn(conn net.Conn, isH2 bool) (net.Conn, error) {
host, _, _ := net.SplitHostPort(v.addr)

if v.isXTLSEnabled() && !isH2 {
if v.isLegacyXTLSEnabled() && !isH2 {
xtlsOpts := vless.XTLSConfig{
Host: host,
SkipCertVerify: v.option.SkipCertVerify,
Expand Down Expand Up @@ -206,8 +206,8 @@ func (v *Vless) streamTLSOrXTLSConn(conn net.Conn, isH2 bool) (net.Conn, error)
return conn, nil
}

func (v *Vless) isXTLSEnabled() bool {
return v.client.Addons != nil
func (v *Vless) isLegacyXTLSEnabled() bool {
return v.client.Addons != nil && v.client.Addons.Flow != vless.XRV
}

// DialContext implements C.ProxyAdapter
Expand Down Expand Up @@ -479,7 +479,7 @@ func NewVless(option VlessOption) (*Vless, error) {
if option.Network != "ws" && len(option.Flow) >= 16 {
option.Flow = option.Flow[:16]
switch option.Flow {
case vless.XRO, vless.XRD, vless.XRS:
case vless.XRO, vless.XRD, vless.XRS, vless.XRV:
addons = &vless.Addons{
Flow: option.Flow,
}
Expand Down
6 changes: 6 additions & 0 deletions common/buf/sing.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,15 @@ import (
"github.com/sagernet/sing/common/buf"
)

const BufferSize = buf.BufferSize

type Buffer = buf.Buffer

var New = buf.New
var StackNew = buf.StackNew
var StackNewSize = buf.StackNewSize
var With = buf.With

var KeepAlive = common.KeepAlive

//go:norace
Expand Down

0 comments on commit 8172261

Please sign in to comment.