diff --git a/README-fa.md b/README-fa.md index 36f1f65..c3fb3b3 100644 --- a/README-fa.md +++ b/README-fa.md @@ -5,7 +5,7 @@ [![Lang_Eglish](https://img.shields.io/badge/Language-English-009688?logo=google-translate&logoColor=white)](README.md) [![Latest Release](https://img.shields.io/badge/Release-Latest-brightgreen?logo=github)](https://github.com/ReturnFI/Hysteria2/releases) -[![License](https://img.shields.io/badge/License-MIT-blueviolet?logo=open-source-initiative&logoColor=white)](LICENSE) +[![License](https://img.shields.io/badge/License-GPL-blueviolet?logo=open-source-initiative&logoColor=white)](LICENSE) [![Made with ❤️](https://img.shields.io/badge/Made%20with-%E2%9D%A4-red)](#) diff --git a/README.md b/README.md index 076d18f..c712838 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ [![Language](https://img.shields.io/badge/Language-Persian-009688?logo=google-translate&logoColor=white)](README-fa.md) [![Latest Release](https://img.shields.io/badge/Release-Latest-brightgreen?logo=github)](https://github.com/ReturnFI/Hysteria2/releases) -[![License](https://img.shields.io/badge/License-MIT-blueviolet?logo=open-source-initiative&logoColor=white)](LICENSE) +[![License](https://img.shields.io/badge/License-GPL-blueviolet?logo=open-source-initiative&logoColor=white)](LICENSE) [![Made with ❤️](https://img.shields.io/badge/Made%20with-%E2%9D%A4-red)](#) diff --git a/changelog b/changelog index 614253c..7e343a7 100644 --- a/changelog +++ b/changelog @@ -1,7 +1,5 @@ -## [1.5.0] - 2025-04-11 -### Added -- Integrated Hysteria2-API package (https://github.com/ReturnFI/Hysteria2-API) -- Added support for managing traffic file via API +## [1.5.1] - 2025-04-11 ### Changed -- Refactored traffic-related logic to use the new API package +- Deprecated SingBox SubLink +- Change pinSHA256 to Hex diff --git a/core/scripts/hysteria2/change_sni.sh b/core/scripts/hysteria2/change_sni.sh index 533f046..2f590ea 100644 --- a/core/scripts/hysteria2/change_sni.sh +++ b/core/scripts/hysteria2/change_sni.sh @@ -19,25 +19,26 @@ update_sni() { openssl req -new -x509 -days 36500 -key ca.key -out ca.crt -subj "/CN=$sni" >/dev/null 2>&1 chown hysteria:hysteria /etc/hysteria/ca.key /etc/hysteria/ca.crt chmod 640 /etc/hysteria/ca.key /etc/hysteria/ca.crt - fingerprint=$(openssl x509 -noout -fingerprint -sha256 -inform pem -in ca.crt | sed 's/.*=//;s/://g') + sha256=$(openssl x509 -noout -fingerprint -sha256 -inform pem -in ca.crt | sed 's/.*=//;s///g') - sha256=$(python3 - </dev/null 2>&1 wget -O /etc/hysteria/geoip.dat https://raw.githubusercontent.com/Chocolate4U/Iran-v2ray-rules/release/geoip.dat >/dev/null 2>&1 - fingerprint=$(openssl x509 -noout -fingerprint -sha256 -inform pem -in ca.crt | sed 's/.*=//;s/://g') + # fingerprint=$(openssl x509 -noout -fingerprint -sha256 -inform pem -in ca.crt | sed 's/.*=//;s/://g') echo "Generating base64 encoded SHA-256 fingerprint..." - cat < generate.py -import base64 -import binascii +# cat < generate.py +# import base64 +# import binascii -# Hexadecimal string -hex_string = "$fingerprint" +# # Hexadecimal string +# hex_string = "$fingerprint" -# Convert hex to binary -binary_data = binascii.unhexlify(hex_string) +# # Convert hex to binary +# binary_data = binascii.unhexlify(hex_string) -# Encode binary data to base64 -base64_encoded = base64.b64encode(binary_data).decode('utf-8') +# # Encode binary data to base64 +# base64_encoded = base64.b64encode(binary_data).decode('utf-8') -# Print the result prefixed with 'sha256/' -print('sha256/' + base64_encoded) -EOF +# # Print the result prefixed with 'sha256/' +# print('sha256/' + base64_encoded) +# EOF - sha256=$(python3 generate.py) + sha256=$(openssl x509 -noout -fingerprint -sha256 -inform pem -in ca.crt | sed 's/.*=//;s///g') if [[ $port =~ ^[0-9]+$ ]] && (( port >= 1 && port <= 65535 )); then if ss -tuln | grep -q ":$port\b"; then diff --git a/core/scripts/services_status.sh b/core/scripts/services_status.sh index 38f3f73..f9b0679 100644 --- a/core/scripts/services_status.sh +++ b/core/scripts/services_status.sh @@ -6,7 +6,7 @@ declare -a services=( "hysteria-caddy.service" "hysteria-telegram-bot.service" "hysteria-normal-sub.service" - "hysteria-singbox.service" + # "hysteria-singbox.service" "hysteria-ip-limit.service" "wg-quick@wgcf.service" ) diff --git a/core/scripts/telegrambot/utils/edituser.py b/core/scripts/telegrambot/utils/edituser.py index db5c61d..537084c 100644 --- a/core/scripts/telegrambot/utils/edituser.py +++ b/core/scripts/telegrambot/utils/edituser.py @@ -87,15 +87,15 @@ def process_show_user(message): result_lines = combined_result.strip().split('\n') uri_v4 = "" - singbox_sublink = "" + # singbox_sublink = "" normal_sub_sublink = "" for line in result_lines: line = line.strip() if line.startswith("hy2://"): uri_v4 = line - elif line.startswith("Singbox Sublink:"): - singbox_sublink = result_lines[result_lines.index(line) + 1].strip() + # elif line.startswith("Singbox Sublink:"): + # singbox_sublink = result_lines[result_lines.index(line) + 1].strip() elif line.startswith("Normal-SUB Sublink:"): normal_sub_sublink = result_lines[result_lines.index(line) + 1].strip() @@ -119,8 +119,8 @@ def process_show_user(message): types.InlineKeyboardButton("Block User", callback_data=f"block_user:{actual_username}")) caption = f"{formatted_details}\n\n**IPv4 URI:**\n\n`{uri_v4}`" - if singbox_sublink: - caption += f"\n\n**SingBox SUB:**\n{singbox_sublink}" + # if singbox_sublink: + # caption += f"\n\n**SingBox SUB:**\n{singbox_sublink}" if normal_sub_sublink: caption += f"\n\n**Normal SUB:**\n{normal_sub_sublink}" diff --git a/core/scripts/webpanel/routers/api/v1/schema/server.py b/core/scripts/webpanel/routers/api/v1/schema/server.py index 33ea6dd..bb3ba4b 100644 --- a/core/scripts/webpanel/routers/api/v1/schema/server.py +++ b/core/scripts/webpanel/routers/api/v1/schema/server.py @@ -20,7 +20,7 @@ class ServerServicesStatusResponse(BaseModel): hysteria_server: bool hysteria_webpanel: bool hysteria_iplimit: bool - hysteria_singbox: bool + # hysteria_singbox: bool hysteria_normal_sub: bool hysteria_telegram_bot: bool hysteria_warp: bool diff --git a/core/scripts/webpanel/routers/api/v1/server.py b/core/scripts/webpanel/routers/api/v1/server.py index 543ff61..5de4753 100644 --- a/core/scripts/webpanel/routers/api/v1/server.py +++ b/core/scripts/webpanel/routers/api/v1/server.py @@ -141,8 +141,8 @@ def __parse_services_status(services_status: dict[str, bool]) -> ServerServicesS parsed_services_status['hysteria_telegram_bot'] = status elif 'hysteria-normal-sub' in service: parsed_services_status['hysteria_normal_sub'] = status - elif 'hysteria-singbox' in service: - parsed_services_status['hysteria_singbox'] = status + # elif 'hysteria-singbox' in service: + # parsed_services_status['hysteria_singbox'] = status elif 'wg-quick' in service: parsed_services_status['hysteria_warp'] = status return ServerServicesStatusResponse(**parsed_services_status) diff --git a/core/scripts/webpanel/templates/settings.html b/core/scripts/webpanel/templates/settings.html index 23ebf5c..44a3363 100644 --- a/core/scripts/webpanel/templates/settings.html +++ b/core/scripts/webpanel/templates/settings.html @@ -68,19 +68,13 @@
-
- -
+ -
+
@@ -467,7 +461,7 @@ function updateServiceUI(data) { const servicesMap = { "hysteria_telegram_bot": "#telegram", - "hysteria_singbox": "#singbox", + // "hysteria_singbox": "#singbox", // singbox removed "hysteria_normal_sub": "#normal", "hysteria_iplimit": "#ip-limit-service" }; @@ -483,9 +477,9 @@ $(selector).prepend(`
Service is running. You can stop it if needed.
`); $(selector + " .btn-danger").show(); - if (service === "hysteria_singbox") { - $("#singbox_start").prop('disabled', true); - } + // if (service === "hysteria_singbox") { // singbox removed + // $("#singbox_start").prop('disabled', true); + // } if(service === "hysteria_telegram_bot"){ $("#telegram_start").prop('disabled', true); } @@ -508,9 +502,9 @@ $(selector + " .btn-success").show(); $(selector + " .btn-danger").hide(); $(selector + " .alert-info").remove(); - if (service === "hysteria_singbox") { - $("#singbox_start").prop('disabled', false); - } + // if (service === "hysteria_singbox") { // singbox removed + // $("#singbox_start").prop('disabled', false); + // } if(service === "hysteria_telegram_bot"){ $("#telegram_start").prop('disabled', false); } @@ -598,32 +592,32 @@ }); } - function startSingbox() { - if (!validateForm('singbox')) return; - const domain = $("#singbox_domain").val(); - const port = $("#singbox_port").val(); - confirmAction("start SingBox", function () { - sendRequest( - "{{ url_for('singbox_start_api') }}", - "POST", - { domain: domain, port: port }, - "SingBox started successfully!", - "#singbox_start" - ); - }); - } + // function startSingbox() { // singbox removed + // if (!validateForm('singbox')) return; + // const domain = $("#singbox_domain").val(); + // const port = $("#singbox_port").val(); + // confirmAction("start SingBox", function () { + // sendRequest( + // "{{ url_for('singbox_start_api') }}", + // "POST", + // { domain: domain, port: port }, + // "SingBox started successfully!", + // "#singbox_start" + // ); + // }); + // } - function stopSingbox() { - confirmAction("stop SingBox", function () { - sendRequest( - "{{ url_for('singbox_stop_api') }}", - "DELETE", - null, - "SingBox stopped successfully!", - null - ); - }); - } + // function stopSingbox() { // singbox removed + // confirmAction("stop SingBox", function () { + // sendRequest( + // "{{ url_for('singbox_stop_api') }}", + // "DELETE", + // null, + // "SingBox stopped successfully!", + // null + // ); + // }); + // } function startNormal() { if (!validateForm('normal')) return; @@ -792,8 +786,8 @@ $("#telegram_start").on("click", startTelegram); $("#telegram_stop").on("click", stopTelegram); - $("#singbox_start").on("click", startSingbox); - $("#singbox_stop").on("click", stopSingbox); + // $("#singbox_start").on("click", startSingbox); // singbox removed + // $("#singbox_stop").on("click", stopSingbox); // singbox removed $("#normal_start").on("click", startNormal); $("#normal_stop").on("click", stopNormal); $("#port_change").on("click", changePort); @@ -806,7 +800,8 @@ $("#ip_limit_change_config").on("click", configIPLimit); - $('#singbox_domain, #normal_domain, #sni_domain').on('input', function () { + // $('#singbox_domain, #normal_domain, #sni_domain').on('input', function () { // singbox removed + $('#normal_domain, #sni_domain').on('input', function () { if (isValidDomain($(this).val())) { $(this).removeClass('is-invalid'); } else { @@ -814,7 +809,8 @@ } }); - $('#singbox_port, #normal_port, #hysteria_port').on('input', function () { + // $('#singbox_port, #normal_port, #hysteria_port').on('input', function () { // singbox removed + $('#normal_port, #hysteria_port').on('input', function () { if (isValidPort($(this).val())) { $(this).removeClass('is-invalid'); } else { diff --git a/menu.sh b/menu.sh index ccd2d06..e7bc1e7 100644 --- a/menu.sh +++ b/menu.sh @@ -485,39 +485,40 @@ telegram_bot_handler() { singbox_handler() { while true; do - echo -e "${cyan}1.${NC} Start Singbox service" + echo -e "${cyan}Merged with Normal-Sub sublink.${NC}" + # echo -e "${cyan}1.${NC} Start Singbox service" echo -e "${red}2.${NC} Stop Singbox service" echo "0. Back" read -p "Choose an option: " option case $option in - 1) - if systemctl is-active --quiet hysteria-singbox.service; then - echo "The hysteria-singbox.service is already active." - else - while true; do - read -e -p "Enter the domain name for the SSL certificate: " domain - if [ -z "$domain" ]; then - echo "Domain name cannot be empty. Please try again." - else - break - fi - done + # 1) + # if systemctl is-active --quiet hysteria-singbox.service; then + # echo "The hysteria-singbox.service is already active." + # else + # while true; do + # read -e -p "Enter the domain name for the SSL certificate: " domain + # if [ -z "$domain" ]; then + # echo "Domain name cannot be empty. Please try again." + # else + # break + # fi + # done - while true; do - read -e -p "Enter the port number for the service: " port - if [ -z "$port" ]; then - echo "Port number cannot be empty. Please try again." - elif ! [[ "$port" =~ ^[0-9]+$ ]]; then - echo "Port must be a number. Please try again." - else - break - fi - done + # while true; do + # read -e -p "Enter the port number for the service: " port + # if [ -z "$port" ]; then + # echo "Port number cannot be empty. Please try again." + # elif ! [[ "$port" =~ ^[0-9]+$ ]]; then + # echo "Port must be a number. Please try again." + # else + # break + # fi + # done - python3 $CLI_PATH singbox -a start -d "$domain" -p "$port" - fi - ;; + # python3 $CLI_PATH singbox -a start -d "$domain" -p "$port" + # fi + # ;; 2) if ! systemctl is-active --quiet hysteria-singbox.service; then echo "The hysteria-singbox.service is already inactive." @@ -1011,7 +1012,7 @@ display_advance_menu() { echo -e "${cyan}[3] ${NC}↝ Configure WARP" echo -e "${red}[4] ${NC}↝ Uninstall WARP" echo -e "${green}[5] ${NC}↝ Telegram Bot" - echo -e "${green}[6] ${NC}↝ SingBox SubLink" + echo -e "${green}[6] ${NC}↝ SingBox SubLink(${red}Deprecated${NC})" echo -e "${green}[7] ${NC}↝ Normal-SUB SubLink" echo -e "${green}[8] ${NC}↝ Web Panel" echo -e "${cyan}[9] ${NC}↝ Change Port Hysteria2" diff --git a/upgrade.sh b/upgrade.sh index 5c1f67d..c1d7957 100644 --- a/upgrade.sh +++ b/upgrade.sh @@ -117,6 +117,23 @@ else echo "$NORMALSUB_ENV not found. Skipping SUBPATH check." fi +CONFIG_FILE="/etc/hysteria/config.json" +if [ -f "$CONFIG_FILE" ]; then + echo "Checking and converting pinSHA256 format in config.json" + + if grep -q "pinSHA256.*=" "$CONFIG_FILE"; then + echo "Converting pinSHA256 from base64 to hex format" + + HEX_FINGERPRINT=$(openssl x509 -noout -fingerprint -sha256 -inform pem -in /etc/hysteria/ca.crt | sed 's/.*=//;s///g') + + sed -i "s|\"pinSHA256\": \"sha256/.*\"|\"pinSHA256\": \"$HEX_FINGERPRINT\"|" "$CONFIG_FILE" + + echo "pinSHA256 converted to hex format: $HEX_FINGERPRINT" + else + echo "pinSHA256 appears to already be in hex format or not present, no conversion needed" + fi +fi + echo "Setting ownership and permissions" chown hysteria:hysteria /etc/hysteria/ca.key /etc/hysteria/ca.crt chmod 640 /etc/hysteria/ca.key /etc/hysteria/ca.crt