Add invite links with admin-configurable config creation limits.

Admins can create shareable links that allow redeeming a VPN config a set number of times (or unlimited).

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
orohi
2026-07-26 01:23:16 +03:00
co-authored by Cursor
parent 5386c4d40e
commit 7b3d8aac34
11 changed files with 1197 additions and 0 deletions
+19
View File
@@ -72,5 +72,24 @@ CREATE TABLE IF NOT EXISTS tunnel_state (
data JSONB NOT NULL DEFAULT '{}'::jsonb
);
CREATE TABLE IF NOT EXISTS invite_links (
id UUID PRIMARY KEY,
name TEXT NOT NULL DEFAULT '',
token TEXT NOT NULL UNIQUE,
enabled BOOLEAN NOT NULL DEFAULT TRUE,
max_uses INTEGER NOT NULL DEFAULT 1,
used_count INTEGER NOT NULL DEFAULT 0,
user_id UUID,
protocol TEXT NOT NULL DEFAULT 'xui',
server_id INTEGER NOT NULL DEFAULT 0,
xui_inbound_id INTEGER NOT NULL DEFAULT 0,
password_hash TEXT,
expires_at TIMESTAMPTZ,
note TEXT,
created_at TIMESTAMPTZ
);
CREATE INDEX IF NOT EXISTS idx_invite_links_token ON invite_links(token);
INSERT INTO settings (id, data) VALUES (1, '{}'::jsonb)
ON CONFLICT (id) DO NOTHING;