From 15c04fd6447297ff7e9756695f1b7e05bbfd0e28 Mon Sep 17 00:00:00 2001 From: Hamidreza Ghavami Date: Tue, 18 Apr 2023 10:16:10 +0430 Subject: [PATCH 01/19] 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 From 3f6d4ea857c4adbb35fda63f57ec7f7f32755bfb Mon Sep 17 00:00:00 2001 From: Hamidreza Ghavami Date: Tue, 18 Apr 2023 10:16:43 +0430 Subject: [PATCH 02/19] 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 From b9d08678e319af9aae7802f74f8b6bee2208d9ec Mon Sep 17 00:00:00 2001 From: Hamidreza Ghavami Date: Tue, 18 Apr 2023 10:21:21 +0430 Subject: [PATCH 03/19] 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 -# 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 -# 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 - -# 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 + # 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() { From 2640089a31409558a3a6a827d910e1a420934b73 Mon Sep 17 00:00:00 2001 From: Hamidreza Ghavami Date: Tue, 18 Apr 2023 10:22:04 +0430 Subject: [PATCH 04/19] 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 +} From e2ef984ea6f4c127c8f5e92a8c498d6bbc6adee0 Mon Sep 17 00:00:00 2001 From: Hamidreza Ghavami Date: Tue, 18 Apr 2023 11:21:12 +0430 Subject: [PATCH 05/19] update html of setting.html --- web/html/xui/setting.html | 233 ++++++++++++++++++++------------------ 1 file changed, 125 insertions(+), 108 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" }} - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + {{ 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"}} - + - \ No newline at end of file + + From 2835e5b2c5ab5962a79827c8fe657eae6f4050cb Mon Sep 17 00:00:00 2001 From: Hamidreza Ghavami Date: Tue, 18 Apr 2023 11:26:51 +0430 Subject: [PATCH 09/19] update translation --- web/translation/translate.en_US.toml | 32 +++++++++++++++++++-- web/translation/translate.fa_IR.toml | 40 +++++++++++++++++++++----- web/translation/translate.zh_Hans.toml | 36 +++++++++++++++++++---- 3 files changed, 93 insertions(+), 15 deletions(-) diff --git a/web/translation/translate.en_US.toml b/web/translation/translate.en_US.toml index 97e65b5a..42442159 100644 --- a/web/translation/translate.en_US.toml +++ b/web/translation/translate.en_US.toml @@ -217,16 +217,42 @@ "newPassword" = "New Password" "advancedTemplate" = "Advanced template parts" "completeTemplate" = "Complete template of Xray configuration" +"generalConfigs" = "General Configs" +"countryConfigs" = "Country Configs" +"ipv4Configs" = "IPv4 Configs" +"warpConfigs" = "WARP Configs" "xrayConfigTemplate" = "Xray Configuration Template" "xrayConfigTemplateDesc" = "Generate the final xray configuration file based on this template, restart the panel to take effect." "xrayConfigTorrent" = "Ban bittorrent usage" "xrayConfigTorrentDesc" = "Change the configuration template to avoid using bittorrent by users, restart the panel to take effect" "xrayConfigPrivateIp" = "Ban private IP ranges to connect" "xrayConfigPrivateIpDesc" = "Change the configuration template to avoid connecting with private IP ranges, restart the panel to take effect" +"xrayConfigAds" = "Block Ads" +"xrayConfigAdsDesc" = "Change the configuration template to block Ads, restart the panel to take effect" +"xrayConfigPorn" = "Ban Porn websites to connect" +"xrayConfigPornDesc" = "Change the configuration template to avoid connecting to Porn websites, restart the panel to take effect" "xrayConfigIRIp" = "Ban Iran IP ranges to connect" "xrayConfigIRIpDesc" = "Change the configuration template to avoid connecting with Iran IP ranges, restart the panel to take effect" -"xrayConfigIRdomain" = "Ban IR domains to connect" -"xrayConfigIRdomainDesc" = "Change the configuration template to avoid connecting with IR domains, restart the panel to take effect" +"xrayConfigIRDomain" = "Ban Iran Domains to connect" +"xrayConfigIRDomainDesc" = "Change the configuration template to avoid connecting with Iran domains, restart the panel to take effect" +"xrayConfigChinaIp" = "Ban China IP ranges to connect" +"xrayConfigChinaIpDesc" = "Change the configuration template to avoid connecting with China IP ranges, restart the panel to take effect" +"xrayConfigChinaDomain" = "Ban China Domains to connect" +"xrayConfigChinaDomainDesc" = "Change the configuration template to avoid connecting with China domains, restart the panel to take effect" +"xrayConfigGoogleIPv4" = "Use IPv4 for Google" +"xrayConfigGoogleIPv4Desc" = "Add routing for google to connect with IPv4, restart the panel to take effect" +"xrayConfigNetflixIPv4" = "Use IPv4 for Netflix" +"xrayConfigNetflixIPv4Desc" = "Add routing for Netflix to connect with IPv4, restart the panel to take effect" +"xrayConfigGoogleWARP" = "Route Google to WARP" +"xrayConfigGoogleWARPDesc" = "Add routing for Google to WARP, restart the panel to take effect" +"xrayConfigOpenAIWARP" = "Route OpenAI (ChatGPT) to WARP" +"xrayConfigOpenAIWARPDesc" = "Add routing for OpenAI (ChatGPT) to WARP, restart the panel to take effect" +"xrayConfigNetflixWARP" = "Route Netflix to WARP" +"xrayConfigNetflixWARPDesc" = "Add routing for Netflix to WARP, restart the panel to take effect" +"xrayConfigSpotifyWARP" = "Route Spotify to WARP" +"xrayConfigSpotifyWARPDesc" = "Add routing for Spotify to WARP, restart the panel to take effect" +"xrayConfigIRWARP" = "Route Iran Domains to WARP" +"xrayConfigIRWARPDesc" = "Add routing for Iran Domains to WARP. restart the panel to take effect" "xrayConfigInbounds" = "Configuration of Inbounds" "xrayConfigInboundsDesc" = "Change the configuration template to accept special clients, restart the panel to take effect" "xrayConfigOutbounds" = "Configuration of Outbounds" @@ -257,4 +283,4 @@ "getSetting" = "Get setting" "modifyUser" = "Modify user" "originalUserPassIncorrect" = "The original user name or original password is incorrect" -"userPassMustBeNotEmpty" = "New username and new password cannot be empty" \ No newline at end of file +"userPassMustBeNotEmpty" = "New username and new password cannot be empty" diff --git a/web/translation/translate.fa_IR.toml b/web/translation/translate.fa_IR.toml index c7ecb331..9890be13 100644 --- a/web/translation/translate.fa_IR.toml +++ b/web/translation/translate.fa_IR.toml @@ -215,16 +215,42 @@ "newPassword" = "رمز عبور جدید" "advancedTemplate" = "بخش های پیشرفته الگو" "completeTemplate" = "الگوی کامل تنظیمات ایکس ری" +"generalConfigs" = "تنظیمات عمومی" +"countryConfigs" = "تنظیمات برای کشورها" +"ipv4Configs" = "تنظیمات برای IPv4" +"warpConfigs" = "تنظیمات برای WARP" "xrayConfigTemplate" = "تنظیمات الگو ایکس ری" "xrayConfigTemplateDesc" = "فایل پیکربندی ایکس ری نهایی بر اساس این الگو ایجاد میشود. لطفاً این را تغییر ندهید مگر اینکه دقیقاً بدانید که چه کاری انجام می دهید! پنل را مجدداً راه اندازی کنید تا اعمال شود" "xrayConfigTorrent" = "فیلتر کردن بیت تورنت" "xrayConfigTorrentDesc" = "الگوی تنظیمات را برای فیلتر کردن پروتکل بیت تورنت برای کاربران تغییر میدهد. پنل را مجدداً راه اندازی کنید تا اعمال شود" -"xrayConfigPrivateIp" = "جلوگیری از اتصال آی پی های نامعتبر" -"xrayConfigPrivateIpDesc" = "الگوی تنظیمات را برای فیلتر کردن اتصال آی پی های نامعتبر و بسته های سرگردان تغییر میدهد. پنل را مجدداً راه اندازی کنید تا اعمال شود" -"xrayConfigIRIp" = "جلوگیری از اتصال آی پی های ایران" -"xrayConfigIRIpDesc" = "الگوی تنظیمات را برای فیلتر کردن اتصال آی پی های ایران تغییر میدهد. پنل را مجدداً راه اندازی کنید تا اعمال شود" -"xrayConfigIRdomain" = "جلوگیری از اتصال دامنه های ایران" -"xrayConfigIRdomainDesc" = "الگوی تنظیمات را برای فیلتر کردن اتصال دامنه های ایران تغییر میدهد. پنل را مجدداً راه اندازی کنید تا اعمال شود" +"xrayConfigPrivateIp" = "جلوگیری از اتصال آیپی های خصوصی یا محلی" +"xrayConfigPrivateIpDesc" = "الگوی تنظیمات را برای فیلتر کردن اتصال آیپی های خصوصی یا محلی و بسته های سرگردان تغییر میدهد. پنل را مجدداً راه اندازی کنید تا اعمال شود" +"xrayConfigAds" = "مسدود کردن تبلیغات" +"xrayConfigAdsDesc" = "الگوی تنظیمات را برای مسدود کردن تبلیغات تغییر میدهد. پنل را مجدداً راه اندازی کنید تا اعمال شود" +"xrayConfigPorn" = "جلوگیری از اتصال به سایت های پورن" +"xrayConfigPornDesc" = "الگوی تنظیمات را برای فیلتر کردن اتصال به سایت های پورن تغییر میدهد. پنل را مجدداً راه اندازی کنید تا اعمال شود" +"xrayConfigIRIp" = "جلوگیری از اتصال آیپی های ایران" +"xrayConfigIRIpDesc" = "الگوی تنظیمات را برای فیلتر کردن اتصال آیپی های ایران تغییر میدهد. پنل را مجدداً راه اندازی کنید تا اعمال شود" +"xrayConfigIRDomain" = "جلوگیری از اتصال دامنه های ایران" +"xrayConfigIRDomainDesc" = "الگوی تنظیمات را برای فیلتر کردن اتصال دامنه های ایران تغییر میدهد. پنل را مجدداً راه اندازی کنید تا اعمال شود" +"xrayConfigChinaIp" = "جلوگیری از اتصال آیپی های چین" +"xrayConfigChinaIpDesc" = "الگوی تنظیمات را برای فیلتر کردن اتصال آیپی های چین تغییر میدهد. پنل را مجدداً راه اندازی کنید تا اعمال شود" +"xrayConfigChinaDomain" = "جلوگیری از اتصال دامنه های چین" +"xrayConfigChinaDomainDesc" = "الگوی تنظیمات را برای فیلتر کردن اتصال دامنه های چین تغییر میدهد. پنل را مجدداً راه اندازی کنید تا اعمال شود" +"xrayConfigGoogleIPv4" = "استفاده از آیپی ورژن 4 برای اتصال به گوگل" +"xrayConfigGoogleIPv4Desc" = "مسیردهی جدید برای اتصال به گوگل با آیپی ورژن 4 اضافه میکند. پنل را مجدداً راه اندازی کنید تا اعمال شود" +"xrayConfigNetflixIPv4" = "استفاده از آیپی ورژن 4 برای اتصال به نتفلیکس" +"xrayConfigNetflixIPv4Desc" = "مسیردهی جدید برای اتصال به نتفلیکس با آیپی ورژن 4 اضافه میکند. پنل را مجدداً راه اندازی کنید تا اعمال شود" +"xrayConfigGoogleWARP" = "مسیردهی گوگل به WARP" +"xrayConfigGoogleWARPDesc" = "مسیردهی جدید برای اتصال به گوگل به WARP اضافه میکند. پنل را مجدداً راه اندازی کنید تا اعمال شود" +"xrayConfigOpenAIWARP" = "مسیردهی OpenAI (ChatGPT) به WARP" +"xrayConfigOpenAIWARPDesc" = "مسیردهی جدید برای اتصال به OpenAI (ChatGPT) به WARP اضافه میکند. پنل را مجدداً راه اندازی کنید تا اعمال شود" +"xrayConfigNetflixWARP" = "مسیردهی نتفلیکس به WARP" +"xrayConfigNetflixWARPDesc" = "مسیردهی جدید برای اتصال به نتفلیکس به WARP اضافه میکند. پنل را مجدداً راه اندازی کنید تا اعمال شود" +"xrayConfigSpotifyWARP" = "مسیردهی اسپاتیفای به WARP" +"xrayConfigSpotifyWARPDesc" = "مسیردهی جدید برای اتصال به اسپاتیفای به WARP اضافه میکند. پنل را مجدداً راه اندازی کنید تا اعمال شود" +"xrayConfigIRWARP" = "مسیردهی دامنه های ایران به WARP" +"xrayConfigIRWARPDesc" = "مسیردهی جدید برای اتصال به دامنه های ایران به WARP اضافه میکند. پنل را مجدداً راه اندازی کنید تا اعمال شود" "xrayConfigInbounds" = "تنظیمات ورودی" "xrayConfigInboundsDesc" = "میتوانید الگوی تنظیمات را برای ورودی های خاص تنظیم نمایید. پنل را مجدداً راه اندازی کنید تا اعمال شود" "xrayConfigOutbounds" = "تنظیمات خروجی" @@ -255,4 +281,4 @@ "getSetting" = "دریافت تنظیمات" "modifyUser" = "ویرایش کاربر" "originalUserPassIncorrect" = "نام کاربری و رمز عبور فعلی اشتباه می باشد ." -"userPassMustBeNotEmpty" = "نام کاربری و رمز عبور جدید نمیتواند خالی باشد ." \ No newline at end of file +"userPassMustBeNotEmpty" = "نام کاربری و رمز عبور جدید نمیتواند خالی باشد ." diff --git a/web/translation/translate.zh_Hans.toml b/web/translation/translate.zh_Hans.toml index 1d8d28b9..1505ff5c 100644 --- a/web/translation/translate.zh_Hans.toml +++ b/web/translation/translate.zh_Hans.toml @@ -215,16 +215,42 @@ "newPassword" = "新密码" "advancedTemplate" = "高级模板部件" "completeTemplate" = "Xray 配置的完整模板" +"generalConfigs" = "一般配置" +"countryConfigs" = "国家配置" +"ipv4Configs" = "IPv4 配置" +"warpConfigs" = "WARP 配置" "xrayConfigTemplate" = "xray 配置模板" "xrayConfigTemplateDesc" = "以该模型为基础生成最终的xray配置文件,重新启动面板生成效率" "xrayConfigTorrent" = "禁止使用 bittorrent" "xrayConfigTorrentDesc" = "更改配置模板避免用户使用bittorrent,重启面板生效" -"xrayConfigPrivateIp" = "禁止私人 ip 范围连接" +"xrayConfigPrivateIp" = "禁止私人 IP 范围连接" "xrayConfigPrivateIpDesc" = "更改配置模板以避免连接私有 IP 范围,重启面板生效" +"xrayConfigAds" = "屏蔽广告" +"xrayConfigAdsDesc" = "修改配置模板屏蔽广告,重启面板生效" +"xrayConfigPorn" = "禁止色情网站连接" +"xrayConfigPornDesc" = "更改配置模板避免连接色情网站,重启面板生效" "xrayConfigIRIp" = "禁止伊朗 IP 范围连接" -"xrayConfigIRIpDesc" = "修改配置模板避免连接伊朗IP范围,重启面板生效" -"xrayConfigIRdomain" = "禁止伊朗域连接" -"xrayConfigIRdomainDesc" = "修改配置模板避免连接伊朗域名,重启面板生效" +"xrayConfigIRIpDesc" = "修改配置模板避免连接伊朗IP段,重启面板生效" +"xrayConfigIRDomain" = "禁止伊朗域连接" +"xrayConfigIRDomainDesc" = "更改配置模板避免连接伊朗域名,重启面板生效" +"xrayConfigChinaIp" = "禁止中国 IP 范围连接" +"xrayConfigChinaIpDesc" = "修改配置模板避免连接中国IP段,重启面板生效" +"xrayConfigChinaDomain" = "禁止中国域名连接" +"xrayConfigChinaDomainDesc" = "更改配置模板避免连接中国域,重启面板生效" +"xrayConfigGoogleIPv4" = "为谷歌使用 IPv4" +"xrayConfigGoogleIPv4Desc" = "添加谷歌连接IPv4的路由,重启面板生效" +"xrayConfigNetflixIPv4" = "为 Netflix 使用 IPv4" +"xrayConfigNetflixIPv4Desc" = "添加Netflix连接IPv4的路由,重启面板生效" +"xrayConfigGoogleWARP" = "将谷歌路由到 WARP" +"xrayConfigGoogleWARPDesc" = "为谷歌添加路由到WARP,重启面板生效" +"xrayConfigOpenAIWARP" = "将 OpenAI (ChatGPT) 路由到 WARP" +"xrayConfigOpenAIWARPDesc" = "将OpenAI(ChatGPT)路由添加到WARP,重启面板生效" +"xrayConfigNetflixWARP" = "将 Netflix 路由到 WARP" +"xrayConfigNetflixWARPDesc" = "为Netflix添加路由到WARP,重启面板生效" +"xrayConfigSpotifyWARP" = "将 Spotify 路由到 WARP" +"xrayConfigSpotifyWARPDesc" = "为Spotify添加路由到WARP,重启面板生效" +"xrayConfigIRWARP" = "将伊朗域名路由到 WARP" +"xrayConfigIRWARPDesc" = "将伊朗域的路由添加到 WARP。 重启面板生效" "xrayConfigInbounds" = "入站配置" "xrayConfigInboundsDesc" = "更改配置模板接受特殊客户端,重启面板生效" "xrayConfigOutbounds" = "出站配置" @@ -255,4 +281,4 @@ "getSetting" = "获取设置" "modifyUser" = "修改用户" "originalUserPassIncorrect" = "原用户名或原密码错误" -"userPassMustBeNotEmpty" = "新用户名和新密码不能为空" \ No newline at end of file +"userPassMustBeNotEmpty" = "新用户名和新密码不能为空" From 42cd200e759fcb14232f6f7879070ea7f19a9f88 Mon Sep 17 00:00:00 2001 From: Hamidreza Ghavami Date: Tue, 18 Apr 2023 11:31:52 +0430 Subject: [PATCH 10/19] update README.md --- README.md | 103 ++++++++++---- .../traffic+block-ads+ipv4-google.json | 88 ++++++++++++ ...ic+block-ads+warp-global+iran-domains.json | 127 ++++++++++++++++++ media/configs/traffic+block-iran-domains.json | 95 +++++++++++++ .../traffic+block-iran-ip.json} | 56 ++++---- .../traffic.json} | 45 +++---- media/enable-traffic+block-IR-domain.txt | 84 ------------ 7 files changed, 428 insertions(+), 170 deletions(-) create mode 100644 media/configs/traffic+block-ads+ipv4-google.json create mode 100644 media/configs/traffic+block-ads+warp-global+iran-domains.json create mode 100644 media/configs/traffic+block-iran-domains.json rename media/{enable-traffic+block-IR-IP.txt => configs/traffic+block-iran-ip.json} (55%) rename media/{enable-traffic.txt => configs/traffic.json} (57%) delete mode 100644 media/enable-traffic+block-IR-domain.txt diff --git a/README.md b/README.md index 8c3bb5c8..58503fe3 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ # 3x-ui + [![](https://img.shields.io/github/v/release/mhsanaei/3x-ui.svg)](https://github.com/MHSanaei/3x-ui/releases) [![](https://img.shields.io/github/actions/workflow/status/mhsanaei/3x-ui/release.yml.svg)](#) [![GO Version](https://img.shields.io/github/go-mod/go-version/mhsanaei/3x-ui.svg)](#) [![Downloads](https://img.shields.io/github/downloads/mhsanaei/3x-ui/total.svg)](#) [![License](https://img.shields.io/badge/license-GPL%20V3-blue.svg?longCache=true)](https://www.gnu.org/licenses/gpl-3.0.en.html) - > **Disclaimer: This project is only for personal learning and communication, please do not use it for illegal purposes, please do not use it in a production environment** xray panel supporting multi-protocol, **Multi-lang (English,Farsi,Chinese)** @@ -15,19 +15,24 @@ xray panel supporting multi-protocol, **Multi-lang (English,Farsi,Chinese)** ``` bash <(curl -Ls https://raw.githubusercontent.com/mhsanaei/3x-ui/master/install.sh) ``` + ## Install custom version + To install your desired version you can add the version to the end of install command. Example for ver `v1.0.9`: + ``` bash <(curl -Ls https://raw.githubusercontent.com/mhsanaei/3x-ui/master/install.sh) v1.0.9 ``` + # SSL + ``` apt-get install certbot -y certbot certonly --standalone --agree-tos --register-unsafely-without-email -d yourdomain.com certbot renew --dry-run ``` -**If you think this project is helpful to you, you may wish to give a** :star2: +**If you think this project is helpful to you, you may wish to give a** :star2: # Default settings @@ -36,18 +41,58 @@ certbot renew --dry-run - database path: /etc/x-ui/x-ui.db - xray config path: /usr/local/x-ui/bin/config.json -before you set ssl on settings -- http:// ip or domain:2053/xui +Before you set ssl on settings + +- http://ip:2053/xui +- http://domain:2053/xui + +After you set ssl on settings -After you set ssl on settings - https://yourdomain:2053/xui -# Enable Traffic For Users: +# Environment Variables + +| Variable | Type | Default | +| -------------- | :--------------------------------------------: | :------------ | +| XUI_LOG_LEVEL | `"debug"` \| `"info"` \| `"warn"` \| `"error"` | `"info"` | +| XUI_DEBUG | `boolean` | `false` | +| XUI_BIN_FOLDER | `string` | `"bin"` | +| XUI_DB_FOLDER | `string` | `"/etc/x-ui"` | + +Example: + +```sh +XUI_BIN_FOLDER="bin" XUI_DB_FOLDER="/etc/x-ui" go build main.go +``` + +# Xray Configurations: **copy and paste to xray Configuration :** (you don't need to do this if you have a fresh install) -- [enable traffic](./media/enable-traffic.txt) -- [enable traffic+block all IR IP address](./media/enable-traffic+block-IR-IP.txt) -- [enable traffic+block all IR domain](./media/enable-traffic+block-IR-domain.txt) + +- [traffic](./media/configs/traffic.json) +- [traffic + Block all Iran IP address](./media/configs/traffic+block-iran-ip.json) +- [traffic + Block all Iran Domains](./media/configs/traffic+block-iran-domains.json) +- [traffic + Block Ads + Use IPv4 for Google](./media/configs/traffic+block-ads+ipv4-google.json) +- [traffic + Block Ads + Route Iran domains + Google + Netflix + Spotify + OpenAI (ChatGPT) to WARP](./media/configs/traffic+block-ads+warp-global+iran-domains.json) + +# [WARP Configuration](https://github.com/fscarmen/warp) (Optional) + +If you want to use routing to WARP follow steps as below: + +1. Install WARP on **socks proxy mode**: + + ```sh + curl -fsSL https://gist.githubusercontent.com/hamid-gh98/dc5dd9b0cc5b0412af927b1ccdb294c7/raw/install_warp_proxy.sh | bash + ``` + +2. [Copy and paste this file to Xray Configuration](./media/configs/traffic+block-ads+warp-global+iran-domains.json) or Turn on the config you need in panel + + Config Features: + + - Block Ads + - Route Google + Netflix + Spotify + OpenAI (ChatGPT) to WARP + - Route Iran Domains to WARP + - Fix Google 403 error # Features @@ -62,7 +107,8 @@ After you set ssl on settings - Support https access panel (self-provided domain name + ssl certificate) - Support one-click SSL certificate application and automatic renewal - For more advanced configuration items, please refer to the panel -- fix api routes (user setting will create with api) +- Fix api routes (user setting will create with api) +- Support to change switch config by different type of items provided in panel # Tg robot use @@ -79,8 +125,8 @@ Set the robot-related parameters in the panel background, including: Reference syntax: -- 30 * * * * * //Notify at the 30s of each point -- 0 */10 * * * * //Notify at the first second of each 10 minutes +- 30 \* \* \* \* \* //Notify at the 30s of each point +- 0 \*/10 \* \* \* \* //Notify at the first second of each 10 minutes - @hourly // hourly notification - @daily // Daily notification (00:00 in the morning) - @every 8h // notify every 8 hours @@ -100,33 +146,34 @@ Reference syntax: - Check depleted users - Receive backup by request and in periodic reports - ## API routes - `/login` with `PUSH` user data: `{username: '', password: ''}` for login - `/xui/API/inbounds` base for following actions: -| Method | Path | Action | -| ------------- | ------------- | ------------- | -| GET | "/list" | Get all inbounds | -| GET | "/get/:id" | Get inbound with inbound.id | -| POST | "/add" | Add inbound | -| POST | "/del/:id" | Delete Inbound | -| POST | "/update/:id" | Update Inbound | -| POST | "/clientIps/:email" | Client Ip address | -| POST | "/clearClientIps/:email" | Clear Client Ip address | -| POST | "/addClient/" | Add Client to inbound | -| POST | "/delClient/:email" | Delete Client | -| POST | "/updateClient/:index" | Update Client | -| POST | "/:id/resetClientTraffic/:email" | Reset Client's Traffic | -| POST | "/resetAllTraffics" | Reset traffics of all inbounds | -| POST | "/resetAllClientTraffics/:id" | Reset traffics of all clients in an inbound | +| Method | Path | Action | +| :----: | ---------------------------------- | ------------------------------------------- | +| `GET` | `"/list"` | Get all inbounds | +| `GET` | `"/get/:id"` | Get inbound with inbound.id | +| `POST` | `"/add"` | Add inbound | +| `POST` | `"/del/:id"` | Delete Inbound | +| `POST` | `"/update/:id"` | Update Inbound | +| `POST` | `"/clientIps/:email"` | Client Ip address | +| `POST` | `"/clearClientIps/:email"` | Clear Client Ip address | +| `POST` | `"/addClient/"` | Add Client to inbound | +| `POST` | `"/delClient/:email"` | Delete Client | +| `POST` | `"/updateClient/:index"` | Update Client | +| `POST` | `"/:id/resetClientTraffic/:email"` | Reset Client's Traffic | +| `POST` | `"/resetAllTraffics"` | Reset traffics of all inbounds | +| `POST` | `"/resetAllClientTraffics/:id"` | Reset traffics of all clients in an inbound | # A Special Thanks To + - [alireza0](https://github.com/alireza0/) - [FranzKafkaYu](https://github.com/FranzKafkaYu) # Suggestion System + - Ubuntu 20.04+ - Debian 10+ - CentOS 8+ diff --git a/media/configs/traffic+block-ads+ipv4-google.json b/media/configs/traffic+block-ads+ipv4-google.json new file mode 100644 index 00000000..d2ca2d45 --- /dev/null +++ b/media/configs/traffic+block-ads+ipv4-google.json @@ -0,0 +1,88 @@ +{ + "log": { + "loglevel": "warning", + "access": "./access.log", + "error": "./error.log" + }, + "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" + } + } + ], + "outbounds": [ + { + "protocol": "freedom", + "settings": {} + }, + { + "tag": "blocked", + "protocol": "blackhole", + "settings": {} + }, + { + "tag": "IPv4", + "protocol": "freedom", + "settings": { + "domainStrategy": "UseIPv4" + } + } + ], + "policy": { + "levels": { + "0": { + "statsUserDownlink": true, + "statsUserUplink": true + } + }, + "system": { + "statsInboundDownlink": true, + "statsInboundUplink": true + } + }, + "routing": { + "domainStrategy": "IPIfNonMatch", + "rules": [ + { + "type": "field", + "inboundTag": ["api"], + "outboundTag": "api" + }, + { + "type": "field", + "outboundTag": "blocked", + "ip": ["geoip:private"] + }, + { + "type": "field", + "outboundTag": "blocked", + "protocol": ["bittorrent"] + }, + { + "type": "field", + "outboundTag": "blocked", + "domain": [ + "geosite:category-ads-all", + "geosite:category-ads", + "geosite:google-ads", + "geosite:spotify-ads" + ] + }, + { + "type": "field", + "outboundTag": "IPv4", + "domain": ["geosite:google"] + } + ] + }, + "stats": {} +} diff --git a/media/configs/traffic+block-ads+warp-global+iran-domains.json b/media/configs/traffic+block-ads+warp-global+iran-domains.json new file mode 100644 index 00000000..0ee0695d --- /dev/null +++ b/media/configs/traffic+block-ads+warp-global+iran-domains.json @@ -0,0 +1,127 @@ +{ + "log": { + "loglevel": "warning", + "access": "./access.log", + "error": "./error.log" + }, + "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" + } + } + ], + "outbounds": [ + { + "protocol": "freedom", + "settings": {} + }, + { + "tag": "blocked", + "protocol": "blackhole", + "settings": {} + }, + { + "tag": "WARP", + "protocol": "socks", + "settings": { + "servers": [ + { + "address": "127.0.0.1", + "port": 40000 + } + ] + } + } + ], + "policy": { + "levels": { + "0": { + "statsUserDownlink": true, + "statsUserUplink": true + } + }, + "system": { + "statsInboundDownlink": true, + "statsInboundUplink": true + } + }, + "routing": { + "domainStrategy": "IPIfNonMatch", + "rules": [ + { + "type": "field", + "inboundTag": ["api"], + "outboundTag": "api" + }, + { + "type": "field", + "outboundTag": "blocked", + "ip": ["geoip:private"] + }, + { + "type": "field", + "outboundTag": "blocked", + "protocol": ["bittorrent"] + }, + { + "type": "field", + "outboundTag": "blocked", + "domain": [ + "geosite:category-ads-all", + "geosite:category-ads", + "geosite:google-ads", + "geosite:spotify-ads" + ] + }, + { + "type": "field", + "outboundTag": "WARP", + "domain": [ + "geosite:google", + "geosite:netflix", + "geosite:spotify", + "geosite:openai" + ] + }, + { + "type": "field", + "outboundTag": "WARP", + "domain": [ + "regexp:.*\\.ir$", + "ext:iran.dat:ir", + "ext:iran.dat:other", + "geosite:category-ir", + "bank", + "tapsi", + "snapp", + "blogfa", + "digikala", + "Torob.com", + "sheypoor.com", + "Tgju.org", + "sb24.com", + "tebyan.net", + "beytoote.com", + "telewebion.com", + "Film2movie.ws", + "Setare.com", + "Filimo.com", + "downloadha.com", + "P30download.com", + "Sarzamindownload.com", + "Sanjesh.org" + ] + } + ] + }, + "stats": {} +} diff --git a/media/configs/traffic+block-iran-domains.json b/media/configs/traffic+block-iran-domains.json new file mode 100644 index 00000000..f04a8322 --- /dev/null +++ b/media/configs/traffic+block-iran-domains.json @@ -0,0 +1,95 @@ +{ + "log": { + "loglevel": "warning", + "access": "./access.log", + "error": "./error.log" + }, + "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" + } + } + ], + "outbounds": [ + { + "protocol": "freedom", + "settings": {} + }, + { + "tag": "blocked", + "protocol": "blackhole", + "settings": {} + } + ], + "policy": { + "levels": { + "0": { + "statsUserDownlink": true, + "statsUserUplink": true + } + }, + "system": { + "statsInboundDownlink": true, + "statsInboundUplink": true + } + }, + "routing": { + "domainStrategy": "IPIfNonMatch", + "rules": [ + { + "type": "field", + "inboundTag": ["api"], + "outboundTag": "api" + }, + { + "type": "field", + "outboundTag": "blocked", + "ip": ["geoip:private"] + }, + { + "type": "field", + "outboundTag": "blocked", + "protocol": ["bittorrent"] + }, + { + "type": "field", + "outboundTag": "blocked", + "domain": [ + "regexp:.*\\.ir$", + "ext:iran.dat:ir", + "ext:iran.dat:other", + "geosite:category-ir", + "bank", + "tapsi", + "snapp", + "blogfa", + "digikala", + "Torob.com", + "sheypoor.com", + "Tgju.org", + "sb24.com", + "tebyan.net", + "beytoote.com", + "telewebion.com", + "Film2movie.ws", + "Setare.com", + "Filimo.com", + "downloadha.com", + "P30download.com", + "Sarzamindownload.com", + "Sanjesh.org" + ] + } + ] + }, + "stats": {} +} diff --git a/media/enable-traffic+block-IR-IP.txt b/media/configs/traffic+block-iran-ip.json similarity index 55% rename from media/enable-traffic+block-IR-IP.txt rename to media/configs/traffic+block-iran-ip.json index 919bef03..103ca700 100644 --- a/media/enable-traffic+block-IR-IP.txt +++ b/media/configs/traffic+block-iran-ip.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,34 +46,31 @@ "domainStrategy": "IPIfNonMatch", "rules": [ { - "inboundTag": [ - "api" - ], - "outboundTag": "api", - "type": "field" + "type": "field", + "inboundTag": ["api"], + "outboundTag": "api" }, { + "type": "field", "outboundTag": "blocked", - "protocol": [ - "bittorrent" - ], - "type": "field" + "ip": ["geoip:private"] }, { + "type": "field", "outboundTag": "blocked", - "ip": [ - "geoip:private" - ], - "type": "field" + "protocol": ["bittorrent"] }, { + "type": "field", "outboundTag": "blocked", - "ip": [ - "geoip:ir" - ], - "type": "field" + "ip": ["geoip:private"] + }, + { + "type": "field", + "outboundTag": "blocked", + "ip": ["geoip:ir"] } ] }, "stats": {} -} \ No newline at end of file +} diff --git a/media/enable-traffic.txt b/media/configs/traffic.json similarity index 57% rename from media/enable-traffic.txt rename to media/configs/traffic.json index 34e2038f..9d8d2d9f 100644 --- a/media/enable-traffic.txt +++ b/media/configs/traffic.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 +} diff --git a/media/enable-traffic+block-IR-domain.txt b/media/enable-traffic+block-IR-domain.txt deleted file mode 100644 index 4fcf3ee7..00000000 --- a/media/enable-traffic+block-IR-domain.txt +++ /dev/null @@ -1,84 +0,0 @@ -{ - "log": { - "loglevel": "warning", - "access": "./access.log" - }, - "api": { - "services": [ - "HandlerService", - "LoggerService", - "StatsService" - ], - "tag": "api" - }, - "inbounds": [ - { - "listen": "127.0.0.1", - "port": 62789, - "protocol": "dokodemo-door", - "settings": { - "address": "127.0.0.1" - }, - "tag": "api" - } - ], - "outbounds": [ - { - "protocol": "freedom", - "settings": {} - }, - { - "protocol": "blackhole", - "settings": {}, - "tag": "blocked" - } - ], - "policy": { - "levels": { - "0": { - "statsUserUplink": true, - "statsUserDownlink": true - } - }, - "system": { - "statsInboundDownlink": true, - "statsInboundUplink": true - } - }, - "routing": { - "domainStrategy": "IPIfNonMatch", - "rules": [ - { - "inboundTag": [ - "api" - ], - "outboundTag": "api", - "type": "field" - }, - { - "ip": [ - "geoip:private" - ], - "outboundTag": "blocked", - "type": "field" - }, - { - "outboundTag": "blocked", - "protocol": [ - "bittorrent" - ], - "type": "field" - }, - { - "outboundTag": "blocked", - "domain": [ - "regexp:.+.ir$", - "ext:iran.dat:ir", - "ext:iran.dat:other" - ], - "type": "field" - } - ] - }, - "stats": {} -} \ No newline at end of file From a4345760300892818bdc27179c525757f67d7f64 Mon Sep 17 00:00:00 2001 From: Hamidreza Ghavami Date: Tue, 18 Apr 2023 11:33:55 +0430 Subject: [PATCH 11/19] update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 58503fe3..c458685f 100644 --- a/README.md +++ b/README.md @@ -108,7 +108,7 @@ If you want to use routing to WARP follow steps as below: - Support one-click SSL certificate application and automatic renewal - For more advanced configuration items, please refer to the panel - Fix api routes (user setting will create with api) -- Support to change switch config by different type of items provided in panel +- Support to change configs by different items provided in panel # Tg robot use From 1747c545cec7f57ca375f41520a6ba712eae2fb4 Mon Sep 17 00:00:00 2001 From: Hamidreza Ghavami Date: Tue, 18 Apr 2023 21:19:25 +0430 Subject: [PATCH 12/19] update media/configs --- ...mains.json => traffic+block-ads+warp.json} | 29 ------------------- media/configs/traffic+block-iran-domains.json | 21 +------------- 2 files changed, 1 insertion(+), 49 deletions(-) rename media/configs/{traffic+block-ads+warp-global+iran-domains.json => traffic+block-ads+warp.json} (73%) diff --git a/media/configs/traffic+block-ads+warp-global+iran-domains.json b/media/configs/traffic+block-ads+warp.json similarity index 73% rename from media/configs/traffic+block-ads+warp-global+iran-domains.json rename to media/configs/traffic+block-ads+warp.json index 0ee0695d..504a8481 100644 --- a/media/configs/traffic+block-ads+warp-global+iran-domains.json +++ b/media/configs/traffic+block-ads+warp.json @@ -91,35 +91,6 @@ "geosite:spotify", "geosite:openai" ] - }, - { - "type": "field", - "outboundTag": "WARP", - "domain": [ - "regexp:.*\\.ir$", - "ext:iran.dat:ir", - "ext:iran.dat:other", - "geosite:category-ir", - "bank", - "tapsi", - "snapp", - "blogfa", - "digikala", - "Torob.com", - "sheypoor.com", - "Tgju.org", - "sb24.com", - "tebyan.net", - "beytoote.com", - "telewebion.com", - "Film2movie.ws", - "Setare.com", - "Filimo.com", - "downloadha.com", - "P30download.com", - "Sarzamindownload.com", - "Sanjesh.org" - ] } ] }, diff --git a/media/configs/traffic+block-iran-domains.json b/media/configs/traffic+block-iran-domains.json index f04a8322..b6f05704 100644 --- a/media/configs/traffic+block-iran-domains.json +++ b/media/configs/traffic+block-iran-domains.json @@ -67,26 +67,7 @@ "regexp:.*\\.ir$", "ext:iran.dat:ir", "ext:iran.dat:other", - "geosite:category-ir", - "bank", - "tapsi", - "snapp", - "blogfa", - "digikala", - "Torob.com", - "sheypoor.com", - "Tgju.org", - "sb24.com", - "tebyan.net", - "beytoote.com", - "telewebion.com", - "Film2movie.ws", - "Setare.com", - "Filimo.com", - "downloadha.com", - "P30download.com", - "Sarzamindownload.com", - "Sanjesh.org" + "geosite:category-ir" ] } ] From 0f7b3eddaf6dcf6ba597cc52d42e04dd51861923 Mon Sep 17 00:00:00 2001 From: Hamidreza Ghavami Date: Tue, 18 Apr 2023 21:20:28 +0430 Subject: [PATCH 13/19] update README.md --- README.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 64feb39e..8519b64e 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ > **Disclaimer: This project is only for personal learning and communication, please do not use it for illegal purposes, please do not use it in a production environment** -**If you think this project is helpful to you, you may wish to give a** :star2: +**If you think this project is helpful to you, you may wish to give a** :star2: xray panel supporting multi-protocol, **Multi-lang (English,Farsi,Chinese)** @@ -34,7 +34,6 @@ certbot certonly --standalone --agree-tos --register-unsafely-without-email -d y certbot renew --dry-run ``` - # Default settings - Port: 2053 @@ -74,7 +73,7 @@ XUI_BIN_FOLDER="bin" XUI_DB_FOLDER="/etc/x-ui" go build main.go - [traffic + Block all Iran IP address](./media/configs/traffic+block-iran-ip.json) - [traffic + Block all Iran Domains](./media/configs/traffic+block-iran-domains.json) - [traffic + Block Ads + Use IPv4 for Google](./media/configs/traffic+block-ads+ipv4-google.json) -- [traffic + Block Ads + Route Iran domains + Google + Netflix + Spotify + OpenAI (ChatGPT) to WARP](./media/configs/traffic+block-ads+warp-global+iran-domains.json) +- [traffic + Block Ads + Route Google + Netflix + Spotify + OpenAI (ChatGPT) to WARP](./media/configs/traffic+block-ads+warp.json) # [WARP Configuration](https://github.com/fscarmen/warp) (Optional) @@ -86,13 +85,12 @@ If you want to use routing to WARP follow steps as below: curl -fsSL https://gist.githubusercontent.com/hamid-gh98/dc5dd9b0cc5b0412af927b1ccdb294c7/raw/install_warp_proxy.sh | bash ``` -2. [Copy and paste this file to Xray Configuration](./media/configs/traffic+block-ads+warp-global+iran-domains.json) or Turn on the config you need in panel +2. Turn on the config you need in panel or [Copy and paste this file to Xray Configuration](./media/configs/traffic+block-ads+warp.json) Config Features: - Block Ads - Route Google + Netflix + Spotify + OpenAI (ChatGPT) to WARP - - Route Iran Domains to WARP - Fix Google 403 error # Features @@ -183,6 +181,7 @@ Reference syntax: # Buy Me a Coffee [![](https://img.shields.io/badge/Wallet-USDT__TRC20-green.svg)](#) + ``` TXncxkvhkDWGts487Pjqq1qT9JmwRUz8CC ``` From a6a05dd938e2f9e1cda1439045b883ec052530d6 Mon Sep 17 00:00:00 2001 From: Hamidreza Ghavami Date: Tue, 18 Apr 2023 21:21:09 +0430 Subject: [PATCH 14/19] add api route setting/getDefaultJsonConfig --- web/controller/setting.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/web/controller/setting.go b/web/controller/setting.go index 261eeec8..1de55ab6 100644 --- a/web/controller/setting.go +++ b/web/controller/setting.go @@ -37,6 +37,7 @@ func (a *SettingController) initRouter(g *gin.RouterGroup) { g.POST("/update", a.updateSetting) g.POST("/updateUser", a.updateUser) g.POST("/restartPanel", a.restartPanel) + g.GET("/getDefaultJsonConfig", a.getDefaultJsonConfig) } func (a *SettingController) getAllSetting(c *gin.Context) { @@ -48,6 +49,15 @@ func (a *SettingController) getAllSetting(c *gin.Context) { jsonObj(c, allSetting, nil) } +func (a *SettingController) getDefaultJsonConfig(c *gin.Context) { + defaultJsonConfig, err := a.settingService.GetDefaultJsonConfig() + if err != nil { + jsonMsg(c, I18n(c, "pages.setting.toasts.getSetting"), err) + return + } + jsonObj(c, defaultJsonConfig, nil) +} + func (a *SettingController) getDefaultSettings(c *gin.Context) { expireDiff, err := a.settingService.GetExpireDiff() if err != nil { From ecfbe7cc84e07dc7ce684d6b9d09cd56d7c1c7f8 Mon Sep 17 00:00:00 2001 From: Hamidreza Ghavami Date: Tue, 18 Apr 2023 21:21:37 +0430 Subject: [PATCH 15/19] add func to setting service --- web/service/setting.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/web/service/setting.go b/web/service/setting.go index ff22f847..9d92685e 100644 --- a/web/service/setting.go +++ b/web/service/setting.go @@ -2,6 +2,7 @@ package service import ( _ "embed" + "encoding/json" "errors" "fmt" "reflect" @@ -42,6 +43,15 @@ var defaultValueMap = map[string]string{ type SettingService struct { } +func (s *SettingService) GetDefaultJsonConfig() (interface{}, error) { + var jsonData interface{} + err := json.Unmarshal([]byte(xrayTemplateConfig), &jsonData) + if err != nil { + return nil, err + } + return jsonData, nil +} + func (s *SettingService) GetAllSetting() (*entity.AllSetting, error) { db := database.GetDB() settings := make([]*model.Setting, 0) From 96d4302a7930e5dcb0b232c6fc7b68f83de5afe2 Mon Sep 17 00:00:00 2001 From: Hamidreza Ghavami Date: Tue, 18 Apr 2023 21:23:12 +0430 Subject: [PATCH 16/19] update domain list of setting.html --- web/html/xui/setting.html | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/web/html/xui/setting.html b/web/html/xui/setting.html index 54d54d72..dba8e14c 100644 --- a/web/html/xui/setting.html +++ b/web/html/xui/setting.html @@ -196,6 +196,7 @@ const app = new Vue({ google: ["geoip:google"], cn: ["geoip:cn"], ir: ["geoip:ir"], + ru: ["geoip:ru"], }, domains: { ads: [ @@ -210,30 +211,13 @@ const app = new Vue({ spotify: ["geosite:spotify"], netflix: ["geosite:netflix"], cn: ["geosite:cn"], + ru: ["geosite:category-ru-gov"], ir: [ "regexp:.*\\.ir$", "ext:iran.dat:ir", "ext:iran.dat:other", - "geosite:category-ir", - "bank", - "tapsi", - "snapp", - "blogfa", - "digikala", - "Torob.com", - "sheypoor.com", - "Tgju.org", - "sb24.com", - "tebyan.net", - "beytoote.com", - "telewebion.com", - "Film2movie.ws", - "Setare.com", - "Filimo.com", - "downloadha.com", - "P30download.com", - "Sarzamindownload.com", - "Sanjesh.org" + "ext:iran.dat:ads", + "geosite:category-ir" ] }, } From 04f1d55425a6810705b7102c0e9a2a9d1e458357 Mon Sep 17 00:00:00 2001 From: Hamidreza Ghavami Date: Tue, 18 Apr 2023 21:23:51 +0430 Subject: [PATCH 17/19] add reset default config function --- web/html/xui/setting.html | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/web/html/xui/setting.html b/web/html/xui/setting.html index dba8e14c..b7869c66 100644 --- a/web/html/xui/setting.html +++ b/web/html/xui/setting.html @@ -271,6 +271,15 @@ const app = new Vue({ location.reload(); } }, + async resetXrayConfigToDefault() { + this.loading(true); + const msg = await HttpUtil.get("/xui/setting/getDefaultJsonConfig"); + this.loading(false); + if (msg.success) { + this.templateSettings = JSON.parse(JSON.stringify(msg.obj, null, 2)); + this.saveBtnDisable = true; + } + }, checkRequiredOutbounds() { const newTemplateSettings = this.templateSettings; const haveIPv4Outbounds = newTemplateSettings.outbounds.some((o) => o?.tag === "IPv4"); From 850bfa58c9822a982db265d109a74ca5b7ffe678 Mon Sep 17 00:00:00 2001 From: Hamidreza Ghavami Date: Tue, 18 Apr 2023 21:24:32 +0430 Subject: [PATCH 18/19] update ui of setting.html + add russia setting --- web/html/xui/setting.html | 90 ++++++++++++++++++++++++++++++--------- 1 file changed, 70 insertions(+), 20 deletions(-) diff --git a/web/html/xui/setting.html b/web/html/xui/setting.html index b7869c66..e10737e0 100644 --- a/web/html/xui/setting.html +++ b/web/html/xui/setting.html @@ -95,25 +95,40 @@ - {{ i18n "pages.setting.generalConfigs"}} - - - - - {{ i18n "pages.setting.countryConfigs"}} - - - - - {{ i18n "pages.setting.ipv4Configs"}} - - - {{ i18n "pages.setting.warpConfigs"}} - - - - - + {{ i18n "pages.setting.actions"}} + + {{ i18n "pages.setting.resetDefaultConfig" }} + + + {{ i18n "pages.setting.basicTemplate"}} + + + + + + + + + + + + + + + + + + + + + + + + + + + + {{ i18n "pages.setting.advancedTemplate"}} @@ -126,6 +141,7 @@ + {{ i18n "pages.setting.completeTemplate"}} @@ -157,7 +173,7 @@ {{template "component/setting"}}