From d8fb83b1f2582c7410b31d2d5813c9639d824ad4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Apr 2023 10:08:20 +0000 Subject: [PATCH 01/46] Bump actions/checkout from 3.5.1 to 3.5.2 Bumps [actions/checkout](https://github.com/actions/checkout) from 3.5.1 to 3.5.2. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v3.5.1...v3.5.2) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5938007f..083180ff 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,7 +10,7 @@ jobs: name: build x-ui amd64 version runs-on: ubuntu-20.04 steps: - - uses: actions/checkout@v3.5.1 + - uses: actions/checkout@v3.5.2 - name: Set up Go uses: actions/setup-go@v4.0.0 with: @@ -50,7 +50,7 @@ jobs: name: build x-ui arm64 version runs-on: ubuntu-20.04 steps: - - uses: actions/checkout@v3.5.1 + - uses: actions/checkout@v3.5.2 - name: Set up Go uses: actions/setup-go@v4.0.0 with: From e13015a9202be83c79e125fb4c6d9cfed7441272 Mon Sep 17 00:00:00 2001 From: Hamidreza Ghavami Date: Tue, 18 Apr 2023 10:16:10 +0430 Subject: [PATCH 02/46] 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 40a029749929bcd53ff9b5a7776cda96dc3aed86 Mon Sep 17 00:00:00 2001 From: Hamidreza Ghavami Date: Tue, 18 Apr 2023 10:16:43 +0430 Subject: [PATCH 03/46] 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 3e5984930ed24261c1cc459d11909a053dce18f3 Mon Sep 17 00:00:00 2001 From: Hamidreza Ghavami Date: Tue, 18 Apr 2023 10:21:21 +0430 Subject: [PATCH 04/46] 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 936f2e6ec2c0380ce3c1b8cd93835383741f5452 Mon Sep 17 00:00:00 2001 From: Hamidreza Ghavami Date: Tue, 18 Apr 2023 10:22:04 +0430 Subject: [PATCH 05/46] 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 4af626bb4b92570032a68e55ece7cb208821fa9f Mon Sep 17 00:00:00 2001 From: Hamidreza Ghavami Date: Tue, 18 Apr 2023 11:21:12 +0430 Subject: [PATCH 06/46] 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 672fd1da196d94a5ca15cae65ea9572843dc4aa8 Mon Sep 17 00:00:00 2001 From: Hamidreza Ghavami Date: Tue, 18 Apr 2023 11:26:51 +0430 Subject: [PATCH 10/46] 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 44cede41fdc1bfe35008996eb26c197efd62d879 Mon Sep 17 00:00:00 2001 From: Hamidreza Ghavami Date: Tue, 18 Apr 2023 11:31:52 +0430 Subject: [PATCH 11/46] 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 e4afbcea3ba18f6374b068cadb7f0285da4893eb Mon Sep 17 00:00:00 2001 From: Hamidreza Ghavami Date: Tue, 18 Apr 2023 11:33:55 +0430 Subject: [PATCH 12/46] 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 c4c266205b6cb7c94c7633fd21e2660e79ce460a Mon Sep 17 00:00:00 2001 From: Ho3ein Date: Tue, 18 Apr 2023 13:34:09 +0330 Subject: [PATCH 13/46] buy me a coffee --- README.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8c3bb5c8..c6fdf66e 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,8 @@ > **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: + xray panel supporting multi-protocol, **Multi-lang (English,Farsi,Chinese)** # Install & Upgrade @@ -27,7 +29,7 @@ certbot certonly --standalone --agree-tos --register-unsafely-without-email -d y certbot renew --dry-run ``` -**If you think this project is helpful to you, you may wish to give a** :star2: + # Default settings @@ -132,6 +134,13 @@ Reference syntax: - CentOS 8+ - Fedora 36+ +# Buy Me a Coffee + +[![](https://img.shields.io/badge/Wallet-USDT__TRC20-green.svg)](#) +``` +TXncxkvhkDWGts487Pjqq1qT9JmwRUz8CC +``` + # Pictures ![1](./media/1.png) From 9f85ec72a82c88fcad56a13d790c79cfe16c2a70 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 18 Apr 2023 10:04:51 +0000 Subject: [PATCH 14/46] Bump github.com/xtls/xray-core from 1.8.0 to 1.8.1 Bumps [github.com/xtls/xray-core](https://github.com/xtls/xray-core) from 1.8.0 to 1.8.1. - [Release notes](https://github.com/xtls/xray-core/releases) - [Commits](https://github.com/xtls/xray-core/compare/v1.8.0...v1.8.1) --- updated-dependencies: - dependency-name: github.com/xtls/xray-core dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 33 +++++++++++++++++---------------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/go.mod b/go.mod index b3f9ac32..160020a0 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/pelletier/go-toml/v2 v2.0.7 github.com/robfig/cron/v3 v3.0.1 github.com/shirou/gopsutil/v3 v3.23.3 - github.com/xtls/xray-core v1.8.0 + github.com/xtls/xray-core v1.8.1 go.uber.org/atomic v1.10.0 golang.org/x/text v0.9.0 google.golang.org/grpc v1.54.0 diff --git a/go.sum b/go.sum index 1dcdc37d..1a3c1f94 100644 --- a/go.sum +++ b/go.sum @@ -19,6 +19,7 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dgryski/go-metro v0.0.0-20211217172704-adc40b04c140 h1:y7y0Oa6UawqTFPCDw9JG6pdKt4F9pAhHv0B7FMGaGD0= github.com/francoispqt/gojay v1.2.13 h1:d2m3sFjloqoIUQU3TsHBgj6qg/BVGlTBeHDUmyJnXKk= +github.com/gaukas/godicttls v0.0.3 h1:YNDIf0d9adcxOijiLrEzpfZGAkNwLRzPaG6OjU7EITk= github.com/ghodss/yaml v1.0.1-0.20220118164431-d8423dcdf344 h1:Arcl6UOIS/kgO2nW3A65HN+7CMjSDP/gofXL4CZt1V4= github.com/gin-contrib/sessions v0.0.4 h1:gq4fNa1Zmp564iHP5G6EBuktilEos8VKhe2sza1KMgo= github.com/gin-contrib/sessions v0.0.4/go.mod h1:pQ3sIyviBBGcxgyR8mkeJuXbeV3h3NYmhJADQTq5+Vo= @@ -43,7 +44,7 @@ github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91 github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn9GlaMV7XkbRSipzJ0Ii4= github.com/go-playground/validator/v10 v10.12.0 h1:E4gtWgxWxp8YSxExrQFv5BpCahla0PVF2oTTEYaWQGI= github.com/go-playground/validator/v10 v10.12.0/go.mod h1:hCAPuzYvKdP33pxWa+2+6AIKXEKqjIUyqsNCtbsSJrA= -github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 h1:p104kn46Q8WdvHunIJ9dAyjPVtrBPhSr3KT2yUst43I= +github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= github.com/go-telegram-bot-api/telegram-bot-api/v5 v5.5.1 h1:wG8n/XJQ07TmjbITcGiUaOtXxdrINDz1b0J1w0SzqDc= github.com/go-telegram-bot-api/telegram-bot-api/v5 v5.5.1/go.mod h1:A2S0CWkNylc2phvKXWBBdD3K0iGnDBGbzRpISP2zBl8= github.com/go-test/deep v1.0.7 h1:/VSMRlnY/JSyqxQUzQLKVMAskpY/NZKFA5j2P+0pP2M= @@ -61,7 +62,7 @@ github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/pprof v0.0.0-20230228050547-1710fef4ab10 h1:CqYfpuYIjnlNxM3msdyPRKabhXZWbKjf3Q8BWROFBso= +github.com/google/pprof v0.0.0-20230406165453-00490a63f317 h1:hFhpt7CTmR3DX+b4R19ydQFtofxT0Sv3QsKNMVQYTMQ= github.com/gorilla/context v1.1.1 h1:AWwleXJkX/nhcU9bZSnZoi3h/qGYqQAGhq6zZe/aQW8= github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= github.com/gorilla/securecookie v1.1.1 h1:miw7JPhV+b/lAHSXz4qd/nN9jRiAFV5FwjeKyCS8BvQ= @@ -79,7 +80,7 @@ github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/u github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/kidstuff/mongostore v0.0.0-20181113001930-e650cd85ee4b/go.mod h1:g2nVr8KZVXJSS97Jo8pJ0jgq29P6H7dG0oplUA86MQw= -github.com/klauspost/compress v1.16.0 h1:iULayQNOReoYUe+1qtKOqw9CwJv3aNQu8ivo7lw1HU4= +github.com/klauspost/compress v1.16.5 h1:IFV2oUNUzZaz+XyusxpLzpzS8Pt5rh0Z16For/djlyI= github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= github.com/klauspost/cpuid/v2 v2.2.4 h1:acbojRNwl3o09bUq+yDCtZFc1aiwaAAxtcn8YkZXnvk= github.com/klauspost/cpuid/v2 v2.2.4/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY= @@ -97,7 +98,7 @@ github.com/mattn/go-sqlite3 v1.14.15/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S github.com/mattn/go-sqlite3 v1.14.16 h1:yOQRA0RpS5PFz/oikGwBEqvAWhWg5ufRz4ETLjwpU1Y= github.com/mattn/go-sqlite3 v1.14.16/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= github.com/memcachier/mc v2.0.1+incompatible/go.mod h1:7bkvFE61leUBvXz+yxsOnGBQSZpBSPIMUQSmmSHvuXc= -github.com/miekg/dns v1.1.51 h1:0+Xg7vObnhrz/4ZCZcZh7zPXlmU0aveS2HDBd0m0qSo= +github.com/miekg/dns v1.1.53 h1:ZBkuHr5dxHtB1caEOlZTLPo7D3L3TWckgUUs/RHfDxw= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -106,7 +107,7 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/nicksnyder/go-i18n/v2 v2.2.1 h1:aOzRCdwsJuoExfZhoiXHy4bjruwCMdt5otbYojM/PaA= github.com/nicksnyder/go-i18n/v2 v2.2.1/go.mod h1:fF2++lPHlo+/kPaj3nB0uxtPwzlPm+BlgwGX7MkeGj0= -github.com/onsi/ginkgo/v2 v2.9.0 h1:Tugw2BKlNHTMfG+CheOITkYvk4LAh6MFOvikhGVnhE8= +github.com/onsi/ginkgo/v2 v2.9.2 h1:BA2GMJOtfGAfagzYtrAlufIP0lq6QERkFmHLMLPwFSU= github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 h1:lDH9UUVJtmYCjyT0CI4q8xvlXPxeZ0gYCVvWbmPlp88= github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8= @@ -122,15 +123,15 @@ github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c/go.mod h1:Om github.com/power-devops/perfstat v0.0.0-20221212215047-62379fc7944b h1:0LFwY6Q3gMACTjAbMZBjXAqTOzOwFaj2Ld6cjeQ7Rig= github.com/power-devops/perfstat v0.0.0-20221212215047-62379fc7944b/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE= github.com/quasoft/memstore v0.0.0-20191010062613-2bce066d2b0b/go.mod h1:wTPjTepVu7uJBYgZ0SdWHQlIas582j6cn2jgk4DDdlg= -github.com/quic-go/qtls-go1-19 v0.2.1 h1:aJcKNMkH5ASEJB9FXNeZCyTEIHU1J7MmHyz1Q1TSG1A= -github.com/quic-go/qtls-go1-20 v0.1.1 h1:KbChDlg82d3IHqaj2bn6GfKRj84Per2VGf5XV3wSwQk= +github.com/quic-go/qtls-go1-19 v0.3.2 h1:tFxjCFcTQzK+oMxG6Zcvp4Dq8dx4yD3dDiIiyc86Z5U= +github.com/quic-go/qtls-go1-20 v0.2.2 h1:WLOPx6OY/hxtTxKV1Zrq20FtXtDEkeY00CGQm8GEa3E= github.com/quic-go/quic-go v0.33.0 h1:ItNoTDN/Fm/zBlq769lLJc8ECe9gYaW40veHCCco7y0= -github.com/refraction-networking/utls v1.2.3-0.20230308205431-4f1df6c200db h1:ULRv/GPW5KYDafE0FACN2no+HTCyQLUtfyOIeyp3GNc= +github.com/refraction-networking/utls v1.3.2 h1:o+AkWB57mkcoW36ET7uJ002CpBWHu0KPxi6vzxvPnv8= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 h1:f/FNXud6gA3MNr8meMVVGxhp+QBTqY91tM8HjEuMjGg= github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs= github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro= -github.com/sagernet/sing v0.1.7 h1:g4vjr3q8SUlBZSx97Emz5OBfSMBxxW5Q8C2PfdoSo08= -github.com/sagernet/sing-shadowsocks v0.1.1 h1:uFK2rlVeD/b1xhDwSMbUI2goWc6fOKxp+ZeKHZq6C9Q= +github.com/sagernet/sing v0.2.3 h1:V50MvZ4c3Iij2lYFWPlzL1PyipwSzjGeN9x+Ox89vpk= +github.com/sagernet/sing-shadowsocks v0.2.1 h1:FvdLQOqpvxHBJUcUe4fvgiYP2XLLwH5i1DtXQviVEPw= github.com/sagernet/wireguard-go v0.0.0-20221116151939-c99467f53f2c h1:vK2wyt9aWYHHvNLWniwijBu/n4pySypiKRhN32u/JGo= github.com/seiflotfy/cuckoofilter v0.0.0-20220411075957-e3b120b3f5fb h1:XfLJSPIOUX+osiMraVgIrMR27uMXnRJWGm1+GL8/63U= github.com/shirou/gopsutil/v3 v3.23.3 h1:Syt5vVZXUDXPEXpIBt5ziWsJ4LdSAAxF4l/xZeQgSEE= @@ -164,9 +165,9 @@ github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLY github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU= github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e h1:5QefA066A1tF8gHIiADmOVOV5LS43gt3ONnlEl3xkwI= -github.com/xtls/reality v0.0.0-20230309125256-0d0713b108c8 h1:LLtLxEe3S0Ko+ckqt4t29RLskpNdOZfgjZCC2/Byr50= -github.com/xtls/xray-core v1.8.0 h1:/OD0sDv6YIBqvE+cVfnqlKrtbMs0Fm9IP5BR5d8Eu4k= -github.com/xtls/xray-core v1.8.0/go.mod h1:i9KWgbLyxg/NT+3+g4nE74Zp3DgTCP3X04YkSfsJeDI= +github.com/xtls/reality v0.0.0-20230331223127-176a94313eda h1:psRJD2RrZbnI0OWyHvXfgYCPqlRM5q5SPDcjDoDBWhE= +github.com/xtls/xray-core v1.8.1 h1:iSTTqXj82ZdwC1ah+eV331X4JTcnrDz+WuKuB/EB3P4= +github.com/xtls/xray-core v1.8.1/go.mod h1:AXxSso0MZwUE4NhRocCfHCg73BtJ+T2dSpQVo1Cg9VM= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/yusufpapurcu/wmi v1.2.2 h1:KBNDSne4vP5mbSWnJbO+51IMOXJB67QiYCSBrubbPRg= @@ -183,10 +184,10 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.8.0 h1:pd9TJtTueMTVQXzk8E2XESSMQDj/U7OUu0PqJqPXQjQ= golang.org/x/crypto v0.8.0/go.mod h1:mRqEX+O9/h5TFCrQhkgjo2yKi0yYA+9ecGkdQoHrywE= -golang.org/x/exp v0.0.0-20230307190834-24139beb5833 h1:SChBja7BCQewoTAU7IgvucQKMIXrEpFxNMs0spT3/5s= +golang.org/x/exp v0.0.0-20230321023759-10a507213a29 h1:ooxPy7fPvB4kwsA2h+iBNHkAbp/4JxTSwCmvdjEYmug= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.9.0 h1:KENHtAZL2y3NLMYZeHY9DW8HW8V+kQyJsY/V9JlKvCs= +golang.org/x/mod v0.10.0 h1:lFO9qtOdlre5W1jxS3r/4szv2/6iXxScdzjoBMXNhYk= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= @@ -227,7 +228,7 @@ golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGm golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20201022035929-9cf592e881e9/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.7.0 h1:W4OVu8VVOaIO0yzWMNdepAulS7YfoS3Zabrm8DOXXU4= +golang.org/x/tools v0.8.0 h1:vSDcovVPld282ceKgDimkRSC8kpaH1dgyc9UMzlt84Y= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= From c71041a60d1f5b2b9e541e54227040ff4fc2ef06 Mon Sep 17 00:00:00 2001 From: Hamidreza Ghavami Date: Tue, 18 Apr 2023 21:19:25 +0430 Subject: [PATCH 15/46] 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 8b79b5a315641293c4fb569816fd711d9572fffa Mon Sep 17 00:00:00 2001 From: Hamidreza Ghavami Date: Tue, 18 Apr 2023 21:20:28 +0430 Subject: [PATCH 16/46] 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 846efe8eb4f25a6cd34b9c1bf0adcc5df89fa6ed Mon Sep 17 00:00:00 2001 From: Hamidreza Ghavami Date: Tue, 18 Apr 2023 21:21:09 +0430 Subject: [PATCH 17/46] 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 dfdb77c49112fb7455e93b6b2800a8309e6b249a Mon Sep 17 00:00:00 2001 From: Hamidreza Ghavami Date: Tue, 18 Apr 2023 21:21:37 +0430 Subject: [PATCH 18/46] 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 72a1b1e3f33cbe96c313f4f1da3ad771195c2a26 Mon Sep 17 00:00:00 2001 From: Hamidreza Ghavami Date: Tue, 18 Apr 2023 21:23:12 +0430 Subject: [PATCH 19/46] 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 f26a7df11b9b3455e461b7d5ca7a51cf4ca0a838 Mon Sep 17 00:00:00 2001 From: Hamidreza Ghavami Date: Tue, 18 Apr 2023 21:23:51 +0430 Subject: [PATCH 20/46] 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 e0e7c102b8564bbc4483aa58737ff8547070fe0d Mon Sep 17 00:00:00 2001 From: Hamidreza Ghavami Date: Tue, 18 Apr 2023 21:24:32 +0430 Subject: [PATCH 21/46] 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"}} diff --git a/web/html/xui/form/client.html b/web/html/xui/form/client.html index 2d8c5d2b..330a20c1 100644 --- a/web/html/xui/form/client.html +++ b/web/html/xui/form/client.html @@ -98,6 +98,10 @@ [[ sizeFormat(clientStats.down) ]] ([[ sizeFormat(clientStats.up + clientStats.down) ]]) + + + + From 81838b504c0f445f9a0daff32a394bd0a149922b Mon Sep 17 00:00:00 2001 From: Hamidreza Ghavami Date: Fri, 21 Apr 2023 02:14:00 +0430 Subject: [PATCH 41/46] update iran.dat from xray zip --- web/service/server.go | 4 ++++ xray/process.go | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/web/service/server.go b/web/service/server.go index f2540252..1108926b 100644 --- a/web/service/server.go +++ b/web/service/server.go @@ -323,6 +323,10 @@ func (s *ServerService) UpdateXray(version string) error { if err != nil { return err } + err = copyZipFile("iran.dat", xray.GetIranPath()) + if err != nil { + return err + } return nil diff --git a/xray/process.go b/xray/process.go index 35907391..e7774ea4 100644 --- a/xray/process.go +++ b/xray/process.go @@ -45,6 +45,10 @@ func GetGeoipPath() string { return config.GetBinFolderPath() + "/geoip.dat" } +func GetIranPath() string { + return config.GetBinFolderPath() + "/iran.dat" +} + func GetBlockedIPsPath() string { return config.GetBinFolderPath() + "/blockedIPs" } From 513f87550af4a3a24b786145a14285e2d0323b6a Mon Sep 17 00:00:00 2001 From: Ehsan Soltani Azad <78851513+ehsaninuc@users.noreply.github.com> Date: Fri, 21 Apr 2023 01:41:03 +0330 Subject: [PATCH 42/46] Update translate.en_US.toml --- web/translation/translate.en_US.toml | 36 ++++++++++++++-------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/web/translation/translate.en_US.toml b/web/translation/translate.en_US.toml index 208a0c76..c5809442 100644 --- a/web/translation/translate.en_US.toml +++ b/web/translation/translate.en_US.toml @@ -26,7 +26,7 @@ "edit" = "Edit" "delete" = "Delete" "reset" = "Reset" -"copySuccess" = "Copy successfully" +"copySuccess" = "Copied successfully" "sure" = "Sure" "encryption" = "Encryption" "transmission" = "Transmission" @@ -40,7 +40,7 @@ "depletingSoon" = "Depleting soon" "domainName" = "Domain name" "additional" = "Alter" -"monitor" = "Listen IP" +"monitor" = "Listening IP" "certificate" = "Certificate" "fail" = "Fail" "success" = " Success" @@ -53,7 +53,7 @@ "dashboard" = "System Status" "inbounds" = "Inbounds" "setting" = "Panel Setting" -"logout" = "LogOut" +"logout" = "Logout" "link" = "Other" [pages.login] @@ -61,7 +61,7 @@ "loginAgain" = "The login time limit has expired, please log in again" [pages.login.toasts] -"invalidFormData" = "Input Data Format Is Invalid" +"invalidFormData" = "Input Data Format is Invalid" "emptyUsername" = "Please Enter Username" "emptyPassword" = "Please Enter Password" "wrongUsernameOrPassword" = "Invalid username or password" @@ -75,17 +75,17 @@ "stopXray" = "Stop" "restartXray" = "Restart" "xraySwitch" = "Switch Version" -"xraySwitchClick" = "Click on the version you want to switch" -"xraySwitchClickDesk" = "Please choose carefully, older versions may have incompatible configurations" +"xraySwitchClick" = "Choose the version you want to switch to." +"xraySwitchClickDesk" = "Choose wisely, as older versions may not be compatible with current configurations." "operationHours" = "Operation Hours" -"operationHoursDesc" = "The running time of the system since it was started" +"operationHoursDesc" = "System uptime: time since startup." "systemLoad" = "System Load" -"connectionCount" = "Connection Count" -"connectionCountDesc" = "The total number of connections for all network cards" +"connectionCount" = "Number of connections" +"connectionCountDesc" = "Total connections across all network cards" "upSpeed" = "Total upload speed for all network cards" "downSpeed" = "Total download speed for all network cards" "totalSent" = "Total upload traffic of all network cards since system startup" -"totalReceive" = "Total download traffic of all network cards since system startup" +"totalReceive" = "Total download data across all network cards since system startup" "xraySwitchVersionDialog" = "Switch xray version" "xraySwitchVersionDialogDesc" = "Whether to switch the xray version to" "dontRefreshh" = "Installation is in progress, please do not refresh this page" @@ -110,8 +110,8 @@ "revise" = "Update" "modifyInbound" = "Modify InBound" "deleteInbound" = "Delete Inbound" -"deleteInboundContent" = "Are you sure you want to delete inbound?" -"resetTrafficContent" = "Are you sure you want to reset traffic?" +"deleteInboundContent" = "Confirm deletion of inbound?" +"resetTrafficContent" = "Confirm traffic reset?" "copyLink" = "Copy Link" "address" = "Address" "network" = "Network" @@ -121,8 +121,8 @@ "monitorDesc" = "Leave blank by default" "meansNoLimit" = "Means no limit" "totalFlow" = "Total flow" -"leaveBlankToNeverExpire" = "Leave blank to never expire" -"noRecommendKeepDefault" = "There are no special requirements to keep the default" +"leaveBlankToNeverExpire" = "Leave blank to set no expiration" +"noRecommendKeepDefault" = "No special requirements to maintain default settings" "certificatePath" = "Certificate file path" "certificateContent" = "Certificate file content" "publicKeyPath" = "Public key path" @@ -134,7 +134,7 @@ "export" = "Export links" "Clone" = "Clone" "cloneInbound" = "Create" -"cloneInboundContent" = "All items of this inbound except Port, Listening IP, Clients will be applied to the clone" +"cloneInboundContent" = "All settings of this inbound, except for Port, Listening IP, and Clients, will be applied to the clone" "cloneInboundOk" = "Creating a clone from" "resetAllTraffic" = "Reset All Inbounds Traffic" "resetAllTrafficTitle" = "Reset all inbounds traffic" @@ -142,12 +142,12 @@ "resetAllTrafficOkText" = "Confirm" "resetAllTrafficCancelText" = "Cancel" "IPLimit" = "IP Limit" -"IPLimitDesc" = "disable inbound if more than entered count (0 for disable limit ip)" +"IPLimitDesc" = "Disable inbound if the count exceeds the entered value (Enter 0 to disable IP limit)" "resetAllClientTraffics" = "Reset Clients Traffic" "resetAllClientTrafficTitle" = "Reset all clients traffic" -"resetAllClientTrafficContent" = "Are you sure to reset all traffics of this inbound's clients ?" +"resetAllClientTrafficContent" = "Confirm reset of all traffic for clients of this inbound?" "Email" = "Email" -"EmailDesc" = "The Email Must Be Completely Unique" +"EmailDesc" = "Please provide a unique email address" "IPLimitlog" = "IP Log" "IPLimitlogDesc" = "IPs history Log (before enabling inbound after it has been disabled by IP limit, you should clear the log)" "IPLimitlogclear" = "Clear The Log" From b0f974a94db8508c7c77db18c89cd0ef3497f879 Mon Sep 17 00:00:00 2001 From: MHSanaei Date: Fri, 21 Apr 2023 19:00:14 +0330 Subject: [PATCH 43/46] secret token thanks to @HarlyquinForest --- database/db.go | 5 +- database/model/model.go | 7 +- install.sh | 39 ++++------ main.go | 22 ++++++ web/assets/js/model/models.js | 2 + web/controller/index.go | 21 ++++-- web/controller/setting.go | 28 ++++++++ web/entity/entity.go | 1 + web/html/login.html | 16 +++++ web/html/xui/setting.html | 98 ++++++++++++++++++++++---- web/service/setting.go | 17 ++++- web/service/user.go | 33 ++++++++- web/translation/translate.en_US.toml | 5 ++ web/translation/translate.fa_IR.toml | 5 ++ web/translation/translate.zh_Hans.toml | 5 ++ x-ui.sh | 77 ++++++++++++++++---- 16 files changed, 314 insertions(+), 67 deletions(-) diff --git a/database/db.go b/database/db.go index b9c16be8..ae42a6de 100644 --- a/database/db.go +++ b/database/db.go @@ -27,8 +27,9 @@ func initUser() error { } if count == 0 { user := &model.User{ - Username: "admin", - Password: "admin", + Username: "admin", + Password: "admin", + LoginSecret: "", } return db.Create(user).Error } diff --git a/database/model/model.go b/database/model/model.go index 778ad9b6..d1498b06 100644 --- a/database/model/model.go +++ b/database/model/model.go @@ -18,9 +18,10 @@ const ( ) type User struct { - Id int `json:"id" gorm:"primaryKey;autoIncrement"` - Username string `json:"username"` - Password string `json:"password"` + Id int `json:"id" gorm:"primaryKey;autoIncrement"` + Username string `json:"username"` + Password string `json:"password"` + LoginSecret string `json:"loginSecret"` } type Inbound struct { diff --git a/install.sh b/install.sh index 15226a08..df74a0cf 100644 --- a/install.sh +++ b/install.sh @@ -23,23 +23,14 @@ else fi echo "The OS release is: $release" -arch=$(arch) - -if [[ $arch == "x86_64" || $arch == "x64" || $arch == "amd64" ]]; then - arch="amd64" -elif [[ $arch == "aarch64" || $arch == "arm64" ]]; then - arch="arm64" -else - arch="amd64" - echo -e "${red} Failed to check system arch, will use default arch: ${arch}${plain}" -fi - -echo "arch: ${arch}" - -if [ $(getconf WORD_BIT) != '32' ] && [ $(getconf LONG_BIT) != '64' ]; then - echo "x-ui dosen't support 32-bit(x86) system, please use 64 bit operating system(x86_64) instead, if there is something wrong, please get in touch with me!" - exit -1 -fi +arch3xui() { + case "$(uname -m)" in + x86_64 | x64 | amd64 ) echo 'amd64' ;; + armv8 | arm64 | aarch64 ) echo 'arm64' ;; + * ) echo -e "${green}Unsupported CPU architecture! ${plain}" && rm -f install.sh && exit 1 ;; + esac +} +echo "arch: $(arch3xui)" os_version="" os_version=$(grep -i version_id /etc/os-release | cut -d \" -f2 | cut -d . -f1) @@ -122,18 +113,18 @@ install_x-ui() { exit 1 fi echo -e "Got x-ui latest version: ${last_version}, beginning the installation..." - wget -N --no-check-certificate -O /usr/local/x-ui-linux-${arch}.tar.gz https://github.com/MHSanaei/3x-ui/releases/download/${last_version}/x-ui-linux-${arch}.tar.gz + wget -N --no-check-certificate -O /usr/local/x-ui-linux-$(arch3xui).tar.gz https://github.com/MHSanaei/3x-ui/releases/download/${last_version}/x-ui-linux-$(arch3xui).tar.gz if [[ $? -ne 0 ]]; then echo -e "${red}Downloading x-ui failed, please be sure that your server can access Github ${plain}" exit 1 fi else last_version=$1 - url="https://github.com/MHSanaei/3x-ui/releases/download/${last_version}/x-ui-linux-${arch}.tar.gz" + url="https://github.com/MHSanaei/3x-ui/releases/download/${last_version}/x-ui-linux-$(arch3xui).tar.gz" echo -e "Begining to install x-ui $1" - wget -N --no-check-certificate -O /usr/local/x-ui-linux-${arch}.tar.gz ${url} + wget -N --no-check-certificate -O /usr/local/x-ui-linux-$(arch3xui).tar.gz ${url} if [[ $? -ne 0 ]]; then - echo -e "${red}Download x-ui $1 failed,please check the version exists${plain}" + echo -e "${red}Download x-ui $1 failed,please check the version exists ${plain}" exit 1 fi fi @@ -142,10 +133,10 @@ install_x-ui() { rm /usr/local/x-ui/ -rf fi - tar zxvf x-ui-linux-${arch}.tar.gz - rm x-ui-linux-${arch}.tar.gz -f + tar zxvf x-ui-linux-$(arch3xui).tar.gz + rm x-ui-linux-$(arch3xui).tar.gz -f cd x-ui - chmod +x x-ui bin/xray-linux-${arch} + chmod +x x-ui bin/xray-linux-$(arch3xui) cp -f x-ui.service /etc/systemd/system/ wget --no-check-certificate -O /usr/bin/x-ui https://raw.githubusercontent.com/MHSanaei/3x-ui/main/x-ui.sh chmod +x /usr/local/x-ui/x-ui.sh diff --git a/main.go b/main.go index e41546ec..710b80d4 100644 --- a/main.go +++ b/main.go @@ -204,6 +204,24 @@ func updateSetting(port int, username string, password string) { } } +func removeSecret() { + err := database.InitDB(config.GetDBPath()) + if err != nil { + fmt.Println(err) + return + } + userService := service.UserService{} + err = userService.RemoveUserSecret() + if err != nil { + fmt.Println(err) + } + settingService := service.SettingService{} + err = settingService.SetSecretStatus(false) + if err != nil { + fmt.Println(err) + } +} + func main() { if len(os.Args) < 2 { runWebServer() @@ -229,6 +247,7 @@ func main() { var tgbotRuntime string var reset bool var show bool + var remove_secret bool settingCmd.BoolVar(&reset, "reset", false, "reset all settings") settingCmd.BoolVar(&show, "show", false, "show current settings") settingCmd.IntVar(&port, "port", 0, "set panel port") @@ -290,6 +309,9 @@ func main() { if (tgbottoken != "") || (tgbotchatid != "") || (tgbotRuntime != "") { updateTgbotSetting(tgbottoken, tgbotchatid, tgbotRuntime) } + if remove_secret { + removeSecret() + } if enabletgbot { updateTgbotEnableSts(enabletgbot) } diff --git a/web/assets/js/model/models.js b/web/assets/js/model/models.js index 1de76850..ace99f48 100644 --- a/web/assets/js/model/models.js +++ b/web/assets/js/model/models.js @@ -3,6 +3,7 @@ class User { constructor() { this.username = ""; this.password = ""; + this.LoginSecret = ""; } } @@ -180,6 +181,7 @@ class AllSetting { this.tgBotBackup = false; this.tgCpu = ""; this.xrayTemplateConfig = ""; + this.secretEnable = false; this.timeLocation = "Asia/Tehran"; diff --git a/web/controller/index.go b/web/controller/index.go index b4f981e8..c19ee799 100644 --- a/web/controller/index.go +++ b/web/controller/index.go @@ -11,15 +11,17 @@ import ( ) type LoginForm struct { - Username string `json:"username" form:"username"` - Password string `json:"password" form:"password"` + Username string `json:"username" form:"username"` + Password string `json:"password" form:"password"` + LoginSecret string `json:"loginSecret" form:"loginSecret"` } type IndexController struct { BaseController - userService service.UserService - tgbot service.Tgbot + settingService service.SettingService + userService service.UserService + tgbot service.Tgbot } func NewIndexController(g *gin.RouterGroup) *IndexController { @@ -32,6 +34,7 @@ func (a *IndexController) initRouter(g *gin.RouterGroup) { g.GET("/", a.index) g.POST("/login", a.login) g.GET("/logout", a.logout) + g.POST("/getSecretStatus", a.getSecretStatus) } func (a *IndexController) index(c *gin.Context) { @@ -57,7 +60,7 @@ func (a *IndexController) login(c *gin.Context) { pureJsonMsg(c, false, I18n(c, "pages.login.toasts.emptyPassword")) return } - user := a.userService.CheckUser(form.Username, form.Password) + user := a.userService.CheckUser(form.Username, form.Password, form.LoginSecret) timeStr := time.Now().Format("2006-01-02 15:04:05") if user == nil { a.tgbot.UserLoginNotify(form.Username, getRemoteIp(c), timeStr, 0) @@ -82,3 +85,11 @@ func (a *IndexController) logout(c *gin.Context) { session.ClearSession(c) c.Redirect(http.StatusTemporaryRedirect, c.GetString("base_path")) } + +func (a *IndexController) getSecretStatus(c *gin.Context) { + status, err := a.settingService.GetSecretStatus() + if err == nil { + jsonObj(c, status, nil) + } + +} diff --git a/web/controller/setting.go b/web/controller/setting.go index 1de55ab6..2726c228 100644 --- a/web/controller/setting.go +++ b/web/controller/setting.go @@ -17,6 +17,10 @@ type updateUserForm struct { NewPassword string `json:"newPassword" form:"newPassword"` } +type updateSecretForm struct { + LoginSecret string `json:"loginSecret" form:"loginSecret"` +} + type SettingController struct { settingService service.SettingService userService service.UserService @@ -38,6 +42,8 @@ func (a *SettingController) initRouter(g *gin.RouterGroup) { g.POST("/updateUser", a.updateUser) g.POST("/restartPanel", a.restartPanel) g.GET("/getDefaultJsonConfig", a.getDefaultJsonConfig) + g.POST("/updateUserSecret", a.updateSecret) + g.POST("/getUserSecret", a.getUserSecret) } func (a *SettingController) getAllSetting(c *gin.Context) { @@ -128,3 +134,25 @@ func (a *SettingController) restartPanel(c *gin.Context) { err := a.panelService.RestartPanel(time.Second * 3) jsonMsg(c, I18n(c, "pages.setting.restartPanel"), err) } + +func (a *SettingController) updateSecret(c *gin.Context) { + form := &updateSecretForm{} + err := c.ShouldBind(form) + if err != nil { + jsonMsg(c, I18n(c, "pages.setting.toasts.modifySetting"), err) + } + user := session.GetLoginUser(c) + err = a.userService.UpdateUserSecret(user.Id, form.LoginSecret) + if err == nil { + user.LoginSecret = form.LoginSecret + session.SetLoginUser(c, user) + } + jsonMsg(c, I18n(c, "pages.setting.toasts.modifyUser"), err) +} +func (a *SettingController) getUserSecret(c *gin.Context) { + loginUser := session.GetLoginUser(c) + user := a.userService.GetUserSecret(loginUser.Id) + if user != nil { + jsonObj(c, user, nil) + } +} diff --git a/web/entity/entity.go b/web/entity/entity.go index b464de00..f1b24520 100644 --- a/web/entity/entity.go +++ b/web/entity/entity.go @@ -42,6 +42,7 @@ type AllSetting struct { TgCpu int `json:"tgCpu" form:"tgCpu"` XrayTemplateConfig string `json:"xrayTemplateConfig" form:"xrayTemplateConfig"` TimeLocation string `json:"timeLocation" form:"timeLocation"` + SecretEnable bool `json:"secretEnable" form:"secretEnable"` } func (s *AllSetting) CheckValid() error { diff --git a/web/html/login.html b/web/html/login.html index 4218793c..2f4cb3e6 100644 --- a/web/html/login.html +++ b/web/html/login.html @@ -57,6 +57,11 @@ + + + + + {{ i18n "login" }} @@ -98,10 +103,12 @@ data: { loading: false, user: new User(), + secretEnable: false, lang : "" }, created(){ this.lang = getLang(); + this.secretEnable = this.getSecretStatus(); }, methods: { async login() { @@ -111,6 +118,15 @@ if (msg.success) { location.href = basePath + 'xui/'; } + }, + async getSecretStatus() { + this.loading= true; + const msg = await HttpUtil.post('/getSecretStatus'); + this.loading = false; + if (msg.success){ + this.secretEnable = msg.obj; + return msg.obj; + } } } }); diff --git a/web/html/xui/setting.html b/web/html/xui/setting.html index eaaf8b25..db318ee4 100644 --- a/web/html/xui/setting.html +++ b/web/html/xui/setting.html @@ -91,8 +91,39 @@ {{ i18n "confirm" }} + + + + + + + + + + + + + + + + + + + + + + + + + {{ i18n "confirm" }} + - {{ i18n "pages.setting.actions"}} @@ -205,7 +236,7 @@ oldAllSetting: new AllSetting(), allSetting: new AllSetting(), saveBtnDisable: true, - user: {}, + user: new User(), lang: getLang(), ipv4Settings: { tag: "IPv4", @@ -262,31 +293,33 @@ } }, methods: { - loading(spinning = true) { - this.spinning = spinning; + loading(spinning = true , obj) { + if(obj == null) + this.spinning = spinning; }, async getAllSetting() { - this.loading(true); + this.loading(true,{}); const msg = await HttpUtil.post("/xui/setting/all"); - this.loading(false); + this.loading(false,null); if (msg.success) { this.oldAllSetting = new AllSetting(msg.obj); this.allSetting = new AllSetting(msg.obj); this.saveBtnDisable = true; } + await this.getUserSecret(); }, async updateAllSetting() { - this.loading(true); + this.loading(true,{}); const msg = await HttpUtil.post("/xui/setting/update", this.allSetting); - this.loading(false); + this.loading(false,null); if (msg.success) { await this.getAllSetting(); } }, async updateUser() { - this.loading(true); + this.loading(true,{}); const msg = await HttpUtil.post("/xui/setting/updateUser", this.user); - this.loading(false); + this.loading(false,null); if (msg.success) { this.user = {}; } @@ -301,19 +334,54 @@ onOk: () => resolve(), }); }); - this.loading(true); + this.loading(true,{}); const msg = await HttpUtil.post("/xui/setting/restartPanel"); - this.loading(false); + this.loading(false,null); if (msg.success) { - this.loading(true); + this.loading(true,{}); await PromiseUtil.sleep(5000); location.reload(); } }, + async getUserSecret(){ + const user_msg = await HttpUtil.post("/xui/setting/getUserSecret", this.user); + if (user_msg.success){ + this.user = user_msg.obj; + } + this.loading(false); + }, + async updateSecret(){ + this.loading(true,{}); + const msg = await HttpUtil.post("/xui/setting/updateUserSecret", this.user); + if (msg.success){ + this.user = msg.obj; + } + this.loading(false,null); + await this.updateAllSetting(); + }, + async getNewSecret(){ + this.loading(true,{}); + await PromiseUtil.sleep(1000); + var chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'; + var string = ''; + var len = 64; + for(var ii=0; ii 1 ]]; then echo && read -p "$1 [Default$2]: " temp @@ -98,18 +106,49 @@ install() { } update() { - confirm "This function will forcefully reinstall the latest version, and the data will not be lost. Do you want to continue?" "n" - if [[ $? != 0 ]]; then - LOGE "Cancelled" - if [[ $# == 0 ]]; then - before_show_menu + read -rp "This function will update the X-UI panel to the latest version. Data will not be lost. Whether to continues? [Y/N]: " yn + if [[ $yn =~ "Y"|"y" ]]; then + systemctl stop x-ui + if [[ -e /usr/local/x-ui/ ]]; then + cd + rm -rf /usr/local/x-ui/ fi - return 0 - fi - bash <(curl -Ls https://raw.githubusercontent.com/MHSanaei/3x-ui/main/install.sh) - if [[ $? == 0 ]]; then - LOGI "Update is complete, Panel has automatically restarted " - exit 0 + + last_version=$(curl -Ls "https://api.github.com/repos/MHSanaei/3x-ui/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/') || last_version=$(curl -sm8 https://raw.githubusercontent.com/MHSanaei/3x-ui/main/config/version) + if [[ -z "$last_version" ]]; then + echo -e "${red}Detecting the X-UI version failed, please make sure your server can connect to the GitHub API ${plain}" + exit 1 + fi + + echo -e "${yellow}The latest version of X-UI is: ${last_version}, starting update...${plain}" + wget -N --no-check-certificate -O /usr/local/x-ui-linux-$(arch3xui).tar.gz https://github.com/MHSanaei/3x-ui/releases/download/${last_version}/x-ui-linux-$(arch3xui).tar.gz + if [[ $? -ne 0 ]]; then + echo -e "${red}Download the X-UI failure, please make sure your server can connect and download the files from github ${plain}" + exit 1 + fi + + cd /usr/local/ + tar zxvf x-ui-linux-$(arch3xui).tar.gz + rm -f x-ui-linux-$(arch3xui).tar.gz + + cd x-ui + chmod +x x-ui bin/xray-linux-$(arch3xui) + cp -f x-ui.service /etc/systemd/system/ + + wget -N --no-check-certificate https://raw.githubusercontent.com/MHSanaei/3x-ui/main/x-ui.sh -O /usr/bin/x-ui + chmod +x /usr/local/x-ui/x-ui.sh + chmod +x /usr/bin/x-ui + + systemctl daemon-reload + systemctl enable x-ui >/dev/null 2>&1 + systemctl start x-ui + systemctl restart x-ui + + echo -e "${green}The update is completed, and the X-UI panel has been automatically restarted ${plain}" + exit 1 + else + echo -e "${red}The upgrade X-UI panel has been canceled! ${plain}" + exit 1 fi } @@ -139,15 +178,23 @@ uninstall() { } reset_user() { - confirm "Reset your username and password to admin?" "n" + confirm "Are you sure to reset the username and password of the panel?" "n" if [[ $? != 0 ]]; then if [[ $# == 0 ]]; then show_menu fi 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." + read -rp "Please set the login username [default is a random username]: " config_account + [[ -z $config_account ]] && config_account=$(date +%s%N | md5sum | cut -c 1-8) + read -rp "Please set the login password [default is a random password]: " config_password + [[ -z $config_password ]] && config_password=$(date +%s%N | md5sum | cut -c 1-8) + /usr/local/x-ui/x-ui setting -username ${config_account} -password ${config_password} >/dev/null 2>&1 + /usr/local/x-ui/x-ui setting -remove_secret >/dev/null 2>&1 + echo -e "Panel login username has been reset to: ${green} ${config_account} ${plain}" + echo -e "Panel login password has been reset to: ${green} ${config_password} ${plain}" + echo -e "${yellow} Panel login secret token disabled ${plain}" + echo -e "${green} Please use the new login username and password to access the X-UI panel. Also remember them! ${plain}" confirm_restart } @@ -781,7 +828,7 @@ show_menu() { ${green}2.${plain} Update x-ui ${green}3.${plain} Uninstall x-ui ———————————————— - ${green}4.${plain} Reset Username And Password + ${green}4.${plain} Reset Username & Password & Secret Token ${green}5.${plain} Reset Panel Settings ${green}6.${plain} Change Panel Port ${green}7.${plain} View Current Panel Settings From 55f7fcd1b3620e6903eb65c17caa79243bf9ff5d Mon Sep 17 00:00:00 2001 From: MHSanaei Date: Fri, 21 Apr 2023 19:03:23 +0330 Subject: [PATCH 44/46] typo thanks to @firefoxOnFire --- x-ui.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-ui.sh b/x-ui.sh index 8e93d62e..bde6eefb 100644 --- a/x-ui.sh +++ b/x-ui.sh @@ -66,7 +66,7 @@ arch3xui() { confirm() { if [[ $# > 1 ]]; then - echo && read -p "$1 [Default$2]: " temp + echo && read -p "$1 [Default $2]: " temp if [[ x"${temp}" == x"" ]]; then temp=$2 fi From f817f922fe9a2be5da907e368366f1f9a2977b6e Mon Sep 17 00:00:00 2001 From: MHSanaei Date: Fri, 21 Apr 2023 19:06:59 +0330 Subject: [PATCH 45/46] add getClientTraffics api Co-Authored-By: Alireza Ahmadi --- web/controller/api.go | 4 ++++ web/controller/inbound.go | 10 ++++++++++ web/service/inbound.go | 2 +- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/web/controller/api.go b/web/controller/api.go index c64b27bf..c8ad2a67 100644 --- a/web/controller/api.go +++ b/web/controller/api.go @@ -19,6 +19,7 @@ func (a *APIController) initRouter(g *gin.RouterGroup) { g.GET("/list", a.getAllInbounds) g.GET("/get/:id", a.getSingleInbound) + g.GET("/getClientTraffics/:email", a.getClientTraffics) g.POST("/add", a.addInbound) g.POST("/del/:id", a.delInbound) g.POST("/update/:id", a.updateInbound) @@ -39,6 +40,9 @@ func (a *APIController) getAllInbounds(c *gin.Context) { func (a *APIController) getSingleInbound(c *gin.Context) { a.inboundController.getInbound(c) } +func (a *APIController) getClientTraffics(c *gin.Context) { + a.inboundController.getClientTraffics(c) +} func (a *APIController) addInbound(c *gin.Context) { a.inboundController.addInbound(c) } diff --git a/web/controller/inbound.go b/web/controller/inbound.go index 8e385248..f32cb766 100644 --- a/web/controller/inbound.go +++ b/web/controller/inbound.go @@ -78,6 +78,16 @@ func (a *InboundController) getInbound(c *gin.Context) { jsonObj(c, inbound, nil) } +func (a *InboundController) getClientTraffics(c *gin.Context) { + email := c.Param("email") + clientTraffics, err := a.inboundService.GetClientTrafficByEmail(email) + if err != nil { + jsonMsg(c, "Error getting traffics", err) + return + } + jsonObj(c, clientTraffics, nil) +} + func (a *InboundController) addInbound(c *gin.Context) { inbound := &model.Inbound{} err := c.ShouldBind(inbound) diff --git a/web/service/inbound.go b/web/service/inbound.go index d3a6be8a..374d15c3 100644 --- a/web/service/inbound.go +++ b/web/service/inbound.go @@ -710,7 +710,7 @@ func (s *InboundService) GetClientTrafficByEmail(email string) (traffic []*xray. db := database.GetDB() var traffics []*xray.ClientTraffic - err = db.Model(xray.ClientTraffic{}).Where("email like ?", "%"+email+"%").Find(&traffics).Error + err = db.Model(xray.ClientTraffic{}).Where("email = ?", email).Find(&traffics).Error if err != nil { if err == gorm.ErrRecordNotFound { logger.Warning(err) From 2b54d0344ea2cb051569b92343897bef113b2b14 Mon Sep 17 00:00:00 2001 From: Ho3ein Date: Fri, 21 Apr 2023 19:15:36 +0330 Subject: [PATCH 46/46] v1.2.7 --- config/version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/version b/config/version index 3c43790f..c04c650a 100644 --- a/config/version +++ b/config/version @@ -1 +1 @@ -1.2.6 +1.2.7