From 93fc03c6ca0b590952a2778e88207f03220277ea Mon Sep 17 00:00:00 2001 From: zenaku Date: Sat, 23 May 2026 04:39:37 +0000 Subject: [PATCH] fix subdomain --- core/services/encrypted_proxy/hysteria_service.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/core/services/encrypted_proxy/hysteria_service.py b/core/services/encrypted_proxy/hysteria_service.py index 855091f..a425a1b 100644 --- a/core/services/encrypted_proxy/hysteria_service.py +++ b/core/services/encrypted_proxy/hysteria_service.py @@ -4,22 +4,17 @@ from core.utils.encrypted_proxy.net import get_real_ip, verify_ip from core.utils.encrypted_proxy.singbox import SingboxRunner import socket + def _resolve(host: str) -> str: return socket.gethostbyname(host) -def _get_hy2_domain(server_host: str) -> str: - parts = server_host.split(".", 1) - if len(parts) == 2: - return f"hy2.{parts[1]}" - return server_host def build_hysteria_config(username: str, password: str, server_host: str, socks5_port: int) -> dict: - hy2_domain = _get_hy2_domain(server_host) - server_ip = _resolve(hy2_domain) + server_ip = _resolve(server_host) return { "dns": { - "servers": [{"tag": "local", "type": "udp", "server": "1.1.1.1"}], + "servers": [{"tag": "local", "type": "udp", "server": "9.9.9.9"}], "final": "local", "strategy": "ipv4_only", }, @@ -51,7 +46,7 @@ def build_hysteria_config(username: str, password: str, "password": f"{username}:{password}", "tls": { "enabled": True, - "server_name": hy2_domain, + "server_name": server_host, "insecure": False, }, }, @@ -71,6 +66,7 @@ def build_hysteria_config(username: str, password: str, }, } + def enable_hysteria(username: str, password: str, server_host: str, config_dir: Path, socks5_port: int, observer=None) -> bool: @@ -99,6 +95,7 @@ def enable_hysteria(username: str, password: str, server_host: str, }) return True + def disable_hysteria(observer=None) -> bool: SingboxRunner().stop() if observer: