Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/MHSanaei/3x-ui.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--install.sh8
-rw-r--r--x-ui.sh103
2 files changed, 73 insertions, 38 deletions
diff --git a/install.sh b/install.sh
index 894171d1..c603878c 100644
--- a/install.sh
+++ b/install.sh
@@ -121,6 +121,12 @@ install_base() {
esac
}
+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"
+}
+
# This function will be called when user installed x-ui out of security
config_after_install() {
echo -e "${yellow}Install/update finished! For security it's recommended to modify panel settings ${plain}"
@@ -146,7 +152,7 @@ config_after_install() {
if [[ ! -f "/etc/x-ui/x-ui.db" ]]; then
local usernameTemp=$(head -c 6 /dev/urandom | base64)
local passwordTemp=$(head -c 6 /dev/urandom | base64)
- local webBasePathTemp=$(head -c 6 /dev/urandom | base64)
+ local webBasePathTemp=$(gen_random_string 10)
/usr/local/x-ui/x-ui setting -username ${usernameTemp} -password ${passwordTemp} -webBasePath ${webBasePathTemp}
echo -e "This is a fresh installation, will generate random login info for security concerns:"
echo -e "###############################################"
diff --git a/x-ui.sh b/x-ui.sh
index 770149d9..c72d7be3 100644
--- a/x-ui.sh
+++ b/x-ui.sh
@@ -228,6 +228,31 @@ reset_user() {
confirm_restart
}
+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"
+}
+
+reset_webbasepath() {
+ echo -e "${yellow}Resetting Web Base Path${plain}"
+
+ # Prompt user to set a new web base path
+ read -rp "Please set the new web base path [default is a random path]: " config_webBasePath
+
+ # If user input is empty, generate a random path
+ if [[ -z $config_webBasePath ]]; then
+ config_webBasePath=$(gen_random_string 10)
+ fi
+
+ # Apply the new web base path setting
+ /usr/local/x-ui/x-ui setting -webBasePath "${config_webBasePath}" >/dev/null 2>&1
+
+ # Display confirmation message
+ echo -e "Web base path has been reset to: ${green} ${config_webBasePath} ${plain}"
+ echo -e "${green} Please use the new web base path to access the panel. ${plain}"
+}
+
reset_config() {
confirm "Are you sure you want to reset all panel settings, Account data will not be lost, Username and password will not change" "n"
if [[ $? != 0 ]]; then
@@ -1282,31 +1307,32 @@ show_menu() {
${green}4.${plain} Uninstall
————————————————
${green}5.${plain} Reset Username & Password & Secret Token
- ${green}6.${plain} Reset Settings
- ${green}7.${plain} Change Port
- ${green}8.${plain} View Current Settings
+ ${green}6.${plain} Reset Web Base Path
+ ${green}7.${plain} Reset Settings
+ ${green}8.${plain} Change Port
+ ${green}9.${plain} View Current Settings
————————————————
- ${green}9.${plain} Start
- ${green}10.${plain} Stop
- ${green}11.${plain} Restart
- ${green}12.${plain} Check Status
- ${green}13.${plain} Check Logs
+ ${green}10.${plain} Start
+ ${green}11.${plain} Stop
+ ${green}12.${plain} Restart
+ ${green}13.${plain} Check Status
+ ${green}14.${plain} Check Logs
————————————————
- ${green}14.${plain} Enable Autostart
- ${green}15.${plain} Disable Autostart
+ ${green}15.${plain} Enable Autostart
+ ${green}16.${plain} Disable Autostart
————————————————
- ${green}16.${plain} SSL Certificate Management
- ${green}17.${plain} Cloudflare SSL Certificate
- ${green}18.${plain} IP Limit Management
- ${green}19.${plain} WARP Management
- ${green}20.${plain} Firewall Management
+ ${green}17.${plain} SSL Certificate Management
+ ${green}18.${plain} Cloudflare SSL Certificate
+ ${green}19.${plain} IP Limit Management
+ ${green}20.${plain} WARP Management
+ ${green}21.${plain} Firewall Management
————————————————
- ${green}21.${plain} Enable BBR
- ${green}22.${plain} Update Geo Files
- ${green}23.${plain} Speedtest by Ookla
+ ${green}22.${plain} Enable BBR
+ ${green}23.${plain} Update Geo Files
+ ${green}24.${plain} Speedtest by Ookla
"
show_status
- echo && read -p "Please enter your selection [0-23]: " num
+ echo && read -p "Please enter your selection [0-24]: " num
case "${num}" in
0)
@@ -1328,61 +1354,64 @@ show_menu() {
check_install && reset_user
;;
6)
- check_install && reset_config
+ check_install && reset_webbasepath
;;
7)
- check_install && set_port
+ check_install && reset_config
;;
8)
- check_install && check_config
+ check_install && set_port
;;
9)
- check_install && start
+ check_install && check_config
;;
10)
- check_install && stop
+ check_install && start
;;
11)
- check_install && restart
+ check_install && stop
;;
12)
- check_install && status
+ check_install && restart
;;
13)
- check_install && show_log
+ check_install && status
;;
14)
- check_install && enable
+ check_install && show_log
;;
15)
- check_install && disable
+ check_install && enable
;;
16)
- ssl_cert_issue_main
+ check_install && disable
;;
17)
- ssl_cert_issue_CF
+ ssl_cert_issue_main
;;
18)
- iplimit_main
+ ssl_cert_issue_CF
;;
19)
- warp_cloudflare
+ iplimit_main
;;
20)
- firewall_menu
+ warp_cloudflare
;;
21)
- bbr_menu
+ firewall_menu
;;
22)
- update_geo
+ bbr_menu
;;
23)
+ update_geo
+ ;;
+ 24)
run_speedtest
;;
*)
- LOGE "Please enter the correct number [0-23]"
+ LOGE "Please enter the correct number [0-24]"
;;
esac
}