Upgrade github.com/xtls/reality to f34b4d174342

Fixes https://github.com/XTLS/Xray-core/issues/1712
This commit is contained in:
RPRX 2023-02-26 19:26:57 +08:00 committed by GitHub
parent a5b297f968
commit c38179a67f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 12 additions and 8 deletions

2
go.mod
View File

@ -20,7 +20,7 @@ require (
github.com/stretchr/testify v1.8.1 github.com/stretchr/testify v1.8.1
github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e
github.com/xtls/go v0.0.0-20230107031059-4610f88d00f3 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 go.starlark.net v0.0.0-20230128213706-3f75dec8e403
golang.org/x/crypto v0.6.0 golang.org/x/crypto v0.6.0
golang.org/x/net v0.7.0 golang.org/x/net v0.7.0

4
go.sum
View File

@ -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/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 h1:a3Y4WVjCxwoyO4E2xdNvq577tW8lkSBgyrA8E9+2NtM=
github.com/xtls/go v0.0.0-20230107031059-4610f88d00f3/go.mod h1:YJTRELIWrGxR1s8xcEBgxcxBfwQfMGjdvNLTjN9XFgY= 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-20230226072656-f34b4d174342 h1:lu9BD/UFZexv70X7mbmSJOyRHRO23mPFrW1xPlLhkGk=
github.com/xtls/reality v0.0.0-20230217102704-085bdf2104d3/go.mod h1:rkuAY1S9F8eI8gDiPDYvACE8e2uwkyg8qoOTuwWov7Y= 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= 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.opencensus.io v0.18.0/go.mod h1:vKdFvxhtzZ9onBp9VKHK8z/sRpBMnKAsufL7wlDrCOA=
go.starlark.net v0.0.0-20230128213706-3f75dec8e403 h1:jPeC7Exc+m8OBJUlWbBLh0O5UZPM7yU5W4adnhhbG4U= go.starlark.net v0.0.0-20230128213706-3f75dec8e403 h1:jPeC7Exc+m8OBJUlWbBLh0O5UZPM7yU5W4adnhhbG4U=

View File

@ -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() return newError(`failed to use `+requestAddons.Flow+`, found outer tls version `, tlsConn.ConnectionState().Version).AtWarning()
} }
netConn = tlsConn.NetConn() 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() t = reflect.TypeOf(tlsConn.Conn).Elem()
p = uintptr(unsafe.Pointer(tlsConn.Conn)) p = uintptr(unsafe.Pointer(tlsConn.Conn))
} else if realityConn, ok := iConn.(*reality.Conn); ok { } 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 { } 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()
} }
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 { if sc, ok := netConn.(syscall.Conn); ok {
rawConn, _ = sc.SyscallConn() rawConn, _ = sc.SyscallConn()
} }

View File

@ -1,6 +1,7 @@
package reality package reality
import ( import (
"net"
"time" "time"
"github.com/xtls/reality" "github.com/xtls/reality"
@ -8,7 +9,10 @@ import (
) )
func (c *Config) GetREALITYConfig() *reality.Config { func (c *Config) GetREALITYConfig() *reality.Config {
var dialer net.Dialer
config := &reality.Config{ config := &reality.Config{
DialContext: dialer.DialContext,
Show: c.Show, Show: c.Show,
Type: c.Type, Type: c.Type,
Dest: c.Dest, Dest: c.Dest,

View File

@ -52,7 +52,7 @@ func (c *Conn) HandshakeAddress() net.Address {
} }
func Server(c net.Conn, config *reality.Config) (net.Conn, error) { 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 return &Conn{Conn: realityConn}, err
} }