Jelajahi Sumber

Upgrade github.com/xtls/reality to f34b4d174342

Fixes https://github.com/XTLS/Xray-core/issues/1712
RPRX 2 tahun lalu
induk
melakukan
c38179a67f

+ 1 - 1
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

+ 2 - 2
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=

+ 4 - 4
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()
 					}

+ 4 - 0
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,

+ 1 - 1
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
 }