mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-04-16 04:25:46 +00:00
Replace random string generation method with OpenSSL for better randomness in install.sh
The previous implementation using cat /dev/urandom | tr caused tr to hang and consume 100% CPU on certain environments (e.g., GCP, specific kernels) due to delayed SIGPIPE handling. Using openssl provides a finite, cryptographically secure string that eliminates this CPU spike and is noticeably faster."
This commit is contained in:
parent
a2097ad062
commit
b01a71f32d
1 changed files with 5 additions and 3 deletions
|
|
@ -105,8 +105,10 @@ install_base() {
|
|||
|
||||
gen_random_string() {
|
||||
local length="$1"
|
||||
local random_string=$(LC_ALL=C tr -dc 'a-zA-Z0-9' </dev/urandom | fold -w "$length" | head -n 1)
|
||||
echo "$random_string"
|
||||
# openssl output base64,no need /dev/urandom + tr
|
||||
openssl rand -base64 $(( length * 2 )) \
|
||||
| tr -dc 'a-zA-Z0-9' \
|
||||
| head -c "$length"
|
||||
}
|
||||
|
||||
install_acme() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue