From e13015a9202be83c79e125fb4c6d9cfed7441272 Mon Sep 17 00:00:00 2001 From: Hamidreza Ghavami Date: Tue, 18 Apr 2023 10:16:10 +0430 Subject: update release.yml --- .github/workflows/release.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 083180ff..39bd9aaa 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,7 +14,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v4.0.0 with: - go-version: 'stable' + go-version: "stable" - name: build linux amd64 version run: | CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -o xui-release -v main.go @@ -28,7 +28,7 @@ jobs: cd bin wget https://github.com/mhsanaei/Xray-core/releases/latest/download/Xray-linux-64.zip unzip Xray-linux-64.zip - rm -f Xray-linux-64.zip geoip.dat geosite.dat + rm -f Xray-linux-64.zip geoip.dat geosite.dat iran.dat wget https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geoip.dat wget https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat wget https://github.com/bootmortis/iran-hosted-domains/releases/latest/download/iran.dat @@ -54,7 +54,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v4.0.0 with: - go-version: 'stable' + go-version: "stable" - name: build linux arm64 version run: | sudo apt-get update @@ -70,7 +70,7 @@ jobs: cd bin wget https://github.com/mhsanaei/xray-core/releases/latest/download/Xray-linux-arm64-v8a.zip unzip Xray-linux-arm64-v8a.zip - rm -f Xray-linux-arm64-v8a.zip geoip.dat geosite.dat + rm -f Xray-linux-arm64-v8a.zip geoip.dat geosite.dat iran.dat wget https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geoip.dat wget https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat wget https://github.com/bootmortis/iran-hosted-domains/releases/latest/download/iran.dat -- cgit v1.2.3 From 40a029749929bcd53ff9b5a7776cda96dc3aed86 Mon Sep 17 00:00:00 2001 From: Hamidreza Ghavami Date: Tue, 18 Apr 2023 10:16:43 +0430 Subject: update .gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 7136428c..7ba03558 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .idea tmp +backup/ bin/ dist/ x-ui-*.tar.gz @@ -9,4 +10,5 @@ x-ui-*.tar.gz main release/ access.log +error.log .cache -- cgit v1.2.3 From 3e5984930ed24261c1cc459d11909a053dce18f3 Mon Sep 17 00:00:00 2001 From: Hamidreza Ghavami Date: Tue, 18 Apr 2023 10:21:21 +0430 Subject: update x-ui.sh --- x-ui.sh | 211 ++++++++++++++++++++++++++++++++-------------------------------- 1 file changed, 107 insertions(+), 104 deletions(-) diff --git a/x-ui.sh b/x-ui.sh index 8f1fcd60..6df37f6f 100644 --- a/x-ui.sh +++ b/x-ui.sh @@ -17,6 +17,7 @@ function LOGE() { function LOGI() { echo -e "${green}[INF] $* ${plain}" } + # check root [[ $EUID -ne 0 ]] && LOGE "ERROR: You must be root to run this script! \n" && exit 1 @@ -34,7 +35,6 @@ fi echo "The OS release is: $release" - os_version="" os_version=$(grep -i version_id /etc/os-release | cut -d \" -f2 | cut -d . -f1) @@ -44,21 +44,18 @@ if [[ "${release}" == "centos" ]]; then fi elif [[ "${release}" == "ubuntu" ]]; then if [[ ${os_version} -lt 20 ]]; then - echo -e "${red}please use Ubuntu 20 or higher version!${plain}\n" && exit 1 + echo -e "${red}please use Ubuntu 20 or higher version! ${plain}\n" && exit 1 fi - elif [[ "${release}" == "fedora" ]]; then if [[ ${os_version} -lt 36 ]]; then - echo -e "${red}please use Fedora 36 or higher version!${plain}\n" && exit 1 + echo -e "${red}please use Fedora 36 or higher version! ${plain}\n" && exit 1 fi - elif [[ "${release}" == "debian" ]]; then if [[ ${os_version} -lt 10 ]]; then echo -e "${red} Please use Debian 10 or higher ${plain}\n" && exit 1 fi fi - confirm() { if [[ $# > 1 ]]; then echo && read -p "$1 [Default$2]: " temp @@ -133,7 +130,7 @@ uninstall() { rm /usr/local/x-ui/ -rf echo "" - echo -e "Uninstalled Successfully,If you want to remove this script,then after exiting the script run ${green}rm /usr/bin/x-ui -f${plain} to delete it." + echo -e "Uninstalled Successfully, If you want to remove this script, then after exiting the script run ${green}rm /usr/bin/x-ui -f${plain} to delete it." echo "" if [[ $# == 0 ]]; then @@ -150,12 +147,12 @@ reset_user() { return 0 fi /usr/local/x-ui/x-ui setting -username admin -password admin - echo -e "Username and password have been reset to ${green}admin${plain},Please restart the panel now." + echo -e "Username and password have been reset to ${green}admin${plain}, Please restart the panel now." confirm_restart } 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" + 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 if [[ $# == 0 ]]; then show_menu @@ -163,14 +160,14 @@ reset_config() { return 0 fi /usr/local/x-ui/x-ui setting -reset - echo -e "All panel settings have been reset to default,Please restart the panel now,and use the default ${green}2053${plain} Port to Access the web Panel" + echo -e "All panel settings have been reset to default, Please restart the panel now, and use the default ${green}2053${plain} Port to Access the web Panel" confirm_restart } check_config() { info=$(/usr/local/x-ui/x-ui setting -show true) if [[ $? != 0 ]]; then - LOGE "get current settings error,please check logs" + LOGE "get current settings error, please check logs" show_menu fi LOGI "${info}" @@ -183,7 +180,7 @@ set_port() { before_show_menu else /usr/local/x-ui/x-ui setting -port ${port} - echo -e "The port is set,Please restart the panel now,and use the new port ${green}${port}${plain} to access web panel" + echo -e "The port is set, Please restart the panel now, and use the new port ${green}${port}${plain} to access web panel" confirm_restart fi } @@ -192,7 +189,7 @@ start() { check_status if [[ $? == 0 ]]; then echo "" - LOGI "Panel is running,No need to start again,If you need to restart, please select restart" + LOGI "Panel is running, No need to start again, If you need to restart, please select restart" else systemctl start x-ui sleep 2 @@ -200,7 +197,7 @@ start() { if [[ $? == 0 ]]; then LOGI "x-ui Started Successfully" else - LOGE "panel Failed to start,Probably because it takes longer than two seconds to start,Please check the log information later" + LOGE "panel Failed to start, Probably because it takes longer than two seconds to start, Please check the log information later" fi fi @@ -213,7 +210,7 @@ stop() { check_status if [[ $? == 1 ]]; then echo "" - LOGI "Panel stopped,No need to stop again!" + LOGI "Panel stopped, No need to stop again!" else systemctl stop x-ui sleep 2 @@ -221,7 +218,7 @@ stop() { if [[ $? == 1 ]]; then LOGI "x-ui and xray stopped successfully" else - LOGE "Panel stop failed,Probably because the stop time exceeds two seconds,Please check the log information later" + LOGE "Panel stop failed, Probably because the stop time exceeds two seconds, Please check the log information later" fi fi @@ -237,7 +234,7 @@ restart() { if [[ $? == 0 ]]; then LOGI "x-ui and xray Restarted successfully" else - LOGE "Panel restart failed,Probably because it takes longer than two seconds to start,Please check the log information later" + LOGE "Panel restart failed, Probably because it takes longer than two seconds to start, Please check the log information later" fi if [[ $# == 0 ]]; then before_show_menu @@ -285,51 +282,49 @@ show_log() { } enable_bbr() { + if grep -q "net.core.default_qdisc=fq" /etc/sysctl.conf && grep -q "net.ipv4.tcp_congestion_control=bbr" /etc/sysctl.conf; then + echo -e "${green}BBR is already enabled!${plain}" + exit 0 + fi -if grep -q "net.core.default_qdisc=fq" /etc/sysctl.conf && grep -q "net.ipv4.tcp_congestion_control=bbr" /etc/sysctl.conf; then - echo -e "${green}BBR is already enabled!${plain}" - exit 0 -fi - -# Check the OS and install necessary packages -if [[ "$(cat /etc/os-release | grep -E '^ID=' | awk -F '=' '{print $2}')" == "ubuntu" ]]; then - sudo apt-get update && sudo apt-get install -yqq --no-install-recommends ca-certificates -elif [[ "$(cat /etc/os-release | grep -E '^ID=' | awk -F '=' '{print $2}')" == "debian" ]]; then - sudo apt-get update && sudo apt-get install -yqq --no-install-recommends ca-certificates -elif [[ "$(cat /etc/os-release | grep -E '^ID=' | awk -F '=' '{print $2}')" == "fedora" ]]; then - sudo dnf -y update && sudo dnf -y install ca-certificates -elif [[ "$(cat /etc/os-release | grep -E '^ID=' | awk -F '=' '{print $2}')" == "centos" ]]; then - sudo yum -y update && sudo yum -y install ca-certificates -else - echo "Unsupported operating system. Please check the script and install the necessary packages manually." - exit 1 -fi - -# Enable BBR -echo "net.core.default_qdisc=fq" | sudo tee -a /etc/sysctl.conf -echo "net.ipv4.tcp_congestion_control=bbr" | sudo tee -a /etc/sysctl.conf + # Check the OS and install necessary packages + if [[ "$(cat /etc/os-release | grep -E '^ID=' | awk -F '=' '{print $2}')" == "ubuntu" ]]; then + sudo apt-get update && sudo apt-get install -yqq --no-install-recommends ca-certificates + elif [[ "$(cat /etc/os-release | grep -E '^ID=' | awk -F '=' '{print $2}')" == "debian" ]]; then + sudo apt-get update && sudo apt-get install -yqq --no-install-recommends ca-certificates + elif [[ "$(cat /etc/os-release | grep -E '^ID=' | awk -F '=' '{print $2}')" == "fedora" ]]; then + sudo dnf -y update && sudo dnf -y install ca-certificates + elif [[ "$(cat /etc/os-release | grep -E '^ID=' | awk -F '=' '{print $2}')" == "centos" ]]; then + sudo yum -y update && sudo yum -y install ca-certificates + else + echo "Unsupported operating system. Please check the script and install the necessary packages manually." + exit 1 + fi -# Apply changes -sudo sysctl -p + # Enable BBR + echo "net.core.default_qdisc=fq" | sudo tee -a /etc/sysctl.conf + echo "net.ipv4.tcp_congestion_control=bbr" | sudo tee -a /etc/sysctl.conf -# Verify that BBR is enabled -if [[ $(sysctl net.ipv4.tcp_congestion_control | awk '{print $3}') == "bbr" ]]; then - echo -e "${green}BBR has been enabled successfully.${plain}" -else - echo -e "${red}Failed to enable BBR. Please check your system configuration.${plain}" -fi + # Apply changes + sudo sysctl -p + # Verify that BBR is enabled + if [[ $(sysctl net.ipv4.tcp_congestion_control | awk '{print $3}') == "bbr" ]]; then + echo -e "${green}BBR has been enabled successfully.${plain}" + else + echo -e "${red}Failed to enable BBR. Please check your system configuration.${plain}" + fi } update_shell() { wget -O /usr/bin/x-ui -N --no-check-certificate https://github.com/MHSanaei/3x-ui/raw/main/x-ui.sh if [[ $? != 0 ]]; then echo "" - LOGE "Failed to download script,Please check whether the machine can connect Github" + LOGE "Failed to download script, Please check whether the machine can connect Github" before_show_menu else chmod +x /usr/bin/x-ui - LOGI "Upgrade script succeeded,Please rerun the script" && exit 0 + LOGI "Upgrade script succeeded, Please rerun the script" && exit 0 fi } @@ -359,7 +354,7 @@ check_uninstall() { check_status if [[ $? != 2 ]]; then echo "" - LOGE "Panel installed,Please do not reinstall" + LOGE "Panel installed, Please do not reinstall" if [[ $# == 0 ]]; then before_show_menu fi @@ -455,69 +450,76 @@ ssl_cert_issue() { } open_ports() { -if ! command -v ufw &> /dev/null -then - echo "ufw firewall is not installed. Installing now..." - sudo apt-get update - sudo apt-get install -y ufw -else - echo "ufw firewall is already installed" -fi - - # Check if the firewall is inactive - if sudo ufw status | grep -q "Status: active"; then - echo "firewall is already active" - else - # Open the necessary ports - sudo ufw allow ssh - sudo ufw allow http - sudo ufw allow https - sudo ufw allow 2053/tcp - - # Enable the firewall - sudo ufw --force enable - fi - - # Prompt the user to enter a list of ports - read -p "Enter the ports you want to open (e.g. 80,443,2053 or range 400-500): " ports - - # Check if the input is valid - if ! [[ $ports =~ ^([0-9]+|[0-9]+-[0-9]+)(,([0-9]+|[0-9]+-[0-9]+))*$ ]]; then - echo "Error: Invalid input. Please enter a comma-separated list of ports or a range of ports (e.g. 80,443,2053 or 400-500)." >&2; exit 1 - fi - - # Open the specified ports using ufw - IFS=',' read -ra PORT_LIST <<< "$ports" - for port in "${PORT_LIST[@]}"; do - if [[ $port == *-* ]]; then - # Split the range into start and end ports - start_port=$(echo $port | cut -d'-' -f1) - end_port=$(echo $port | cut -d'-' -f2) - # Loop through the range and open each port - for ((i=start_port; i<=end_port; i++)); do - sudo ufw allow $i - done + if ! command -v ufw &> /dev/null + then + echo "ufw firewall is not installed. Installing now..." + sudo apt-get update + sudo apt-get install -y ufw else - sudo ufw allow "$port" + echo "ufw firewall is already installed" fi - done - # Confirm that the ports are open - sudo ufw status | grep $ports -} + # Check if the firewall is inactive + if sudo ufw status | grep -q "Status: active"; then + echo "firewall is already active" + else + # Open the necessary ports + sudo ufw allow ssh + sudo ufw allow http + sudo ufw allow https + sudo ufw allow 2053/tcp + + # Enable the firewall + sudo ufw --force enable + fi + + # Prompt the user to enter a list of ports + read -p "Enter the ports you want to open (e.g. 80,443,2053 or range 400-500): " ports + + # Check if the input is valid + if ! [[ $ports =~ ^([0-9]+|[0-9]+-[0-9]+)(,([0-9]+|[0-9]+-[0-9]+))*$ ]]; then + echo "Error: Invalid input. Please enter a comma-separated list of ports or a range of ports (e.g. 80,443,2053 or 400-500)." >&2; exit 1 + fi + + # Open the specified ports using ufw + IFS=',' read -ra PORT_LIST <<< "$ports" + for port in "${PORT_LIST[@]}"; do + if [[ $port == *-* ]]; then + # Split the range into start and end ports + start_port=$(echo $port | cut -d'-' -f1) + end_port=$(echo $port | cut -d'-' -f2) + # Loop through the range and open each port + for ((i=start_port; i<=end_port; i++)); do + sudo ufw allow $i + done + else + sudo ufw allow "$port" + fi + done + # Confirm that the ports are open + sudo ufw status | grep $ports +} +update_geo() { + local defaultBinFolder="/usr/local/x-ui/bin" + read -p "Please enter x-ui bin folder path. Leave blank for default. (Default: '${defaultBinFolder}')" binFolder + binFolder=${binFolder:-${defaultBinFolder}} + if [[ ! -d ${binFolder} ]]; then + LOGE "Folder ${binFolder} not exists!" + LOGI "making bin folder: ${binFolder}..." + mkdir -p ${binFolder} + fi -update_geo(){ systemctl stop x-ui - cd /usr/local/x-ui/bin + cd ${binFolder} rm -f geoip.dat geosite.dat iran.dat wget -N https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geoip.dat wget -N https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat wget -N https://github.com/bootmortis/iran-hosted-domains/releases/latest/download/iran.dat systemctl start x-ui - echo -e "${green}Geosite and Geoip have been updated successfully!${plain}" -before_show_menu + echo -e "${green}Geosite.dat + Geoip.dat + Iran.dat have been updated successfully in bin folder '${binfolder}'!${plain}" + before_show_menu } install_acme() { @@ -714,10 +716,11 @@ ssl_cert_issue_by_cloudflare() { show_menu fi } + google_recaptcha() { - curl -O https://raw.githubusercontent.com/jinwyp/one_click_script/master/install_kernel.sh && chmod +x ./install_kernel.sh && ./install_kernel.sh - echo "" - before_show_menu + curl -O https://raw.githubusercontent.com/jinwyp/one_click_script/master/install_kernel.sh && chmod +x ./install_kernel.sh && ./install_kernel.sh + echo "" + before_show_menu } run_speedtest() { -- cgit v1.2.3 From 936f2e6ec2c0380ce3c1b8cd93835383741f5452 Mon Sep 17 00:00:00 2001 From: Hamidreza Ghavami Date: Tue, 18 Apr 2023 10:22:04 +0430 Subject: update config.json --- web/service/config.json | 45 ++++++++++++++++++--------------------------- 1 file changed, 18 insertions(+), 27 deletions(-) diff --git a/web/service/config.json b/web/service/config.json index 34e2038f..9d8d2d9f 100644 --- a/web/service/config.json +++ b/web/service/config.json @@ -1,25 +1,22 @@ { "log": { "loglevel": "warning", - "access": "./access.log" + "access": "./access.log", + "error": "./error.log" }, "api": { - "services": [ - "HandlerService", - "LoggerService", - "StatsService" - ], - "tag": "api" + "tag": "api", + "services": ["HandlerService", "LoggerService", "StatsService"] }, "inbounds": [ { + "tag": "api", "listen": "127.0.0.1", "port": 62789, "protocol": "dokodemo-door", "settings": { "address": "127.0.0.1" - }, - "tag": "api" + } } ], "outbounds": [ @@ -28,16 +25,16 @@ "settings": {} }, { + "tag": "blocked", "protocol": "blackhole", - "settings": {}, - "tag": "blocked" + "settings": {} } ], "policy": { "levels": { "0": { - "statsUserUplink": true, - "statsUserDownlink": true + "statsUserDownlink": true, + "statsUserUplink": true } }, "system": { @@ -49,27 +46,21 @@ "domainStrategy": "IPIfNonMatch", "rules": [ { - "inboundTag": [ - "api" - ], - "outboundTag": "api", - "type": "field" + "type": "field", + "inboundTag": ["api"], + "outboundTag": "api" }, { + "type": "field", "outboundTag": "blocked", - "ip": [ - "geoip:private" - ], - "type": "field" + "ip": ["geoip:private"] }, { + "type": "field", "outboundTag": "blocked", - "protocol": [ - "bittorrent" - ], - "type": "field" + "protocol": ["bittorrent"] } ] }, "stats": {} -} \ No newline at end of file +} -- cgit v1.2.3 From 4af626bb4b92570032a68e55ece7cb208821fa9f Mon Sep 17 00:00:00 2001 From: Hamidreza Ghavami Date: Tue, 18 Apr 2023 11:21:12 +0430 Subject: update html of setting.html --- web/html/xui/setting.html | 231 +++++++++++++++++++++++++--------------------- 1 file changed, 124 insertions(+), 107 deletions(-) diff --git a/web/html/xui/setting.html b/web/html/xui/setting.html index 0218aea8..7691a284 100644 --- a/web/html/xui/setting.html +++ b/web/html/xui/setting.html @@ -24,121 +24,138 @@ background: white; } + - - {{ template "commonSider" . }} - - - - - - {{ i18n "pages.setting.save" }} - {{ i18n "pages.setting.restartPanel" }} - - - + + {{ template "commonSider" . }} + + + + + + {{ i18n "pages.setting.save" }} + {{ i18n "pages.setting.restartPanel" }} + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + {{ i18n "confirm" }} + + + + + + + {{ i18n "pages.setting.generalConfigs"}} + + + + + {{ i18n "pages.setting.countryConfigs"}} + + + + + {{ i18n "pages.setting.ipv4Configs"}} + + + {{ i18n "pages.setting.warpConfigs"}} + + + + + + {{ i18n "pages.setting.advancedTemplate"}} + + + + + + + + + + + + {{ i18n "pages.setting.completeTemplate"}} + + + + + + + + + + + + + + + + + + + + + + + + + - -{{template "js" .}} -{{template "component/setting"}} -