Skip to content

Commit ce33688

Browse files
committed
fix: hide Hysteria ACME block on Xray node form
Do not leak panel ACME_EMAIL into the Let's Encrypt field placeholder.
1 parent 4d3c4c7 commit ce33688

3 files changed

Lines changed: 17 additions & 9 deletions

File tree

src/routes/panel/nodes.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,6 @@ router.get('/nodes/add', async (req, res) => {
412412
cascadeLinks: [],
413413
error: req.query.error || null,
414414
panelDomain: config.PANEL_DOMAIN || '',
415-
panelAcmeEmail: config.ACME_EMAIL || '',
416415
lastInitScript: settings?.lastInitScript || '',
417416
canAddPairedProtocol: false,
418417
});
@@ -903,7 +902,6 @@ router.get('/nodes/:id', async (req, res) => {
903902
cascadeLinks: cascadeLinks || [],
904903
error: req.query.error || null,
905904
panelDomain: config.PANEL_DOMAIN || '',
906-
panelAcmeEmail: config.ACME_EMAIL || '',
907905
lastInitScript: settings?.lastInitScript || '',
908906
canAddPairedProtocol,
909907
xrayUpdateTotpEnabled: !!currentAdmin?.twoFactor?.enabled,

views/partials/node-form/scripts.ejs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1289,9 +1289,15 @@ function useLastInitScript() {
12891289
}
12901290
12911291
function toggleAcmeByDomain() {
1292+
// Hysteria-only ACME knobs. Xray ACME lives under tlsSource==='acme'
1293+
// (xrayTlsAcmeBlock). Must not re-show this block just because the
1294+
// shared Domain field is filled — that is how Xray operators ended up
1295+
// seeing two email fields.
1296+
const proto = document.querySelector('input[name="type"]:checked')?.value || 'hysteria';
1297+
const isHysteria = proto === 'hysteria';
12921298
const domain = (document.getElementById('domain')?.value || '').trim();
12931299
const toggleGroup = document.getElementById('acmeAdvancedToggleGroup');
1294-
if (toggleGroup) toggleGroup.style.display = domain ? '' : 'none';
1300+
if (toggleGroup) toggleGroup.style.display = (isHysteria && domain) ? '' : 'none';
12951301
12961302
if (!domain) {
12971303
const cb = document.getElementById('acmeAdvancedEnabled');
@@ -1303,11 +1309,13 @@ function toggleAcmeByDomain() {
13031309
}
13041310
13051311
function toggleAcmeAdvancedFields() {
1312+
const proto = document.querySelector('input[name="type"]:checked')?.value || 'hysteria';
13061313
const domain = (document.getElementById('domain')?.value || '').trim();
13071314
const enabled = !!document.getElementById('acmeAdvancedEnabled')?.checked;
13081315
const wrap = document.getElementById('acmeAdvancedFieldsWrap');
1309-
if (wrap) wrap.style.display = (domain && enabled) ? '' : 'none';
1310-
if (domain && enabled) toggleAcmeTypeFields();
1316+
const show = proto === 'hysteria' && domain && enabled;
1317+
if (wrap) wrap.style.display = show ? '' : 'none';
1318+
if (show) toggleAcmeTypeFields();
13111319
}
13121320
13131321
function toggleAcmeTypeFields() {

views/partials/node-form/xray.ejs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
<%# TLS Source (only when security==='tls'): panel | acme | manual | self-signed %>
4444
<% var _tlsSource = node?.xray?.tlsSource || 'panel'; %>
4545
<% var _panelDomain = (typeof panelDomain === 'string' ? panelDomain : '') || ''; %>
46-
<% var _panelAcmeEmail = (typeof panelAcmeEmail === 'string' ? panelAcmeEmail : '') || ''; %>
4746
<% var _hasManualKey = !!(node?.xray && (node.xray.manualKeySet === true || node.xray.manualKey)); %>
4847
<% var _anyTls = node?.xray?.security === 'tls' || (node?.xray?.extraInbounds || []).some(function(i){ return i && i.security === 'tls'; }); %>
4948
<div class="form-group xray-tls-config" id="xrayTlsConfig" style="<%= _anyTls ? '' : 'display:none' %>">
@@ -103,12 +102,15 @@
103102
</div>
104103
<div class="form-group">
105104
<label for="xrayAcmeEmail"><%= t('nodes.xrayTlsAcmeEmailLabel') %></label>
106-
<%# type=text: Chrome validates type=email even when hidden, blocking submit on mode switch. %>
105+
<%# type=text: Chrome validates type=email even when hidden, blocking submit on mode switch.
106+
readonly-until-focus: Chrome otherwise autofills the operator's Google
107+
account into any field whose name contains "email". %>
107108
<input type="text" id="xrayAcmeEmail" name="xray.acmeEmail"
108109
value="<%= node?.xray?.acmeEmail || '' %>"
109-
placeholder="<%= _panelAcmeEmail || 'admin@example.com' %>"
110+
placeholder="admin@example.com"
110111
maxlength="254" autocomplete="off" spellcheck="false"
111-
inputmode="email">
112+
inputmode="email" readonly
113+
onfocus="this.removeAttribute('readonly')">
112114
<small><%= t('nodes.xrayTlsAcmeEmailHint') %></small>
113115
</div>
114116
</div>

0 commit comments

Comments
 (0)