Skip to content

Commit 9087d6c

Browse files
committed
fix: compatibility issues between reality and the latest utls
1 parent 025ff19 commit 9087d6c

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

component/tls/reality.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
utls "github.com/metacubex/utls"
2727
"golang.org/x/crypto/chacha20poly1305"
2828
"golang.org/x/crypto/hkdf"
29+
"golang.org/x/exp/slices"
2930
"golang.org/x/net/http2"
3031
)
3132

@@ -60,6 +61,23 @@ func GetRealityConn(ctx context.Context, conn net.Conn, ClientFingerprint string
6061
return nil, err
6162
}
6263

64+
// ------for utls.HelloChrome_131 does not work properly with reality-------
65+
// Iterate over extensions and check for utls.SupportedCurvesExtension
66+
for _, extension := range uConn.Extensions {
67+
if ce, ok := extension.(*utls.SupportedCurvesExtension); ok {
68+
ce.Curves = slices.DeleteFunc(ce.Curves, func(curveID utls.CurveID) bool {
69+
return curveID == utls.X25519MLKEM768 // X25519MLKEM768 does not work properly with reality
70+
})
71+
break
72+
}
73+
}
74+
// Rebuild the client hello
75+
err = uConn.BuildHandshakeState()
76+
if err != nil {
77+
return nil, err
78+
}
79+
// -------------------------------------------------------------------------
80+
6381
hello := uConn.HandshakeState.Hello
6482
rawSessionID := hello.Raw[39 : 39+32] // the location of session ID
6583
for i := range rawSessionID { // https://github.com/golang/go/issues/5373

0 commit comments

Comments
 (0)