From c8c0e8f850bbedf0b9f07d1560d79389731b0073 Mon Sep 17 00:00:00 2001 From: Whispering Wind <151555003+ReturnFI@users.noreply.github.com> Date: Sat, 11 Jan 2025 10:25:00 +0330 Subject: [PATCH 1/8] Update Requirements --- requirements.txt | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/requirements.txt b/requirements.txt index 836d506..cfec43e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,22 @@ -pyTelegramBotAPI==4.22.1 -qrcode==7.4.2 -python-dotenv==1.0.1 -requests==2.32.3 -aiohttp==3.10.5 -click==8.1.7 +aiohappyeyeballs==2.4.4 +aiohttp==3.11.11 +aiosignal==1.3.2 +async-timeout==4.0.3 +attrs==24.3.0 +certifi==2024.12.14 +charset-normalizer==3.4.1 +click==8.1.8 +frozenlist==1.5.0 +idna==3.10 +multidict==6.1.0 +pillow==11.1.0 +propcache==0.2.1 psutil==6.1.1 +pypng==0.20220715.0 +pyTelegramBotAPI==4.26.0 +python-dotenv==1.0.1 +qrcode==8.0 +requests==2.32.3 +typing_extensions==4.12.2 +urllib3==2.3.0 +yarl==1.18.3 From 9b720d8222dcaf162fc33374d1284c93b3883774 Mon Sep 17 00:00:00 2001 From: Whispering Wind <151555003+ReturnFI@users.noreply.github.com> Date: Sun, 12 Jan 2025 12:51:54 +0330 Subject: [PATCH 2/8] Increasing the chunk size to 32768 bytes --- core/scripts/hysteria2/update_geo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/scripts/hysteria2/update_geo.py b/core/scripts/hysteria2/update_geo.py index ba25ff3..4c63505 100644 --- a/core/scripts/hysteria2/update_geo.py +++ b/core/scripts/hysteria2/update_geo.py @@ -31,7 +31,7 @@ def remove_file(file_path): except Exception as e: print(f"Error removing file {file_path}: {e}") -def download_file(url, destination, chunk_size=8192): +def download_file(url, destination, chunk_size=32768): try: destination_dir = os.path.dirname(destination) if destination_dir and not os.path.exists(destination_dir): From a7e51ec302b38ee23a155d05d69e69b519a4f693 Mon Sep 17 00:00:00 2001 From: Whispering Wind <151555003+ReturnFI@users.noreply.github.com> Date: Sun, 12 Jan 2025 19:45:16 +0330 Subject: [PATCH 3/8] Fix: Block users based on total data usage --- core/scripts/hysteria2/user.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/scripts/hysteria2/user.sh b/core/scripts/hysteria2/user.sh index f185e8e..67cf08e 100644 --- a/core/scripts/hysteria2/user.sh +++ b/core/scripts/hysteria2/user.sh @@ -14,6 +14,9 @@ EXPIRATION_DAYS=$(jq -r --arg user "$USERNAME" '.[$user].expiration_days' "$USER ACCOUNT_CREATION_DATE=$(jq -r --arg user "$USERNAME" '.[$user].account_creation_date' "$USERS_FILE") BLOCKED=$(jq -r --arg user "$USERNAME" '.[$user].blocked' "$USERS_FILE") CURRENT_DOWNLOAD_BYTES=$(jq -r --arg user "$USERNAME" '.[$user].download_bytes' "$USERS_FILE") +CURRENT_UPLOAD_BYTES=$(jq -r --arg user "$USERNAME" '.[$user].upload_bytes' "$USERS_FILE") + +TOTAL_BYTES=$((CURRENT_DOWNLOAD_BYTES + CURRENT_UPLOAD_BYTES)) if [ "$BLOCKED" == "true" ]; then sleep 20 @@ -33,7 +36,7 @@ if [ "$CURRENT_DATE" -ge "$EXPIRATION_DATE" ]; then exit 1 fi -if [ "$CURRENT_DOWNLOAD_BYTES" -ge "$MAX_DOWNLOAD_BYTES" ]; then +if [ "$TOTAL_BYTES" -ge "$MAX_DOWNLOAD_BYTES" ]; then SECRET=$(jq -r '.trafficStats.secret' "$CONFIG_FILE") KICK_ENDPOINT="http://127.0.0.1:25413/kick" curl -s -H "Authorization: $SECRET" -X POST -d "[\"$USERNAME\"]" "$KICK_ENDPOINT" From 48e85c23e209be034340445ad64469abd6eeab62 Mon Sep 17 00:00:00 2001 From: Whispering Wind <151555003+ReturnFI@users.noreply.github.com> Date: Sun, 12 Jan 2025 19:45:58 +0330 Subject: [PATCH 4/8] Fix: Block users based on total data usage --- core/scripts/hysteria2/kick.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/core/scripts/hysteria2/kick.sh b/core/scripts/hysteria2/kick.sh index aa29ad0..93ad465 100644 --- a/core/scripts/hysteria2/kick.sh +++ b/core/scripts/hysteria2/kick.sh @@ -46,6 +46,9 @@ for USERNAME in $(jq -r 'keys[]' "$USERS_FILE"); do EXPIRATION_DAYS=$(jq -r --arg user "$USERNAME" '.[$user].expiration_days // 0' "$USERS_FILE") ACCOUNT_CREATION_DATE=$(jq -r --arg user "$USERNAME" '.[$user].account_creation_date' "$USERS_FILE") CURRENT_DOWNLOAD_BYTES=$(jq -r --arg user "$USERNAME" '.[$user].download_bytes // 0' "$USERS_FILE") + CURRENT_UPLOAD_BYTES=$(jq -r --arg user "$USERNAME" '.[$user].upload_bytes // 0' "$USERS_FILE") + + TOTAL_BYTES=$((CURRENT_DOWNLOAD_BYTES + CURRENT_UPLOAD_BYTES)) if [ -z "$ACCOUNT_CREATION_DATE" ]; then echo "$(date): [INFO] Skipping $USERNAME due to missing account creation date." >> $LOGFILE @@ -55,8 +58,8 @@ for USERNAME in $(jq -r 'keys[]' "$USERS_FILE"); do CURRENT_DATE=$(date +%s) EXPIRATION_DATE=$(date -d "$ACCOUNT_CREATION_DATE + $EXPIRATION_DAYS days" +%s) - if [ "$MAX_DOWNLOAD_BYTES" -gt 0 ] && [ "$CURRENT_DOWNLOAD_BYTES" -ge 0 ] && [ "$EXPIRATION_DAYS" -gt 0 ]; then - if [ "$CURRENT_DOWNLOAD_BYTES" -ge "$MAX_DOWNLOAD_BYTES" ] || [ "$CURRENT_DATE" -ge "$EXPIRATION_DATE" ]; then + if [ "$MAX_DOWNLOAD_BYTES" -gt 0 ] && [ "$EXPIRATION_DAYS" -gt 0 ]; then + if [ "$TOTAL_BYTES" -ge "$MAX_DOWNLOAD_BYTES" ] || [ "$CURRENT_DATE" -ge "$EXPIRATION_DATE" ]; then for i in {1..3}; do jq --arg user "$USERNAME" '.[$user].blocked = true' "$USERS_FILE" > temp.json && mv temp.json "$USERS_FILE" && break sleep 1 From 3fe416d0066e3c442da9178f73645207efb232a7 Mon Sep 17 00:00:00 2001 From: Whispering Wind <151555003+ReturnFI@users.noreply.github.com> Date: Sun, 12 Jan 2025 19:59:49 +0330 Subject: [PATCH 5/8] fix: EXPIRATION_DAYS --- core/scripts/hysteria2/kick.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/scripts/hysteria2/kick.sh b/core/scripts/hysteria2/kick.sh index 93ad465..2b9f08b 100644 --- a/core/scripts/hysteria2/kick.sh +++ b/core/scripts/hysteria2/kick.sh @@ -58,7 +58,7 @@ for USERNAME in $(jq -r 'keys[]' "$USERS_FILE"); do CURRENT_DATE=$(date +%s) EXPIRATION_DATE=$(date -d "$ACCOUNT_CREATION_DATE + $EXPIRATION_DAYS days" +%s) - if [ "$MAX_DOWNLOAD_BYTES" -gt 0 ] && [ "$EXPIRATION_DAYS" -gt 0 ]; then + if [ "$MAX_DOWNLOAD_BYTES" -gt 0 ] && [ "$TOTAL_BYTES" -ge 0 ] && [ "$EXPIRATION_DAYS" -gt 0 ]; then if [ "$TOTAL_BYTES" -ge "$MAX_DOWNLOAD_BYTES" ] || [ "$CURRENT_DATE" -ge "$EXPIRATION_DATE" ]; then for i in {1..3}; do jq --arg user "$USERNAME" '.[$user].blocked = true' "$USERS_FILE" > temp.json && mv temp.json "$USERS_FILE" && break From 4057dd6fd4104cfe9df32c36abadc11c9ac1a9c1 Mon Sep 17 00:00:00 2001 From: Whispering Wind <151555003+ReturnFI@users.noreply.github.com> Date: Sun, 12 Jan 2025 20:11:57 +0330 Subject: [PATCH 6/8] Update changelog --- changelog | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/changelog b/changelog index bef334f..46c03d7 100644 --- a/changelog +++ b/changelog @@ -1,6 +1,3 @@ -1. Fix: Changed geo category(block adult sites) -2. Reject(malware, phishing, cryptominers) -3. Add: GeoCountry(Iran, China, and Russia) -4. Add: Geo Update flag --country option(cli) -5. Add: CPU monitoring module(Telegram-Bot) -6. Add: Search users by the `blocked` status(Telegram-Bot) +1. Fix: Block users based on total data usage +2. Increasing the chunk size to 32768 bytes(GeoFiles) +3. Update Requirements From c853d2a502223f9486d0083eee1c370fc2adb5c2 Mon Sep 17 00:00:00 2001 From: Whispering Wind <151555003+ReturnFI@users.noreply.github.com> Date: Sun, 12 Jan 2025 20:13:12 +0330 Subject: [PATCH 7/8] Clone beta --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index f95bacf..cbe775d 100644 --- a/install.sh +++ b/install.sh @@ -53,7 +53,7 @@ else echo "All required packages are already installed." fi -git clone https://github.com/ReturnFI/Hysteria2 /etc/hysteria +git clone -b beta https://github.com/ReturnFI/Hysteria2 /etc/hysteria cd /etc/hysteria python3 -m venv hysteria2_venv From bc653742f386a50aa815c9bc36db89e8b9a2bdd8 Mon Sep 17 00:00:00 2001 From: Whispering Wind <151555003+ReturnFI@users.noreply.github.com> Date: Sun, 12 Jan 2025 20:28:21 +0330 Subject: [PATCH 8/8] Clone Main --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index cbe775d..f95bacf 100644 --- a/install.sh +++ b/install.sh @@ -53,7 +53,7 @@ else echo "All required packages are already installed." fi -git clone -b beta https://github.com/ReturnFI/Hysteria2 /etc/hysteria +git clone https://github.com/ReturnFI/Hysteria2 /etc/hysteria cd /etc/hysteria python3 -m venv hysteria2_venv