diff --git a/common/tls/reality_client.go b/common/tls/reality_client.go index 80edad8c..0f8e1dc4 100644 --- a/common/tls/reality_client.go +++ b/common/tls/reality_client.go @@ -27,14 +27,12 @@ import ( "time" "unsafe" - "github.com/sagernet/sing-box/adapter" C "github.com/sagernet/sing-box/constant" "github.com/sagernet/sing-box/option" "github.com/sagernet/sing/common/debug" E "github.com/sagernet/sing/common/exceptions" "github.com/sagernet/sing/common/logger" M "github.com/sagernet/sing/common/metadata" - "github.com/sagernet/sing/common/ntp" aTLS "github.com/sagernet/sing/common/tls" utls "github.com/metacubex/utls" @@ -45,7 +43,6 @@ import ( var _ ConfigCompat = (*RealityClientConfig)(nil) type RealityClientConfig struct { - ctx context.Context uClient *UTLSClientConfig publicKey []byte shortID [8]byte @@ -84,7 +81,7 @@ func newRealityClient(ctx context.Context, logger logger.ContextLogger, serverAd return nil, E.New("invalid short_id") } - var config Config = &RealityClientConfig{ctx, uClient.(*UTLSClientConfig), publicKey, shortID} + var config Config = &RealityClientConfig{uClient.(*UTLSClientConfig), publicKey, shortID} if options.KernelRx || options.KernelTx { if !C.IsLinux { return nil, E.New("kTLS is only supported on Linux") @@ -209,7 +206,7 @@ func (e *RealityClientConfig) ClientHandshake(ctx context.Context, conn net.Conn } if !verifier.verified { - go realityClientFallback(e.ctx, uConn, e.uClient.ServerName(), e.uClient.id) + realityClientFallback(ctx, uConn, e.uClient.ServerName(), e.uClient.id) return nil, E.New("reality verification failed") } @@ -223,10 +220,6 @@ func realityClientFallback(ctx context.Context, uConn net.Conn, serverName strin DialTLSContext: func(ctx context.Context, network, addr string, config *tls.Config) (net.Conn, error) { return uConn, nil }, - TLSClientConfig: &tls.Config{ - Time: ntp.TimeFuncFromContext(ctx), - RootCAs: adapter.RootPoolFromContext(ctx), - }, }, } serverAddress := M.ParseSocksaddrHostPort(serverName, 0) @@ -234,7 +227,7 @@ func realityClientFallback(ctx context.Context, uConn net.Conn, serverName strin if serverAddress.IsIPv6() { host = "[" + host + "]" } - request, err := http.NewRequest("GET", "https://"+host, nil) + request, err := http.NewRequestWithContext(ctx, "GET", "https://"+host, nil) if err != nil { return } @@ -250,7 +243,6 @@ func realityClientFallback(ctx context.Context, uConn net.Conn, serverName strin func (e *RealityClientConfig) Clone() Config { return &RealityClientConfig{ - e.ctx, e.uClient.Clone().(*UTLSClientConfig), e.publicKey, e.shortID,