fix subdomain
This commit is contained in:
parent
811b285fe6
commit
93fc03c6ca
1 changed files with 6 additions and 9 deletions
|
|
@ -4,22 +4,17 @@ from core.utils.encrypted_proxy.net import get_real_ip, verify_ip
|
||||||
from core.utils.encrypted_proxy.singbox import SingboxRunner
|
from core.utils.encrypted_proxy.singbox import SingboxRunner
|
||||||
import socket
|
import socket
|
||||||
|
|
||||||
|
|
||||||
def _resolve(host: str) -> str:
|
def _resolve(host: str) -> str:
|
||||||
return socket.gethostbyname(host)
|
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,
|
def build_hysteria_config(username: str, password: str,
|
||||||
server_host: str, socks5_port: int) -> dict:
|
server_host: str, socks5_port: int) -> dict:
|
||||||
hy2_domain = _get_hy2_domain(server_host)
|
server_ip = _resolve(server_host)
|
||||||
server_ip = _resolve(hy2_domain)
|
|
||||||
return {
|
return {
|
||||||
"dns": {
|
"dns": {
|
||||||
"servers": [{"tag": "local", "type": "udp", "server": "1.1.1.1"}],
|
"servers": [{"tag": "local", "type": "udp", "server": "9.9.9.9"}],
|
||||||
"final": "local",
|
"final": "local",
|
||||||
"strategy": "ipv4_only",
|
"strategy": "ipv4_only",
|
||||||
},
|
},
|
||||||
|
|
@ -51,7 +46,7 @@ def build_hysteria_config(username: str, password: str,
|
||||||
"password": f"{username}:{password}",
|
"password": f"{username}:{password}",
|
||||||
"tls": {
|
"tls": {
|
||||||
"enabled": True,
|
"enabled": True,
|
||||||
"server_name": hy2_domain,
|
"server_name": server_host,
|
||||||
"insecure": False,
|
"insecure": False,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -71,6 +66,7 @@ def build_hysteria_config(username: str, password: str,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def enable_hysteria(username: str, password: str, server_host: str,
|
def enable_hysteria(username: str, password: str, server_host: str,
|
||||||
config_dir: Path, socks5_port: int,
|
config_dir: Path, socks5_port: int,
|
||||||
observer=None) -> bool:
|
observer=None) -> bool:
|
||||||
|
|
@ -99,6 +95,7 @@ def enable_hysteria(username: str, password: str, server_host: str,
|
||||||
})
|
})
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def disable_hysteria(observer=None) -> bool:
|
def disable_hysteria(observer=None) -> bool:
|
||||||
SingboxRunner().stop()
|
SingboxRunner().stop()
|
||||||
if observer:
|
if observer:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue