From c38179a67feb993d63adc99cc7f4918e4d1d5c57 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Sun, 26 Feb 2023 19:26:57 +0800 Subject: [PATCH] Upgrade github.com/xtls/reality to f34b4d174342 Fixes https://github.com/XTLS/Xray-core/issues/1712 --- go.mod | 2 +- go.sum | 4 ++-- proxy/vless/inbound/inbound.go | 8 ++++---- transport/internet/reality/config.go | 4 ++++ transport/internet/reality/reality.go | 2 +- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/go.mod b/go.mod index 01993c74..070bc02b 100644 --- a/go.mod +++ b/go.mod @@ -20,7 +20,7 @@ require ( github.com/stretchr/testify v1.8.1 github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e github.com/xtls/go v0.0.0-20230107031059-4610f88d00f3 - github.com/xtls/reality v0.0.0-20230217102704-085bdf2104d3 + github.com/xtls/reality v0.0.0-20230226072656-f34b4d174342 go.starlark.net v0.0.0-20230128213706-3f75dec8e403 golang.org/x/crypto v0.6.0 golang.org/x/net v0.7.0 diff --git a/go.sum b/go.sum index f7e9ccb2..3c8110eb 100644 --- a/go.sum +++ b/go.sum @@ -191,8 +191,8 @@ github.com/viant/assertly v0.4.8/go.mod h1:aGifi++jvCrUaklKEKT0BU95igDNaqkvz+49u github.com/viant/toolbox v0.24.0/go.mod h1:OxMCG57V0PXuIP2HNQrtJf2CjqdmbrOx5EkMILuUhzM= github.com/xtls/go v0.0.0-20230107031059-4610f88d00f3 h1:a3Y4WVjCxwoyO4E2xdNvq577tW8lkSBgyrA8E9+2NtM= github.com/xtls/go v0.0.0-20230107031059-4610f88d00f3/go.mod h1:YJTRELIWrGxR1s8xcEBgxcxBfwQfMGjdvNLTjN9XFgY= -github.com/xtls/reality v0.0.0-20230217102704-085bdf2104d3 h1:Rp9BfXZ+Li5j5L40zAdFZLcr0nXrYBPgaNpQ9lQnpWg= -github.com/xtls/reality v0.0.0-20230217102704-085bdf2104d3/go.mod h1:rkuAY1S9F8eI8gDiPDYvACE8e2uwkyg8qoOTuwWov7Y= +github.com/xtls/reality v0.0.0-20230226072656-f34b4d174342 h1:lu9BD/UFZexv70X7mbmSJOyRHRO23mPFrW1xPlLhkGk= +github.com/xtls/reality v0.0.0-20230226072656-f34b4d174342/go.mod h1:rkuAY1S9F8eI8gDiPDYvACE8e2uwkyg8qoOTuwWov7Y= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= go.opencensus.io v0.18.0/go.mod h1:vKdFvxhtzZ9onBp9VKHK8z/sRpBMnKAsufL7wlDrCOA= go.starlark.net v0.0.0-20230128213706-3f75dec8e403 h1:jPeC7Exc+m8OBJUlWbBLh0O5UZPM7yU5W4adnhhbG4U= diff --git a/proxy/vless/inbound/inbound.go b/proxy/vless/inbound/inbound.go index a7863051..d060f222 100644 --- a/proxy/vless/inbound/inbound.go +++ b/proxy/vless/inbound/inbound.go @@ -495,10 +495,6 @@ func (h *Handler) Process(ctx context.Context, network net.Network, connection s return newError(`failed to use `+requestAddons.Flow+`, found outer tls version `, tlsConn.ConnectionState().Version).AtWarning() } netConn = tlsConn.NetConn() - if pc, ok := netConn.(*proxyproto.Conn); ok { - netConn = pc.Raw() - // 8192 > 4096, there is no need to process pc's bufReader - } t = reflect.TypeOf(tlsConn.Conn).Elem() p = uintptr(unsafe.Pointer(tlsConn.Conn)) } else if realityConn, ok := iConn.(*reality.Conn); ok { @@ -512,6 +508,10 @@ func (h *Handler) Process(ctx context.Context, network net.Network, connection s } else { return newError("XTLS only supports TCP, mKCP and DomainSocket for now.").AtWarning() } + if pc, ok := netConn.(*proxyproto.Conn); ok { + netConn = pc.Raw() + // 8192 > 4096, there is no need to process pc's bufReader + } if sc, ok := netConn.(syscall.Conn); ok { rawConn, _ = sc.SyscallConn() } diff --git a/transport/internet/reality/config.go b/transport/internet/reality/config.go index f7938db5..58608720 100644 --- a/transport/internet/reality/config.go +++ b/transport/internet/reality/config.go @@ -1,6 +1,7 @@ package reality import ( + "net" "time" "github.com/xtls/reality" @@ -8,7 +9,10 @@ import ( ) func (c *Config) GetREALITYConfig() *reality.Config { + var dialer net.Dialer config := &reality.Config{ + DialContext: dialer.DialContext, + Show: c.Show, Type: c.Type, Dest: c.Dest, diff --git a/transport/internet/reality/reality.go b/transport/internet/reality/reality.go index 145f1531..835c075a 100644 --- a/transport/internet/reality/reality.go +++ b/transport/internet/reality/reality.go @@ -52,7 +52,7 @@ func (c *Conn) HandshakeAddress() net.Address { } func Server(c net.Conn, config *reality.Config) (net.Conn, error) { - realityConn, err := reality.Server(c, config) + realityConn, err := reality.Server(context.Background(), c, config) return &Conn{Conn: realityConn}, err }