More performance optimized/random string generation, removed passkey length limit from the announcer (#1013)

This commit is contained in:
Cønstantine Kovalensky 2023-11-01 21:20:12 +04:00 committed by GitHub
commit 725773254f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 20 additions and 17 deletions

View file

@ -102,7 +102,7 @@ define('BB_BT_TRACKER', 'bb_bt_tracker');
define('BB_BT_TRACKER_SNAP', 'bb_bt_tracker_snap');
define('BB_BT_USERS', 'bb_bt_users');
define('BT_AUTH_KEY_LENGTH', 10);
define('BT_AUTH_KEY_LENGTH', 20);
define('DL_STATUS_RELEASER', -1);
define('DL_STATUS_DOWN', 0);
@ -297,9 +297,14 @@ function str_compact($str)
*/
function make_rand_str($length = 10): string
{
$pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$pool = str_shuffle('0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ');
return substr(str_shuffle(str_repeat($pool, (int)$length)), 0, $length);
$randomString = '';
for ($i = 0; $i < $length; $i++) {
$randomString .= $pool[random_int(0, 61)];
}
return $randomString;
}
function array_deep(&$var, $fn, $one_dimensional = false, $array_only = false)