fix: check default credentials during a fresh installation
Some checks are pending
Build and Release 3X-UI / build (386) (push) Waiting to run
Build and Release 3X-UI / build (amd64) (push) Waiting to run
Build and Release 3X-UI / build (arm64) (push) Waiting to run
Build and Release 3X-UI / build (armv5) (push) Waiting to run
Build and Release 3X-UI / build (armv6) (push) Waiting to run
Build and Release 3X-UI / build (armv7) (push) Waiting to run
Build and Release 3X-UI / build (s390x) (push) Waiting to run

This commit is contained in:
Shishkevich D. 2025-05-06 09:05:32 +07:00 committed by GitHub
parent 63edc63ab0
commit 13cf7271d6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 16 additions and 12 deletions

View file

@ -33,7 +33,7 @@
لتثبيت المشروع أو تحديثه، نفذ الأمر ده: لتثبيت المشروع أو تحديثه، نفذ الأمر ده:
```bash ```bash
bash <(curl -Ls https://raw.githubusercontent.com/mhsanaei/3x-ui/master/install.sh) bash <(curl -Ls https://raw.githubusercontent.com/MHSanaei/3x-ui/refs/tags/v2.5.8/install.sh)
``` ```
## تثبيت النسخة القديمة (مش موصى بيها) ## تثبيت النسخة القديمة (مش موصى بيها)

View file

@ -32,7 +32,7 @@
## Instalar y Actualizar ## Instalar y Actualizar
``` ```
bash <(curl -Ls https://raw.githubusercontent.com/mhsanaei/3x-ui/master/install.sh) bash <(curl -Ls https://raw.githubusercontent.com/MHSanaei/3x-ui/refs/tags/v2.5.8/install.sh)
``` ```
## Instalar versión antigua (no recomendamos) ## Instalar versión antigua (no recomendamos)

View file

@ -32,7 +32,7 @@
## نصب و ارتقا ## نصب و ارتقا
``` ```
bash <(curl -Ls https://raw.githubusercontent.com/mhsanaei/3x-ui/master/install.sh) bash <(curl -Ls https://raw.githubusercontent.com/MHSanaei/3x-ui/refs/tags/v2.5.8/install.sh)
``` ```
## نصب نسخه‌های قدیمی (توصیه نمی‌شود) ## نصب نسخه‌های قدیمی (توصیه نمی‌شود)

View file

@ -32,7 +32,7 @@
## Install & Upgrade ## Install & Upgrade
``` ```
bash <(curl -Ls https://raw.githubusercontent.com/mhsanaei/3x-ui/master/install.sh) bash <(curl -Ls https://raw.githubusercontent.com/MHSanaei/3x-ui/refs/tags/v2.5.8/install.sh)
``` ```
## Install legacy Version (we don't recommend) ## Install legacy Version (we don't recommend)

View file

@ -32,7 +32,7 @@
## Установка и обновление ## Установка и обновление
``` ```
bash <(curl -Ls https://raw.githubusercontent.com/mhsanaei/3x-ui/master/install.sh) bash <(curl -Ls https://raw.githubusercontent.com/MHSanaei/3x-ui/refs/tags/v2.5.8/install.sh)
``` ```
## Установить старую версию (мы не рекомендуем) ## Установить старую версию (мы не рекомендуем)

View file

@ -32,7 +32,7 @@
## 安装 & 升级 ## 安装 & 升级
``` ```
bash <(curl -Ls https://raw.githubusercontent.com/mhsanaei/3x-ui/master/install.sh) bash <(curl -Ls https://raw.githubusercontent.com/MHSanaei/3x-ui/refs/tags/v2.5.8/install.sh)
``` ```
## 安装旧版本 (我们不建议) ## 安装旧版本 (我们不建议)

View file

@ -82,14 +82,13 @@ gen_random_string() {
} }
config_after_install() { config_after_install() {
local existing_username=$(/usr/local/x-ui/x-ui setting -show true | grep -Eo 'username: .+' | awk '{print $2}') local existing_hasDefaultCredential=$(/usr/local/x-ui/x-ui setting -show true | grep -Eo 'hasDefaultCredential: .+' | awk '{print $2}')
local existing_password=$(/usr/local/x-ui/x-ui setting -show true | grep -Eo 'password: .+' | awk '{print $2}')
local existing_webBasePath=$(/usr/local/x-ui/x-ui setting -show true | grep -Eo 'webBasePath: .+' | awk '{print $2}') local existing_webBasePath=$(/usr/local/x-ui/x-ui setting -show true | grep -Eo 'webBasePath: .+' | awk '{print $2}')
local existing_port=$(/usr/local/x-ui/x-ui setting -show true | grep -Eo 'port: .+' | awk '{print $2}') local existing_port=$(/usr/local/x-ui/x-ui setting -show true | grep -Eo 'port: .+' | awk '{print $2}')
local server_ip=$(curl -s https://api.ipify.org) local server_ip=$(curl -s https://api.ipify.org)
if [[ ${#existing_webBasePath} -lt 4 ]]; then if [[ ${#existing_webBasePath} -lt 4 ]]; then
if [[ "$existing_username" == "admin" && "$existing_password" == "admin" ]]; then if [[ "$existing_hasDefaultCredential" == "true" ]]; then
local config_webBasePath=$(gen_random_string 15) local config_webBasePath=$(gen_random_string 15)
local config_username=$(gen_random_string 10) local config_username=$(gen_random_string 10)
local config_password=$(gen_random_string 10) local config_password=$(gen_random_string 10)
@ -112,7 +111,6 @@ config_after_install() {
echo -e "${green}WebBasePath: ${config_webBasePath}${plain}" echo -e "${green}WebBasePath: ${config_webBasePath}${plain}"
echo -e "${green}Access URL: http://${server_ip}:${config_port}/${config_webBasePath}${plain}" echo -e "${green}Access URL: http://${server_ip}:${config_port}/${config_webBasePath}${plain}"
echo -e "###############################################" echo -e "###############################################"
echo -e "${yellow}If you forgot your login info, you can type 'x-ui settings' to check${plain}"
else else
local config_webBasePath=$(gen_random_string 15) local config_webBasePath=$(gen_random_string 15)
echo -e "${yellow}WebBasePath is missing or too short. Generating a new one...${plain}" echo -e "${yellow}WebBasePath is missing or too short. Generating a new one...${plain}"
@ -121,7 +119,7 @@ config_after_install() {
echo -e "${green}Access URL: http://${server_ip}:${existing_port}/${config_webBasePath}${plain}" echo -e "${green}Access URL: http://${server_ip}:${existing_port}/${config_webBasePath}${plain}"
fi fi
else else
if [[ "$existing_username" == "admin" && "$existing_password" == "admin" ]]; then if [[ "$existing_hasDefaultCredential" == "true" ]]; then
local config_username=$(gen_random_string 10) local config_username=$(gen_random_string 10)
local config_password=$(gen_random_string 10) local config_password=$(gen_random_string 10)
@ -132,7 +130,6 @@ config_after_install() {
echo -e "${green}Username: ${config_username}${plain}" echo -e "${green}Username: ${config_username}${plain}"
echo -e "${green}Password: ${config_password}${plain}" echo -e "${green}Password: ${config_password}${plain}"
echo -e "###############################################" echo -e "###############################################"
echo -e "${yellow}If you forgot your login info, you can type 'x-ui settings' to check${plain}"
else else
echo -e "${green}Username, Password, and WebBasePath are properly set. Exiting...${plain}" echo -e "${green}Username, Password, and WebBasePath are properly set. Exiting...${plain}"
fi fi

View file

@ -16,6 +16,7 @@ import (
"x-ui/web" "x-ui/web"
"x-ui/web/global" "x-ui/web/global"
"x-ui/web/service" "x-ui/web/service"
"x-ui/util/crypto"
"github.com/op/go-logging" "github.com/op/go-logging"
) )
@ -161,6 +162,12 @@ func showSetting(show bool) {
} else { } else {
fmt.Println("Panel is secure with SSL") fmt.Println("Panel is secure with SSL")
} }
hasDefaultCredential := func() bool {
return userModel.Username == "admin" && crypto.CheckPasswordHash(userModel.Password, "admin")
}()
fmt.Println("hasDefaultCredential:", hasDefaultCredential)
fmt.Println("port:", port) fmt.Println("port:", port)
fmt.Println("webBasePath:", webBasePath) fmt.Println("webBasePath:", webBasePath)
} }