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:
@@ -3905,12 +3905,14 @@ async def api_add_user_connection(request: Request, user_id: str, req: AddUserCo
|
||||
config = await xui_get_config(data.get('settings', {}), req.client_id, panel_id=panel_id)
|
||||
result = {'client_id': req.client_id, 'config': config, 'subscription_url': config if str(config).startswith('http') else ''}
|
||||
else:
|
||||
inbound = req.xui_inbound_id or panel.get('default_inbound_id') or None
|
||||
if not inbound:
|
||||
return JSONResponse({'error': 'Select a VLESS inbound from 3x-ui'}, status_code=400)
|
||||
from managers.xui_api import xui_create_vless_config
|
||||
created = await xui_create_vless_config(
|
||||
data.get('settings', {}),
|
||||
name=req.name or user.get('username') or 'user',
|
||||
# Optional hint only — panel assigns inbound + share link
|
||||
inbound_id=req.xui_inbound_id or panel.get('default_inbound_id') or None,
|
||||
inbound_id=inbound,
|
||||
panel_id=panel_id,
|
||||
)
|
||||
result = {
|
||||
@@ -4498,8 +4500,9 @@ async def _create_config_for_protocol(
|
||||
if not panel:
|
||||
raise RuntimeError('Add a 3x-ui server in Settings first')
|
||||
panel_id = panel.get('id') or ''
|
||||
# Prefer invite/default inbound; otherwise 3x-ui picks first VLESS on that panel
|
||||
inbound = xui_inbound_id or panel.get('default_inbound_id') or None
|
||||
inbound = int(xui_inbound_id or 0) or int(panel.get('default_inbound_id') or 0) or None
|
||||
if not inbound:
|
||||
raise RuntimeError('Select a VLESS inbound from 3x-ui')
|
||||
expiry_ms = _expiry_ms_from_duration_days(duration_days)
|
||||
created = await xui_create_vless_config(
|
||||
data.get('settings', {}),
|
||||
@@ -4611,9 +4614,10 @@ async def api_create_invite(request: Request, req: InviteCreateRequest):
|
||||
if not panel:
|
||||
return JSONResponse({'error': 'Add a 3x-ui server in Settings first'}, status_code=400)
|
||||
panel_id = panel.get('id') or ''
|
||||
# Inbound is optional — 3x-ui panel assigns it (or uses server default) on redeem
|
||||
if not inbound_id:
|
||||
inbound_id = int(panel.get('default_inbound_id') or 0)
|
||||
if not inbound_id:
|
||||
return JSONResponse({'error': 'Select a VLESS inbound from 3x-ui'}, status_code=400)
|
||||
link = {
|
||||
'id': str(uuid.uuid4()),
|
||||
'name': (req.name or 'Invite').strip() or 'Invite',
|
||||
@@ -4686,6 +4690,10 @@ async def api_update_invite(request: Request, invite_id: str, req: InviteUpdateR
|
||||
return JSONResponse({'error': 'Add a 3x-ui server in Settings first'}, status_code=400)
|
||||
if not link.get('xui_panel_id'):
|
||||
link['xui_panel_id'] = panel.get('id') or ''
|
||||
if not int(link.get('xui_inbound_id') or 0):
|
||||
link['xui_inbound_id'] = int(panel.get('default_inbound_id') or 0)
|
||||
if not int(link.get('xui_inbound_id') or 0):
|
||||
return JSONResponse({'error': 'Select a VLESS inbound from 3x-ui'}, status_code=400)
|
||||
save_data(data)
|
||||
return {'status': 'success', 'invite': _invite_public_view(link)}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user