Load inbounds from 3x-ui and use panel share links only.

Restore inbound selection from the panel API and send a minimal addClient payload so locally invented fields do not break configs.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
orohi
2026-07-26 03:47:06 +03:00
co-authored by Cursor
parent 8dc090bd67
commit 2707e0af18
7 changed files with 267 additions and 113 deletions
+48 -6
View File
@@ -127,13 +127,16 @@
</div>
<div class="form-group" id="guestInboundGroup" style="{% if settings.guest.create_protocol != 'xui' %}display:none;{% endif %}">
<label class="form-label">{{ _('xui_server_select_label') }}</label>
<select class="form-select" id="guest_create_xui_panel">
<select class="form-select" id="guest_create_xui_panel" onchange="loadGuestInbounds()">
{% for s in xui_servers %}
<option value="{{ s.id }}" {% if settings.guest.create_xui_panel_id == s.id %}selected{% endif %}>{{ s.name }}</option>
{% endfor %}
</select>
<div class="form-hint">{{ _('xui_server_select_hint') }}</div>
<input type="hidden" id="guest_create_inbound_id" value="0">
<label class="form-label" style="margin-top:var(--space-sm);">{{ _('xui_inbound_label') }}</label>
<select class="form-select" id="guest_create_inbound_id">
<option value="0">{{ _('invite_inbound_loading') }}</option>
</select>
<div class="form-hint">{{ _('xui_inbound_hint') }}</div>
</div>
</div>
</div>
@@ -850,9 +853,42 @@
}
}
// Inbound + share link are assigned by the selected 3x-ui panel on create
async function loadXuiInbounds() {}
async function loadGuestInbounds() {}
// Load VLESS inbounds from the selected 3x-ui panel
async function loadXuiInbounds() {
await loadGuestInbounds();
}
async function loadGuestInbounds() {
const select = document.getElementById('guest_create_inbound_id');
if (!select) return;
const preferred = {{ settings.guest.create_inbound_id | default(0) | int }};
select.innerHTML = `<option value="">${_('invite_inbound_loading')}</option>`;
try {
const panelSel = document.getElementById('guest_create_xui_panel');
const panelId = panelSel ? panelSel.value : '';
const q = panelId ? `?panel_id=${encodeURIComponent(panelId)}` : '';
const res = await fetch('/api/settings/xui/inbounds' + q);
const data = await res.json();
if (!res.ok) throw new Error(data.error || 'Failed to load inbounds');
const list = data.inbounds || [];
if (!list.length) {
select.innerHTML = `<option value="">${_('invite_inbound_empty')}</option>`;
return;
}
select.innerHTML = '';
list.forEach((ib, idx) => {
const opt = document.createElement('option');
opt.value = ib.id;
opt.textContent = `${ib.remark || 'VLESS'} (:${ib.port})`;
if (preferred && String(ib.id) === String(preferred)) opt.selected = true;
else if (!preferred && idx === 0) opt.selected = true;
select.appendChild(opt);
});
} catch (err) {
console.warn('loadGuestInbounds:', err);
select.innerHTML = `<option value="">${_('error')}: ${err.message}</option>`;
}
}
document.getElementById('syncCreateConns').addEventListener('change', (e) => {
document.getElementById('autoConnFields').style.display = e.target.checked ? 'block' : 'none';
@@ -1286,6 +1322,12 @@
const v = document.getElementById('guest_create_protocol')?.value;
const group = document.getElementById('guestInboundGroup');
if (group) group.style.display = (v === 'xui') ? 'block' : 'none';
if (v === 'xui') loadGuestInbounds();
}
// Prefill guest inbound list when page opens on 3x-ui
if (document.getElementById('guest_create_protocol')?.value === 'xui') {
loadGuestInbounds();
}
function copyGuestLink() {