From 2f38cd58a31c19ee3525c678e18e1d6e32c32fb8 Mon Sep 17 00:00:00 2001 From: infosave2007 Date: Thu, 29 Jan 2026 08:56:28 +0300 Subject: [PATCH] feat: Added readme API new endpoints --- README.md | 12 ++++++++++-- public/index.php | 10 ++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 23500b2..8a9c206 100644 --- a/README.md +++ b/README.md @@ -253,16 +253,24 @@ DELETE /api/servers/{id}/delete - Delete server by ID GET /api/servers/{id}/clients - List clients on server ``` +### Protocols +``` +GET /api/protocols/active - List all available protocols (with IDs) +GET /api/servers/{id}/protocols - List installed protocols on server +POST /api/servers/{id}/protocols/install - Install protocol +``` + ### Clients ``` GET /api/clients - List all clients GET /api/clients/{id}/details - Get client details with stats, config and QR code GET /api/clients/{id}/qr - Get client QR code POST /api/clients/create - Create new client (returns config and QR code) - Parameters: server_id, name, expires_in_days (optional) + Parameters: server_id, name, protocol_id (optional, default: installed), expires_in_days (optional) POST /api/clients/{id}/revoke - Revoke client access POST /api/clients/{id}/restore - Restore client access -DELETE /api/clients/{id}/delete - Delete client by ID +DELETE /api/clients/{id}/delete - Delete client by ID (removes from DB and server) +POST /api/clients/{id}/set-expiration - Set client expiration date POST /api/clients/{id}/set-expiration - Set client expiration date Parameters: expires_at (Y-m-d H:i:s or null) POST /api/clients/{id}/extend - Extend client expiration diff --git a/public/index.php b/public/index.php index f5a0206..871925a 100644 --- a/public/index.php +++ b/public/index.php @@ -1706,6 +1706,16 @@ Router::get('/api/servers', function () { return; $servers = VpnServer::listByUser($user['id']); + + // Enrich with installed protocols + $pdo = DB::conn(); + foreach ($servers as &$server) { + $stmt = $pdo->prepare('SELECT p.id, p.slug, p.name FROM server_protocols sp JOIN protocols p ON p.id = sp.protocol_id WHERE sp.server_id = ?'); + $stmt->execute([$server['id']]); + $server['protocols'] = $stmt->fetchAll(PDO::FETCH_ASSOC); + } + unset($server); + echo json_encode(['servers' => $servers]); });