Add uTLS support for shadowtls

This commit is contained in:
世界 2023-02-21 20:42:44 +08:00
parent 6fb673aee4
commit 0188c2d67d
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
10 changed files with 55 additions and 31 deletions

View file

@ -24,7 +24,7 @@ import (
"time"
"unsafe"
utls "github.com/refraction-networking/utls"
utls "github.com/sagernet/utls"
"github.com/xtls/reality"
"github.com/xtls/xray-core/common/errors"
"github.com/xtls/xray-core/common/net"

View file

@ -25,7 +25,7 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me
tlsConfig := config.GetTLSConfig(tls.WithDestination(dest))
customClient, loaded := tls.CustomClientFromContext(ctx)
if loaded {
conn = customClient(conn, tlsConfig)
conn = customClient(conn, config, tlsConfig)
} else {
if fingerprint := tls.GetFingerprint(config.Fingerprint); fingerprint != nil {
conn = tls.UClient(conn, tlsConfig, fingerprint)

View file

@ -9,7 +9,7 @@ import (
type customClientKey struct{}
type CustomClientFunc func(conn net.Conn, config *tls.Config) net.Conn
type CustomClientFunc func(conn net.Conn, xrayConfig *Config, config *tls.Config) net.Conn
func CustomClientFromContext(ctx context.Context) (CustomClientFunc, bool) {
client, loaded := ctx.Value(customClientKey{}).(CustomClientFunc)

View file

@ -7,7 +7,7 @@ import (
"net/url"
"strconv"
utls "github.com/refraction-networking/utls"
utls "github.com/sagernet/utls"
"google.golang.org/grpc/credentials"
)

View file

@ -5,7 +5,7 @@ import (
"crypto/tls"
"math/big"
utls "github.com/refraction-networking/utls"
utls "github.com/sagernet/utls"
"github.com/xtls/xray-core/common/buf"
"github.com/xtls/xray-core/common/net"
)