Hotfix(sub): Display correct user data on blocked page

This commit is contained in:
Whispering Wind
2025-08-18 15:56:26 +03:30
committed by GitHub
parent d41a6a05ba
commit 40ce17deea
2 changed files with 63 additions and 27 deletions

View File

@ -124,6 +124,7 @@ class TemplateContext:
expiration_date: str expiration_date: str
sublink_qrcode: str sublink_qrcode: str
sub_link: str sub_link: str
blocked: bool = False
local_uris: List[NodeURI] = field(default_factory=list) local_uris: List[NodeURI] = field(default_factory=list)
node_uris: List[NodeURI] = field(default_factory=list) node_uris: List[NodeURI] = field(default_factory=list)
@ -558,7 +559,7 @@ class HysteriaServer:
return web.Response(status=404, text=f"User '{username}' details not found.") return web.Response(status=404, text=f"User '{username}' details not found.")
if user_info.blocked: if user_info.blocked:
return await self._handle_blocked_user(request) return await self._handle_blocked_user(request, user_info)
user_agent = request.headers.get('User-Agent', '').lower() user_agent = request.headers.get('User-Agent', '').lower()
if any(browser in user_agent for browser in ['chrome', 'firefox', 'safari', 'edge', 'opera']): if any(browser in user_agent for browser in ['chrome', 'firefox', 'safari', 'edge', 'opera']):
@ -573,12 +574,12 @@ class HysteriaServer:
print(f"Internal Server Error: {e}") print(f"Internal Server Error: {e}")
return web.Response(status=500, text="Error: Internal server error") return web.Response(status=500, text="Error: Internal server error")
async def _handle_blocked_user(self, request: web.Request) -> web.Response: async def _handle_blocked_user(self, request: web.Request, user_info: UserInfo) -> web.Response:
fake_uri = "hysteria2://x@end.com:443?sni=support.me#⛔Account-Expired⚠" fake_uri = "hysteria2://x@end.com:443?sni=support.me#⛔Account-Expired⚠"
user_agent = request.headers.get('User-Agent', '').lower() user_agent = request.headers.get('User-Agent', '').lower()
if any(browser in user_agent for browser in ['chrome', 'firefox', 'safari', 'edge', 'opera']): if any(browser in user_agent for browser in ['chrome', 'firefox', 'safari', 'edge', 'opera']):
context = self._get_blocked_template_context(fake_uri) context = self._get_blocked_template_context(fake_uri, user_info)
return web.Response(text=self.template_renderer.render(context), content_type='text/html') return web.Response(text=self.template_renderer.render(context), content_type='text/html')
fragment = request.query.get('fragment', '') fragment = request.query.get('fragment', '')
@ -588,19 +589,20 @@ class HysteriaServer:
return web.Response(text=fake_uri, content_type='text/plain') return web.Response(text=fake_uri, content_type='text/plain')
def _get_blocked_template_context(self, fake_uri: str) -> TemplateContext: def _get_blocked_template_context(self, fake_uri: str, user_info: UserInfo) -> TemplateContext:
return TemplateContext( return TemplateContext(
username="blocked", username=user_info.username,
usage="N/A", usage=user_info.usage_human_readable,
usage_raw="This account has been suspended.", usage_raw="This account has been suspended.",
expiration_date="N/A", expiration_date=user_info.expiration_date,
sublink_qrcode=Utils.generate_qrcode_base64("blocked"), sublink_qrcode="",
sub_link="#blocked", sub_link="#blocked",
blocked=True,
local_uris=[ local_uris=[
NodeURI( NodeURI(
label="Blocked", label="Blocked",
uri=fake_uri, uri=fake_uri,
qrcode=Utils.generate_qrcode_base64(fake_uri) qrcode=None
) )
], ],
node_uris=[] node_uris=[]
@ -656,6 +658,7 @@ class HysteriaServer:
expiration_date=user_info.expiration_date, expiration_date=user_info.expiration_date,
sublink_qrcode=sublink_qrcode, sublink_qrcode=sublink_qrcode,
sub_link=sub_link, sub_link=sub_link,
blocked=user_info.blocked,
local_uris=local_uris, local_uris=local_uris,
node_uris=node_uris node_uris=node_uris
) )

View File

@ -11,6 +11,7 @@
:root { :root {
--primary-gradient: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%); --primary-gradient: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
--secondary-gradient: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%); --secondary-gradient: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
--danger-color: #ef4444;
--card-bg-light: #ffffff; --card-bg-light: #ffffff;
--card-bg-dark: #1f2937; --card-bg-dark: #1f2937;
--text-light: #1f2937; --text-light: #1f2937;
@ -188,6 +189,10 @@
gap: 0.75rem; gap: 0.75rem;
} }
.qr-header.blocked {
background: var(--danger-color);
}
.qr-content { .qr-content {
padding: 2rem; padding: 2rem;
} }
@ -213,10 +218,18 @@
margin-bottom: 1rem; margin-bottom: 1rem;
} }
.qr-title.blocked {
color: var(--danger-color);
}
.dark-mode .qr-title { .dark-mode .qr-title {
color: #818cf8; color: #818cf8;
} }
.dark-mode .qr-title.blocked {
color: #f87171;
}
.qrcode { .qrcode {
max-width: 200px; max-width: 200px;
padding: 1rem; padding: 1rem;
@ -361,12 +374,18 @@
</div> </div>
<div class="qr-section"> <div class="qr-section">
<div class="qr-header"> <div class="qr-header {% if blocked %}blocked{% endif %}">
<i class="fas fa-link"></i> <i class="fas fa-link"></i>
Subscription Link Subscription Link
</div> </div>
<div class="qr-content"> <div class="qr-content">
<div class="qr-grid"> <div class="qr-grid">
{% if blocked %}
<div class="qr-item" style="grid-column: 1 / -1;">
<h3 class="qr-title blocked">Account Suspended</h3>
<p class="card-text">Your subscription link is disabled. Please contact support.</p>
</div>
{% else %}
<div class="qr-item" style="grid-column: 1 / -1;"> <div class="qr-item" style="grid-column: 1 / -1;">
<h3 class="qr-title">Universal Subscription Link</h3> <h3 class="qr-title">Universal Subscription Link</h3>
<img src="{{ sublink_qrcode }}" alt="Subscription QR Code" class="qrcode"> <img src="{{ sublink_qrcode }}" alt="Subscription QR Code" class="qrcode">
@ -376,17 +395,30 @@
</button> </button>
</div> </div>
</div> </div>
{% endif %}
</div> </div>
</div> </div>
</div> </div>
<div class="qr-section"> <div class="qr-section">
<div class="qr-header"> <div class="qr-header {% if blocked %}blocked{% endif %}">
<i class="fas fa-server"></i> <i class="fas fa-server"></i>
{% if blocked %}
Connection Status
{% else %}
Local Server Connections Local Server Connections
{% endif %}
</div> </div>
<div class="qr-content"> <div class="qr-content">
<div class="qr-grid"> <div class="qr-grid">
{% if blocked %}
{% for item in local_uris %}
<div class="qr-item" style="grid-column: 1 / -1;">
<h3 class="qr-title blocked">{{ item.label }}</h3>
<p class="card-text">{{ usage_raw }}</p>
</div>
{% endfor %}
{% else %}
{% for item in local_uris %} {% for item in local_uris %}
<div class="qr-item"> <div class="qr-item">
<h3 class="qr-title">{{ item.label }} URI</h3> <h3 class="qr-title">{{ item.label }} URI</h3>
@ -402,11 +434,12 @@
{% endif %} {% endif %}
</div> </div>
{% endfor %} {% endfor %}
{% endif %}
</div> </div>
</div> </div>
</div> </div>
{% if node_uris %} {% if node_uris and not blocked %}
<div class="qr-section"> <div class="qr-section">
<div class="qr-header"> <div class="qr-header">
<i class="fas fa-globe-americas"></i> <i class="fas fa-globe-americas"></i>