Remove Hysteria 2 from the panel for now.
Drop the protocol manager, UI, API routes, and related translations until it can be reintroduced cleanly. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -804,8 +804,8 @@ async def wait_for_tunnel_url(provider: str, seconds: int = 20):
|
||||
return get_tunnel_status(provider)
|
||||
|
||||
|
||||
BASE_PROTOCOLS = ['awg', 'awg2', 'awg_legacy', 'xray', 'telemt', 'hysteria', 'dns', 'wireguard', 'socks5', 'adguard', 'nginx']
|
||||
MULTI_INSTANCE_PROTOCOLS = {'awg', 'awg2', 'awg_legacy', 'xray', 'telemt', 'hysteria', 'socks5'}
|
||||
BASE_PROTOCOLS = ['awg', 'awg2', 'awg_legacy', 'xray', 'telemt', 'dns', 'wireguard', 'socks5', 'adguard', 'nginx']
|
||||
MULTI_INSTANCE_PROTOCOLS = {'awg', 'awg2', 'awg_legacy', 'xray', 'telemt', 'socks5'}
|
||||
|
||||
|
||||
def protocol_base(protocol: str) -> str:
|
||||
@@ -845,7 +845,6 @@ def protocol_display_name(protocol: str) -> str:
|
||||
'awg_legacy': 'AmneziaWG Legacy',
|
||||
'xray': 'Xray',
|
||||
'telemt': 'Telemt',
|
||||
'hysteria': 'Hysteria 2',
|
||||
'dns': 'AmneziaDNS',
|
||||
'wireguard': 'WireGuard',
|
||||
'socks5': 'SOCKS5',
|
||||
@@ -865,7 +864,6 @@ def protocol_container_name(protocol: str) -> Optional[str]:
|
||||
'awg_legacy': 'amnezia-awg-legacy',
|
||||
'xray': 'amnezia-xray',
|
||||
'telemt': 'telemt',
|
||||
'hysteria': 'amnezia-hysteria',
|
||||
'dns': 'amnezia-dns',
|
||||
'wireguard': 'amnezia-wireguard',
|
||||
'socks5': 'amnezia-socks5proxy',
|
||||
@@ -905,9 +903,6 @@ def get_protocol_manager(ssh, protocol: str):
|
||||
elif base == 'nginx':
|
||||
from managers.nginx_manager import NginxManager
|
||||
return NginxManager(ssh, protocol)
|
||||
elif base == 'hysteria':
|
||||
from managers.hysteria_manager import HysteriaManager
|
||||
return HysteriaManager(ssh, protocol)
|
||||
from managers.awg_manager import AWGManager
|
||||
return AWGManager(ssh)
|
||||
|
||||
@@ -969,7 +964,7 @@ def _manager_call(manager, method, protocol, *args, **kwargs):
|
||||
|
||||
|
||||
# Protocols that own VPN clients (can list/link connections)
|
||||
CLIENT_VPN_BASES = {'awg', 'awg2', 'awg_legacy', 'xray', 'telemt', 'wireguard', 'hysteria', 'xui'}
|
||||
CLIENT_VPN_BASES = {'awg', 'awg2', 'awg_legacy', 'xray', 'telemt', 'wireguard', 'xui'}
|
||||
|
||||
|
||||
def generate_vpn_link(config_text):
|
||||
@@ -1689,9 +1684,6 @@ class InstallProtocolRequest(BaseModel):
|
||||
# NGINX
|
||||
nginx_domain: Optional[str] = None
|
||||
nginx_email: Optional[str] = None
|
||||
# Hysteria
|
||||
hysteria_domain: Optional[str] = None
|
||||
hysteria_email: Optional[str] = None
|
||||
|
||||
|
||||
class Socks5SettingsRequest(BaseModel):
|
||||
@@ -1701,17 +1693,12 @@ class Socks5SettingsRequest(BaseModel):
|
||||
password: Optional[str] = None
|
||||
|
||||
|
||||
class HysteriaSettingsRequest(BaseModel):
|
||||
protocol: str = 'hysteria'
|
||||
port: Optional[int] = None
|
||||
|
||||
|
||||
class ProtocolRequest(BaseModel):
|
||||
protocol: str = 'awg'
|
||||
|
||||
|
||||
class ContainerLogsRequest(BaseModel):
|
||||
protocol: str = 'hysteria'
|
||||
protocol: str = 'awg'
|
||||
tail: Optional[int] = 200
|
||||
|
||||
|
||||
@@ -2708,13 +2695,6 @@ async def api_check_server(request: Request, server_id: int):
|
||||
for key in ('domain', 'email', 'site_url'):
|
||||
if db_proto.get(key) not in (None, ''):
|
||||
merged[key] = db_proto[key]
|
||||
if protocol_base(proto) == 'hysteria':
|
||||
for key in ('domain', 'email'):
|
||||
if db_proto.get(key) not in (None, '') and not merged.get(key):
|
||||
merged[key] = db_proto[key]
|
||||
# Keep a useful error even when merging preserved records
|
||||
if db_proto.get('port') and not merged.get('port'):
|
||||
merged['port'] = db_proto['port']
|
||||
return merged
|
||||
|
||||
def should_preserve_saved_protocol(proto, result=None, err=None):
|
||||
@@ -2864,13 +2844,6 @@ async def api_install_protocol(request: Request, server_id: int, req: InstallPro
|
||||
domain=req.nginx_domain,
|
||||
email=req.nginx_email,
|
||||
)
|
||||
elif install_base == 'hysteria':
|
||||
result = manager.install_protocol(
|
||||
protocol_type=install_protocol,
|
||||
port=req.port,
|
||||
domain=req.hysteria_domain,
|
||||
email=req.hysteria_email,
|
||||
)
|
||||
else:
|
||||
result = manager.install_protocol(install_protocol, port=req.port)
|
||||
|
||||
@@ -2897,9 +2870,6 @@ async def api_install_protocol(request: Request, server_id: int, req: InstallPro
|
||||
proto_record['domain'] = result.get('domain')
|
||||
proto_record['email'] = result.get('email')
|
||||
proto_record['site_url'] = result.get('site_url')
|
||||
if install_base == 'hysteria':
|
||||
proto_record['domain'] = result.get('domain')
|
||||
proto_record['email'] = result.get('email')
|
||||
proto_record['base_protocol'] = install_base
|
||||
proto_record['instance'] = protocol_instance(install_protocol)
|
||||
proto_record['display_name'] = protocol_display_name(install_protocol)
|
||||
@@ -2975,70 +2945,6 @@ async def api_socks5_update_credentials(request: Request, server_id: int, req: S
|
||||
return JSONResponse({'error': str(e)}, status_code=500)
|
||||
|
||||
|
||||
@app.get('/api/servers/{server_id}/hysteria/settings', tags=["Protocols"])
|
||||
async def api_hysteria_get_settings(request: Request, server_id: int, protocol: str = 'hysteria'):
|
||||
"""Return current Hysteria domain/port for the settings modal."""
|
||||
if not _check_admin(request):
|
||||
return JSONResponse({'error': 'Forbidden'}, status_code=403)
|
||||
try:
|
||||
data = load_data()
|
||||
if server_id >= len(data['servers']):
|
||||
return JSONResponse({'error': 'Server not found'}, status_code=404)
|
||||
if not is_valid_protocol(protocol) or protocol_base(protocol) != 'hysteria':
|
||||
return JSONResponse({'error': 'Invalid protocol'}, status_code=400)
|
||||
server = data['servers'][server_id]
|
||||
ssh = get_ssh(server)
|
||||
ssh.connect()
|
||||
manager = get_protocol_manager(ssh, protocol)
|
||||
settings = manager.get_settings()
|
||||
ssh.disconnect()
|
||||
saved = (server.get('protocols') or {}).get(protocol) or {}
|
||||
if not settings.get('port') and saved.get('port'):
|
||||
settings['port'] = int(saved['port'])
|
||||
return {'status': 'success', **settings}
|
||||
except Exception as e:
|
||||
logger.exception("Error reading Hysteria settings")
|
||||
return JSONResponse({'error': str(e)}, status_code=500)
|
||||
|
||||
|
||||
@app.post('/api/servers/{server_id}/hysteria/settings', tags=["Protocols"])
|
||||
async def api_hysteria_update_settings(request: Request, server_id: int, req: HysteriaSettingsRequest):
|
||||
"""Change Hysteria UDP listen port and recreate the container."""
|
||||
if not _check_admin(request):
|
||||
return JSONResponse({'error': 'Forbidden'}, status_code=403)
|
||||
try:
|
||||
data = load_data()
|
||||
if server_id >= len(data['servers']):
|
||||
return JSONResponse({'error': 'Server not found'}, status_code=404)
|
||||
protocol = req.protocol if is_valid_protocol(req.protocol) and protocol_base(req.protocol) == 'hysteria' else 'hysteria'
|
||||
server = data['servers'][server_id]
|
||||
ssh = get_ssh(server)
|
||||
ssh.connect()
|
||||
manager = get_protocol_manager(ssh, protocol)
|
||||
result = manager.update_settings(port=req.port)
|
||||
ssh.disconnect()
|
||||
if result.get('status') == 'error':
|
||||
return JSONResponse(
|
||||
{'error': result.get('message') or 'Failed to update settings', **{k: v for k, v in result.items() if k != 'status'}},
|
||||
status_code=400,
|
||||
)
|
||||
if result.get('port'):
|
||||
srv_proto = server.setdefault('protocols', {}).setdefault(protocol, {})
|
||||
srv_proto['port'] = str(result['port'])
|
||||
srv_proto['installed'] = True
|
||||
srv_proto['base_protocol'] = protocol_base(protocol)
|
||||
srv_proto['instance'] = protocol_instance(protocol)
|
||||
srv_proto['display_name'] = protocol_display_name(protocol)
|
||||
srv_proto['container_name'] = protocol_container_name(protocol)
|
||||
if result.get('domain'):
|
||||
srv_proto['domain'] = result['domain']
|
||||
save_data(data)
|
||||
return result
|
||||
except Exception as e:
|
||||
logger.exception("Error updating Hysteria settings")
|
||||
return JSONResponse({'error': str(e)}, status_code=500)
|
||||
|
||||
|
||||
@app.post('/api/servers/{server_id}/uninstall', tags=["Protocols"])
|
||||
async def api_uninstall_protocol(request: Request, server_id: int, req: ProtocolRequest):
|
||||
if not _check_admin(request):
|
||||
@@ -3072,7 +2978,6 @@ CONTAINER_NAMES = {
|
||||
'awg_legacy': 'amnezia-awg-legacy',
|
||||
'xray': 'amnezia-xray',
|
||||
'telemt': 'telemt',
|
||||
'hysteria': 'amnezia-hysteria',
|
||||
'dns': 'amnezia-dns',
|
||||
'wireguard': 'amnezia-wireguard',
|
||||
'socks5': 'amnezia-socks5proxy',
|
||||
@@ -3222,41 +3127,13 @@ async def api_container_toggle(request: Request, server_id: int, req: ProtocolRe
|
||||
ssh.run_sudo_command(f"docker stop {container}")
|
||||
action = 'stopped'
|
||||
else:
|
||||
# Hysteria: recreate with host network / current config instead of plain start
|
||||
if protocol_base(req.protocol) == 'hysteria':
|
||||
from managers.hysteria_manager import HysteriaManager
|
||||
mgr = HysteriaManager(ssh, req.protocol)
|
||||
meta = mgr._read_metadata()
|
||||
port = int(meta.get('port') or mgr.DEFAULT_PORT)
|
||||
mgr._write_config_from_clients(port)
|
||||
mgr._start_container(port)
|
||||
else:
|
||||
ssh.run_sudo_command(f"docker start {container}")
|
||||
ssh.run_sudo_command(f"docker start {container}")
|
||||
action = 'started'
|
||||
# After stop/start, return diagnostics for UI
|
||||
error = ''
|
||||
recent_logs = ''
|
||||
if protocol_base(req.protocol) == 'hysteria':
|
||||
from managers.hysteria_manager import HysteriaManager
|
||||
mgr = HysteriaManager(ssh, req.protocol)
|
||||
diag = mgr.get_container_diagnostics(req.protocol)
|
||||
error = diag.get('error_summary') or ''
|
||||
recent_logs = diag.get('recent_logs') or ''
|
||||
if action == 'started' and not diag.get('running'):
|
||||
ssh.disconnect()
|
||||
return JSONResponse({
|
||||
'error': error or 'Hysteria failed to start',
|
||||
'action': action,
|
||||
'container': container,
|
||||
'recent_logs': recent_logs,
|
||||
}, status_code=400)
|
||||
ssh.disconnect()
|
||||
return {
|
||||
'status': 'success',
|
||||
'action': action,
|
||||
'container': container,
|
||||
'error': error,
|
||||
'recent_logs': recent_logs,
|
||||
}
|
||||
except Exception as e:
|
||||
logger.exception("Error toggling container")
|
||||
@@ -3278,23 +3155,7 @@ async def api_container_logs(request: Request, server_id: int, req: ContainerLog
|
||||
container = protocol_container_name(req.protocol)
|
||||
ssh = get_ssh(server)
|
||||
ssh.connect()
|
||||
if protocol_base(req.protocol) == 'hysteria':
|
||||
from managers.hysteria_manager import HysteriaManager
|
||||
mgr = HysteriaManager(ssh, req.protocol)
|
||||
logs = mgr.get_logs(req.protocol, tail=req.tail or 200)
|
||||
diag = mgr.get_container_diagnostics(req.protocol)
|
||||
ssh.disconnect()
|
||||
return {
|
||||
'status': 'success',
|
||||
'protocol': req.protocol,
|
||||
'container': container,
|
||||
'logs': logs,
|
||||
'running': bool(diag.get('running')),
|
||||
'error': diag.get('error_summary') or '',
|
||||
'exit_code': diag.get('exit_code'),
|
||||
'container_status': diag.get('status') or '',
|
||||
}
|
||||
# Generic fallback for other protocols
|
||||
# Generic docker logs for all protocols
|
||||
tail = max(20, min(int(req.tail or 200), 2000))
|
||||
out, err, _ = ssh.run_sudo_command(
|
||||
f"docker logs --tail {tail} --timestamps {shlex.quote(container)} 2>&1",
|
||||
@@ -3318,7 +3179,7 @@ async def api_container_logs(request: Request, server_id: int, req: ContainerLog
|
||||
|
||||
|
||||
@app.get('/api/servers/{server_id}/container/logs/stream', tags=["Protocols"])
|
||||
async def api_container_logs_stream(request: Request, server_id: int, protocol: str = 'hysteria', tail: int = 100):
|
||||
async def api_container_logs_stream(request: Request, server_id: int, protocol: str = 'awg', tail: int = 100):
|
||||
"""SSE stream of docker logs (polls every ~1.5s for new lines)."""
|
||||
if not _check_admin(request):
|
||||
return JSONResponse({'error': 'Forbidden'}, status_code=403)
|
||||
@@ -3415,10 +3276,6 @@ async def api_server_config(request: Request, server_id: int, req: ProtocolReque
|
||||
from managers.nginx_manager import NginxManager
|
||||
mgr = NginxManager(ssh, req.protocol)
|
||||
config = mgr._get_server_config(req.protocol)
|
||||
elif protocol_base(req.protocol) == 'hysteria':
|
||||
from managers.hysteria_manager import HysteriaManager
|
||||
mgr = HysteriaManager(ssh, req.protocol)
|
||||
config = mgr.get_server_config(req.protocol)
|
||||
else:
|
||||
mgr = AWGManager(ssh)
|
||||
config = mgr._get_server_config(req.protocol)
|
||||
@@ -3463,10 +3320,6 @@ async def api_server_config_save(request: Request, server_id: int, req: ServerCo
|
||||
from managers.nginx_manager import NginxManager
|
||||
mgr = NginxManager(ssh, req.protocol)
|
||||
mgr.save_server_config(req.protocol, req.config)
|
||||
elif protocol_base(req.protocol) == 'hysteria':
|
||||
from managers.hysteria_manager import HysteriaManager
|
||||
mgr = HysteriaManager(ssh, req.protocol)
|
||||
mgr.save_server_config(req.protocol, req.config)
|
||||
else:
|
||||
mgr = AWGManager(ssh)
|
||||
mgr.save_server_config(req.protocol, req.config)
|
||||
|
||||
Reference in New Issue
Block a user