From 0496e35126d2c476c5bf4b69ca97742a73279f57 Mon Sep 17 00:00:00 2001 From: ReturnFI <151555003+ReturnFI@users.noreply.github.com> Date: Thu, 5 Sep 2024 13:22:35 +0000 Subject: [PATCH] Change SNI --- core/cli.py | 10 +++++++--- core/scripts/hysteria2/install.sh | 2 +- menu.sh | 5 +++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/core/cli.py b/core/cli.py index bf87d1b..b30251f 100644 --- a/core/cli.py +++ b/core/cli.py @@ -74,9 +74,13 @@ def cli(): @cli.command('install-hysteria2') -@click.option('--port', '-p', required=True, help='New port for Hysteria2', type=int, callback=validator.validate_port) -def install_hysteria2(port: int): - run_cmd(['bash', Command.INSTALL_HYSTERIA2.value, str(port)]) +@click.option('--port', '-p', required=True, help='Port for Hysteria2', type=int, callback=validator.validate_port) +@click.option('--sni', '-s', required=False, default='bts.com', help='SNI for Hysteria2 (default: bts.com)', type=str) +def install_hysteria2(port: int, sni: str): + """ + Installs Hysteria2 on the given port and uses the provided or default SNI value. + """ + run_cmd(['bash', Command.INSTALL_HYSTERIA2.value, str(port), sni]) @cli.command('uninstall-hysteria2') diff --git a/core/scripts/hysteria2/install.sh b/core/scripts/hysteria2/install.sh index 87c5982..aeee301 100644 --- a/core/scripts/hysteria2/install.sh +++ b/core/scripts/hysteria2/install.sh @@ -14,7 +14,7 @@ install_hysteria() { echo "Generating CA key and certificate..." openssl ecparam -genkey -name prime256v1 -out ca.key >/dev/null 2>&1 - openssl req -new -x509 -days 36500 -key ca.key -out ca.crt -subj "/CN=bts.com" >/dev/null 2>&1 + openssl req -new -x509 -days 36500 -key ca.key -out ca.crt -subj "/CN=$sni" >/dev/null 2>&1 echo "Downloading geo data..." wget -O /etc/hysteria/geosite.dat https://raw.githubusercontent.com/Chocolate4U/Iran-v2ray-rules/release/geosite.dat >/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 diff --git a/menu.sh b/menu.sh index ffee8bb..040dc71 100644 --- a/menu.sh +++ b/menu.sh @@ -12,7 +12,8 @@ hysteria2_install_handler() { fi while true; do - read -p "Enter the new port number you want to use: " port + read -p "Enter the SNI (default: bts.com): " sni + read -p "Enter the port number you want to use: " port if ! [[ "$port" =~ ^[0-9]+$ ]] || [ "$port" -lt 1 ] || [ "$port" -gt 65535 ]; then echo "Invalid port number. Please enter a number between 1 and 65535." else @@ -20,7 +21,7 @@ hysteria2_install_handler() { fi done - python3 $CLI_PATH install-hysteria2 --port "$port" + python3 $CLI_PATH install-hysteria2 --port "$port" --sni "$sni" } hysteria2_add_user_handler() {