@@ -21,8 +21,10 @@ func MakeSession(connConfig RemoteConnConfig, authInfo AuthInfo, dialer common.D
2121 var wg sync.WaitGroup
2222 for i := 0 ; i < connConfig .NumConn ; i ++ {
2323 wg .Add (1 )
24+ transportConfig := connConfig .Transport
2425 go func () {
2526 makeconn:
27+ transportConn := transportConfig .CreateTransport ()
2628 remoteConn , err := dialer .Dial ("tcp" , connConfig .RemoteAddr )
2729 if err != nil {
2830 log .Errorf ("Failed to establish new connections to remote: %v" , err )
@@ -31,12 +33,20 @@ func MakeSession(connConfig RemoteConnConfig, authInfo AuthInfo, dialer common.D
3133 goto makeconn
3234 }
3335
34- transportConn := connConfig .TransportMaker ()
3536 sk , err := transportConn .Handshake (remoteConn , authInfo )
3637 if err != nil {
3738 log .Errorf ("Failed to prepare connection to remote: %v" , err )
3839 transportConn .Close ()
40+
41+ // In Cloak v2.11.0, we've updated uTLS version and subsequently increased the first packet size for chrome above 1500
42+ // https://github.com/cbeuw/Cloak/pull/306#issuecomment-2862728738. As a backwards compatibility feature, if we fail
43+ // to connect using chrome signature, retry with firefox which has a smaller packet size.
44+ if transportConfig .mode == "direct" && transportConfig .browser == chrome {
45+ transportConfig .browser = firefox
46+ log .Warnf ("failed to connect with chrome signature, falling back to retry with firefox" )
47+ }
3948 time .Sleep (time .Second * 3 )
49+
4050 goto makeconn
4151 }
4252 // sessionKey given by each connection should be identical
0 commit comments