Change SNI

This commit is contained in:
ReturnFI
2024-09-05 13:22:35 +00:00
parent cee86069b2
commit 0496e35126
3 changed files with 11 additions and 6 deletions

View File

@ -74,9 +74,13 @@ def cli():
@cli.command('install-hysteria2') @cli.command('install-hysteria2')
@click.option('--port', '-p', required=True, help='New port for Hysteria2', type=int, callback=validator.validate_port) @click.option('--port', '-p', required=True, help='Port for Hysteria2', type=int, callback=validator.validate_port)
def install_hysteria2(port: int): @click.option('--sni', '-s', required=False, default='bts.com', help='SNI for Hysteria2 (default: bts.com)', type=str)
run_cmd(['bash', Command.INSTALL_HYSTERIA2.value, str(port)]) 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') @cli.command('uninstall-hysteria2')

View File

@ -14,7 +14,7 @@ install_hysteria() {
echo "Generating CA key and certificate..." echo "Generating CA key and certificate..."
openssl ecparam -genkey -name prime256v1 -out ca.key >/dev/null 2>&1 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..." 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/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 wget -O /etc/hysteria/geoip.dat https://raw.githubusercontent.com/Chocolate4U/Iran-v2ray-rules/release/geoip.dat >/dev/null 2>&1

View File

@ -12,7 +12,8 @@ hysteria2_install_handler() {
fi fi
while true; do 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 if ! [[ "$port" =~ ^[0-9]+$ ]] || [ "$port" -lt 1 ] || [ "$port" -gt 65535 ]; then
echo "Invalid port number. Please enter a number between 1 and 65535." echo "Invalid port number. Please enter a number between 1 and 65535."
else else
@ -20,7 +21,7 @@ hysteria2_install_handler() {
fi fi
done done
python3 $CLI_PATH install-hysteria2 --port "$port" python3 $CLI_PATH install-hysteria2 --port "$port" --sni "$sni"
} }
hysteria2_add_user_handler() { hysteria2_add_user_handler() {