@@ -49,7 +49,7 @@ func NewShadowTLS(ctx context.Context, conn net.Conn, option *ShadowTLSOption) (
4949 return nil , err
5050 }
5151
52- tlsHandshake := uTLSHandshakeFunc (tlsConfig , option .ClientFingerprint )
52+ tlsHandshake := uTLSHandshakeFunc (tlsConfig , option .ClientFingerprint , option . Version )
5353 client , err := shadowtls .NewClient (shadowtls.ClientConfig {
5454 Version : option .Version ,
5555 Password : option .Password ,
@@ -62,15 +62,19 @@ func NewShadowTLS(ctx context.Context, conn net.Conn, option *ShadowTLSOption) (
6262 return client .DialContextConn (ctx , conn )
6363}
6464
65- func uTLSHandshakeFunc (config * tls.Config , clientFingerprint string ) shadowtls.TLSHandshakeFunc {
65+ func uTLSHandshakeFunc (config * tls.Config , clientFingerprint string , version int ) shadowtls.TLSHandshakeFunc {
6666 return func (ctx context.Context , conn net.Conn , sessionIDGenerator shadowtls.TLSSessionIDGeneratorFunc ) error {
6767 tlsConfig := tlsC .UConfig (config )
6868 tlsConfig .SessionIDGenerator = sessionIDGenerator
69- if config .MaxVersion == tls .VersionTLS12 { // for ShadowTLS v1
69+ if version == 1 {
70+ tlsConfig .MaxVersion = tlsC .VersionTLS12 // ShadowTLS v1 only support TLS 1.2
7071 tlsConn := tlsC .Client (conn , tlsConfig )
7172 return tlsConn .HandshakeContext (ctx )
7273 }
7374 if clientFingerprint , ok := tlsC .GetFingerprint (clientFingerprint ); ok {
75+ if version == 2 && clientFingerprint == tlsC .HelloChrome_Auto {
76+ clientFingerprint = tlsC .HelloChrome_120 // ShadowTLS v2 not work with X25519MLKEM768
77+ }
7478 tlsConn := tlsC .UClient (conn , tlsConfig , clientFingerprint )
7579 if slices .Equal (tlsConfig .NextProtos , WsALPN ) {
7680 err := tlsC .BuildWebsocketHandshakeState (tlsConn )
0 commit comments