From 2d0510ac3ee3b16973801eddbebcde12e6262874 Mon Sep 17 00:00:00 2001 From: Whispering Wind <151555003+ReturnFI@users.noreply.github.com> Date: Wed, 18 Dec 2024 22:52:07 +0330 Subject: [PATCH 01/11] Added Core Version --- core/scripts/utils.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/core/scripts/utils.sh b/core/scripts/utils.sh index 56af85d..b04f9fe 100644 --- a/core/scripts/utils.sh +++ b/core/scripts/utils.sh @@ -18,6 +18,7 @@ get_system_info() { IP=$(echo "$IP_API_DATA" | jq -r '.ip') CPU=$(top -bn1 | grep "Cpu(s)" | awk '{print $2 + $4 "%"}') RAM=$(free -m | awk 'NR==2{printf "%.2f%%", $3*100/$2 }') + HCVERSION=$(hysteria version | grep "^Version:" | awk '{print $2}') } version_greater_equal() { From 198acc977f840fe60b25d1b50983908bc3d90a3d Mon Sep 17 00:00:00 2001 From: Whispering Wind <151555003+ReturnFI@users.noreply.github.com> Date: Wed, 18 Dec 2024 22:54:15 +0330 Subject: [PATCH 02/11] Added Core Version --- menu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/menu.sh b/menu.sh index 8c40caf..3ce39c8 100644 --- a/menu.sh +++ b/menu.sh @@ -567,7 +567,7 @@ display_main_menu() { echo -e "${green}• IP: ${NC}$IP ${green}• RAM: ${NC}$RAM" echo -e "${LPurple}◇──────────────────────────────────────────────────────────────────────◇${NC}" - + echo -e "Hysteria2 Core Version: ${cyan}$VERSION${NC}" check_version echo -e "${LPurple}◇──────────────────────────────────────────────────────────────────────◇${NC}" echo -e "${yellow} ☼ Services Status ☼ ${NC}" From b0cd3666701101a63760cd03d5c577fe98781b4d Mon Sep 17 00:00:00 2001 From: Whispering Wind <151555003+ReturnFI@users.noreply.github.com> Date: Wed, 18 Dec 2024 22:55:00 +0330 Subject: [PATCH 03/11] typo --- menu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/menu.sh b/menu.sh index 3ce39c8..5deb183 100644 --- a/menu.sh +++ b/menu.sh @@ -567,7 +567,7 @@ display_main_menu() { echo -e "${green}• IP: ${NC}$IP ${green}• RAM: ${NC}$RAM" echo -e "${LPurple}◇──────────────────────────────────────────────────────────────────────◇${NC}" - echo -e "Hysteria2 Core Version: ${cyan}$VERSION${NC}" + echo -e "Hysteria2 Core Version: ${cyan}$HCVERSION${NC}" check_version echo -e "${LPurple}◇──────────────────────────────────────────────────────────────────────◇${NC}" echo -e "${yellow} ☼ Services Status ☼ ${NC}" From 4859c03d6c3da4a7fa8c3eea84c6b32b83b37c89 Mon Sep 17 00:00:00 2001 From: Whispering Wind <151555003+ReturnFI@users.noreply.github.com> Date: Wed, 18 Dec 2024 23:12:57 +0330 Subject: [PATCH 04/11] Clone Dev --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index f95bacf..d76c78a 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 dev https://github.com/ReturnFI/Hysteria2 /etc/hysteria cd /etc/hysteria python3 -m venv hysteria2_venv From 9802e3435b9814fdc0dc41f9cab9b7d9ba2f74ac Mon Sep 17 00:00:00 2001 From: Whispering Wind <151555003+ReturnFI@users.noreply.github.com> Date: Fri, 20 Dec 2024 22:38:14 +0330 Subject: [PATCH 05/11] Displays the data in a readable format --- menu.sh | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/menu.sh b/menu.sh index 5deb183..086bafb 100644 --- a/menu.sh +++ b/menu.sh @@ -162,11 +162,38 @@ hysteria2_get_user_handler() { fi done - # Run the command and suppress error output - if ! python3 "$CLI_PATH" get-user --username "$username" 2>/dev/null; then + user_data=$(python3 "$CLI_PATH" get-user --username "$username" 2>/dev/null) + + if [[ $? -ne 0 ]]; then echo -e "${red}Error:${NC} User '$username' not found." return 1 fi + + password=$(echo "$user_data" | jq -r '.password // "N/A"') + max_download_bytes=$(echo "$user_data" | jq -r '.max_download_bytes // 0') + upload_bytes=$(echo "$user_data" | jq -r '.upload_bytes // 0') + download_bytes=$(echo "$user_data" | jq -r '.download_bytes // 0') + account_creation_date=$(echo "$user_data" | jq -r '.account_creation_date // "N/A"') + expiration_days=$(echo "$user_data" | jq -r '.expiration_days // 0') + blocked=$(echo "$user_data" | jq -r '.blocked // false') + status=$(echo "$user_data" | jq -r '.status // "N/A"') + total_usage=$((upload_bytes + download_bytes)) + expiration_date=$(date -d "$account_creation_date + $expiration_days days" +"%Y-%m-%d") + current_date=$(date +"%Y-%m-%d") + used_days=$(( ( $(date -d "$current_date" +%s) - $(date -d "$account_creation_date" +%s) ) / 86400 )) + + if [[ $used_days -gt $expiration_days ]]; then + used_days=$expiration_days + fi + + echo -e "${green}User Details:${NC}" + echo -e "Username: $username" + echo -e "Password: $password" + echo -e "Total Traffic: $max_download_bytes bytes" + echo -e "Total Usage: $total_usage bytes" + echo -e "Time Expiration: $expiration_date ($used_days/$expiration_days Days)" + echo -e "Blocked: $blocked" + echo -e "Status: $status" } hysteria2_list_users_handler() { From 5029cf9e5e7f0f7d309428e941b03a4ce8a02e45 Mon Sep 17 00:00:00 2001 From: Whispering Wind <151555003+ReturnFI@users.noreply.github.com> Date: Fri, 20 Dec 2024 22:45:08 +0330 Subject: [PATCH 06/11] Fix: Core Version --- core/scripts/utils.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/scripts/utils.sh b/core/scripts/utils.sh index b04f9fe..7fcc5a5 100644 --- a/core/scripts/utils.sh +++ b/core/scripts/utils.sh @@ -18,7 +18,6 @@ get_system_info() { IP=$(echo "$IP_API_DATA" | jq -r '.ip') CPU=$(top -bn1 | grep "Cpu(s)" | awk '{print $2 + $4 "%"}') RAM=$(free -m | awk 'NR==2{printf "%.2f%%", $3*100/$2 }') - HCVERSION=$(hysteria version | grep "^Version:" | awk '{print $2}') } version_greater_equal() { @@ -40,6 +39,12 @@ version_greater_equal() { return 0 } +check_core_version() { + if systemctl is-active --quiet hysteria-server.service; then + HCVERSION=$(hysteria version | grep "^Version:" | awk '{print $2}') + fi +} + check_version() { local_version=$(cat $LOCALVERSION) latest_version=$(curl -s $LATESTVERSION) From 6efd2de02ab140015ec10366ff7b367a8b66ac6a Mon Sep 17 00:00:00 2001 From: Whispering Wind <151555003+ReturnFI@users.noreply.github.com> Date: Fri, 20 Dec 2024 22:52:22 +0330 Subject: [PATCH 07/11] Fix: Core Version --- menu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/menu.sh b/menu.sh index 086bafb..837f940 100644 --- a/menu.sh +++ b/menu.sh @@ -594,7 +594,7 @@ display_main_menu() { echo -e "${green}• IP: ${NC}$IP ${green}• RAM: ${NC}$RAM" echo -e "${LPurple}◇──────────────────────────────────────────────────────────────────────◇${NC}" - echo -e "Hysteria2 Core Version: ${cyan}$HCVERSION${NC}" + check_core_version check_version echo -e "${LPurple}◇──────────────────────────────────────────────────────────────────────◇${NC}" echo -e "${yellow} ☼ Services Status ☼ ${NC}" From 125fedcdd1446a1d8bde6a98f93c167d040f64ed Mon Sep 17 00:00:00 2001 From: Whispering Wind <151555003+ReturnFI@users.noreply.github.com> Date: Fri, 20 Dec 2024 22:53:00 +0330 Subject: [PATCH 08/11] Added Core Version --- core/scripts/utils.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/core/scripts/utils.sh b/core/scripts/utils.sh index 7fcc5a5..8095164 100644 --- a/core/scripts/utils.sh +++ b/core/scripts/utils.sh @@ -42,6 +42,7 @@ version_greater_equal() { check_core_version() { if systemctl is-active --quiet hysteria-server.service; then HCVERSION=$(hysteria version | grep "^Version:" | awk '{print $2}') + echo -e "Hysteria2 Core Version: ${cyan}$HCVERSION${NC}" fi } From 1f209a701d7b9af4671391f58fd4bab37935fc17 Mon Sep 17 00:00:00 2001 From: Whispering Wind <151555003+ReturnFI@users.noreply.github.com> Date: Fri, 20 Dec 2024 23:12:32 +0330 Subject: [PATCH 09/11] display the traffic information in gigabytes --- menu.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/menu.sh b/menu.sh index 837f940..19b57a1 100644 --- a/menu.sh +++ b/menu.sh @@ -178,6 +178,10 @@ hysteria2_get_user_handler() { blocked=$(echo "$user_data" | jq -r '.blocked // false') status=$(echo "$user_data" | jq -r '.status // "N/A"') total_usage=$((upload_bytes + download_bytes)) + max_download_gb=$(echo "scale=2; $max_download_bytes / 1073741824" | bc) + upload_gb=$(echo "scale=2; $upload_bytes / 1073741824" | bc) + download_gb=$(echo "scale=2; $download_bytes / 1073741824" | bc) + total_usage_gb=$(echo "scale=2; $total_usage / 1073741824" | bc) expiration_date=$(date -d "$account_creation_date + $expiration_days days" +"%Y-%m-%d") current_date=$(date +"%Y-%m-%d") used_days=$(( ( $(date -d "$current_date" +%s) - $(date -d "$account_creation_date" +%s) ) / 86400 )) @@ -189,8 +193,8 @@ hysteria2_get_user_handler() { echo -e "${green}User Details:${NC}" echo -e "Username: $username" echo -e "Password: $password" - echo -e "Total Traffic: $max_download_bytes bytes" - echo -e "Total Usage: $total_usage bytes" + echo -e "Total Traffic: $max_download_gb GB" + echo -e "Total Usage: $total_usage_gb GB" echo -e "Time Expiration: $expiration_date ($used_days/$expiration_days Days)" echo -e "Blocked: $blocked" echo -e "Status: $status" From ce19aa6a3c9784f1ab6b0162e96bf41051ab1f46 Mon Sep 17 00:00:00 2001 From: Whispering Wind <151555003+ReturnFI@users.noreply.github.com> Date: Fri, 20 Dec 2024 23:18:00 +0330 Subject: [PATCH 10/11] Update changelog --- changelog | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/changelog b/changelog index b0b4911..efbe159 100644 --- a/changelog +++ b/changelog @@ -1,4 +1,3 @@ -1. Add SSL certificate deletion -2. Shows the URI with the -s and -n -3. Refactored check_version function to use variables from path.sh -4. Fixed some bugs +1. Displays the data in a readable format +2. Added Core Version(Menu) +3. Added Total Usage(TelegramBOT) From 57db6744417261871a1ba26fabd68d297f957559 Mon Sep 17 00:00:00 2001 From: Whispering Wind <151555003+ReturnFI@users.noreply.github.com> Date: Fri, 20 Dec 2024 23:21:12 +0330 Subject: [PATCH 11/11] Clone Main --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index d76c78a..f95bacf 100644 --- a/install.sh +++ b/install.sh @@ -53,7 +53,7 @@ else echo "All required packages are already installed." fi -git clone -b dev https://github.com/ReturnFI/Hysteria2 /etc/hysteria +git clone https://github.com/ReturnFI/Hysteria2 /etc/hysteria cd /etc/hysteria python3 -m venv hysteria2_venv