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,10 +105,12 @@ install_base() {
|
||||||
|
|
||||||
gen_random_string() {
|
gen_random_string() {
|
||||||
local length="$1"
|
local length="$1"
|
||||||
local random_string=$(LC_ALL=C tr -dc 'a-zA-Z0-9' </dev/urandom | fold -w "$length" | head -n 1)
|
# openssl output base64,no need /dev/urandom + tr
|
||||||
echo "$random_string"
|
openssl rand -base64 $(( length * 2 )) \
|
||||||
|
| tr -dc 'a-zA-Z0-9' \
|
||||||
|
| head -c "$length"
|
||||||
}
|
}
|
||||||
|
|
||||||
install_acme() {
|
install_acme() {
|
||||||
echo -e "${green}Installing acme.sh for SSL certificate management...${plain}"
|
echo -e "${green}Installing acme.sh for SSL certificate management...${plain}"
|
||||||
cd ~ || return 1
|
cd ~ || return 1
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue