|
@@ -3,9 +3,12 @@ package outbound
|
|
|
//go:generate go run github.com/xtls/xray-core/common/errors/errorgen
|
|
//go:generate go run github.com/xtls/xray-core/common/errors/errorgen
|
|
|
|
|
|
|
|
import (
|
|
import (
|
|
|
|
|
+ "bytes"
|
|
|
"context"
|
|
"context"
|
|
|
|
|
+ "reflect"
|
|
|
"syscall"
|
|
"syscall"
|
|
|
"time"
|
|
"time"
|
|
|
|
|
+ "unsafe"
|
|
|
|
|
|
|
|
"github.com/xtls/xray-core/common"
|
|
"github.com/xtls/xray-core/common"
|
|
|
"github.com/xtls/xray-core/common/buf"
|
|
"github.com/xtls/xray-core/common/buf"
|
|
@@ -130,6 +133,8 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte
|
|
|
|
|
|
|
|
var netConn net.Conn
|
|
var netConn net.Conn
|
|
|
var rawConn syscall.RawConn
|
|
var rawConn syscall.RawConn
|
|
|
|
|
+ var input *bytes.Reader
|
|
|
|
|
+ var rawInput *bytes.Buffer
|
|
|
allowUDP443 := false
|
|
allowUDP443 := false
|
|
|
switch requestAddons.Flow {
|
|
switch requestAddons.Flow {
|
|
|
case vless.XRO + "-udp443", vless.XRD + "-udp443", vless.XRS + "-udp443", vless.XRV + "-udp443":
|
|
case vless.XRO + "-udp443", vless.XRD + "-udp443", vless.XRS + "-udp443", vless.XRV + "-udp443":
|
|
@@ -147,21 +152,31 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte
|
|
|
requestAddons.Flow = ""
|
|
requestAddons.Flow = ""
|
|
|
case protocol.RequestCommandTCP:
|
|
case protocol.RequestCommandTCP:
|
|
|
if requestAddons.Flow == vless.XRV {
|
|
if requestAddons.Flow == vless.XRV {
|
|
|
|
|
+ var t reflect.Type
|
|
|
|
|
+ var p uintptr
|
|
|
if tlsConn, ok := iConn.(*tls.Conn); ok {
|
|
if tlsConn, ok := iConn.(*tls.Conn); ok {
|
|
|
netConn = tlsConn.NetConn()
|
|
netConn = tlsConn.NetConn()
|
|
|
if sc, ok := netConn.(syscall.Conn); ok {
|
|
if sc, ok := netConn.(syscall.Conn); ok {
|
|
|
rawConn, _ = sc.SyscallConn()
|
|
rawConn, _ = sc.SyscallConn()
|
|
|
}
|
|
}
|
|
|
|
|
+ t = reflect.TypeOf(tlsConn.Conn).Elem()
|
|
|
|
|
+ p = uintptr(unsafe.Pointer(tlsConn.Conn))
|
|
|
} else if utlsConn, ok := iConn.(*tls.UConn); ok {
|
|
} else if utlsConn, ok := iConn.(*tls.UConn); ok {
|
|
|
netConn = utlsConn.Conn.NetConn()
|
|
netConn = utlsConn.Conn.NetConn()
|
|
|
if sc, ok := netConn.(syscall.Conn); ok {
|
|
if sc, ok := netConn.(syscall.Conn); ok {
|
|
|
rawConn, _ = sc.SyscallConn()
|
|
rawConn, _ = sc.SyscallConn()
|
|
|
}
|
|
}
|
|
|
|
|
+ t = reflect.TypeOf(utlsConn.Conn).Elem()
|
|
|
|
|
+ p = uintptr(unsafe.Pointer(utlsConn.Conn))
|
|
|
} else if _, ok := iConn.(*xtls.Conn); ok {
|
|
} else if _, ok := iConn.(*xtls.Conn); ok {
|
|
|
return newError(`failed to use ` + requestAddons.Flow + `, vision "security" must be "tls"`).AtWarning()
|
|
return newError(`failed to use ` + requestAddons.Flow + `, vision "security" must be "tls"`).AtWarning()
|
|
|
} else {
|
|
} else {
|
|
|
return newError("XTLS only supports TCP, mKCP and DomainSocket for now.").AtWarning()
|
|
return newError("XTLS only supports TCP, mKCP and DomainSocket for now.").AtWarning()
|
|
|
}
|
|
}
|
|
|
|
|
+ i, _ := t.FieldByName("input")
|
|
|
|
|
+ r, _ := t.FieldByName("rawInput")
|
|
|
|
|
+ input = (*bytes.Reader)(unsafe.Pointer(p + i.Offset))
|
|
|
|
|
+ rawInput = (*bytes.Buffer)(unsafe.Pointer(p + r.Offset))
|
|
|
} else if xtlsConn, ok := iConn.(*xtls.Conn); ok {
|
|
} else if xtlsConn, ok := iConn.(*xtls.Conn); ok {
|
|
|
xtlsConn.RPRX = true
|
|
xtlsConn.RPRX = true
|
|
|
xtlsConn.SHOW = xtls_show
|
|
xtlsConn.SHOW = xtls_show
|
|
@@ -287,7 +302,7 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte
|
|
|
counter = statConn.ReadCounter
|
|
counter = statConn.ReadCounter
|
|
|
}
|
|
}
|
|
|
if requestAddons.Flow == vless.XRV {
|
|
if requestAddons.Flow == vless.XRV {
|
|
|
- err = encoding.XtlsRead(serverReader, clientWriter, timer, netConn, rawConn, counter, ctx, account.ID.Bytes(),
|
|
|
|
|
|
|
+ err = encoding.XtlsRead(serverReader, clientWriter, timer, netConn, rawConn, input, rawInput, counter, ctx, account.ID.Bytes(),
|
|
|
&numberOfPacketToFilter, &enableXtls, &isTLS12orAbove, &isTLS, &cipher, &remainingServerHello)
|
|
&numberOfPacketToFilter, &enableXtls, &isTLS12orAbove, &isTLS, &cipher, &remainingServerHello)
|
|
|
} else {
|
|
} else {
|
|
|
if requestAddons.Flow != vless.XRS {
|
|
if requestAddons.Flow != vless.XRS {
|