From 1851d551e4df3817c7f6d86a7be35dd28a31ec78 Mon Sep 17 00:00:00 2001 From: Sergey Konovalov Date: Fri, 10 Oct 2025 17:41:27 +0300 Subject: [PATCH] [bug] Fix info page for OpenSource; Fix bug 77514 --- DocService/sources/DocsCoServer.js | 9 +++++++++ DocService/sources/routes/info.js | 15 ++++++++++----- DocService/sources/server.js | 2 +- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/DocService/sources/DocsCoServer.js b/DocService/sources/DocsCoServer.js index 369f5958..ba430cbf 100644 --- a/DocService/sources/DocsCoServer.js +++ b/DocService/sources/DocsCoServer.js @@ -4695,6 +4695,15 @@ exports.shutdown = function (req, res) { } }); }; +/** + * Get active connections array + * @returns {Array} Active connections + */ +function getConnections() { + return connections; +} + +exports.getConnections = getConnections; exports.getEditorConnectionsCount = function (req, res) { const ctx = new operationContext.Context(); let count = 0; diff --git a/DocService/sources/routes/info.js b/DocService/sources/routes/info.js index fd48cfe9..6bb7ac63 100644 --- a/DocService/sources/routes/info.js +++ b/DocService/sources/routes/info.js @@ -54,8 +54,9 @@ function getLicenseNowUtc() { * License info endpoint handler * @param {import('express').Request} req Express request * @param {import('express').Response} res Express response + * @param {Function} getConnections Function to get active connections */ -async function licenseInfo(req, res) { +async function licenseInfo(req, res, getConnections = null) { let isError = false; const serverDate = new Date(); // Security risk of high-precision time @@ -174,7 +175,8 @@ async function licenseInfo(req, res) { const nowUTC = getLicenseNowUtc(); let execRes; execRes = await editorStat.getPresenceUniqueUser(ctx, nowUTC); - output.quota.edit.connectionsCount = await editorStat.getEditorConnectionsCount(ctx, {}); + const connections = getConnections ? getConnections() : null; + output.quota.edit.connectionsCount = await editorStat.getEditorConnectionsCount(ctx, connections); output.quota.edit.usersCount.unique = execRes.length; execRes.forEach(elem => { if (elem.anonym) { @@ -183,7 +185,7 @@ async function licenseInfo(req, res) { }); execRes = await editorStat.getPresenceUniqueViewUser(ctx, nowUTC); - output.quota.view.connectionsCount = await editorStat.getLiveViewerConnectionsCount(ctx, {}); + output.quota.view.connectionsCount = await editorStat.getLiveViewerConnectionsCount(ctx, connections); output.quota.view.usersCount.unique = execRes.length; execRes.forEach(elem => { if (elem.anonym) { @@ -229,13 +231,16 @@ async function licenseInfo(req, res) { /** * Create shared Info router + * @param {Function} getConnections Optional function to get active connections * @returns {import('express').Router} Router instance */ -function createInfoRouter() { +function createInfoRouter(getConnections = null) { const router = express.Router(); // License info endpoint with CORS and client IP check - router.get('/info.json', cors(), utils.checkClientIp, licenseInfo); + router.get('/info.json', cors(), utils.checkClientIp, (req, res) => { + licenseInfo(req, res, getConnections); + }); return router; } diff --git a/DocService/sources/server.js b/DocService/sources/server.js index d1154530..a5773a20 100644 --- a/DocService/sources/server.js +++ b/DocService/sources/server.js @@ -295,7 +295,7 @@ docsCoServer.install(server, app, () => { converterService.builder(req, res); }); // Shared Info router (provides /info.json) - app.use('/info', infoRouter()); + app.use('/info', infoRouter(docsCoServer.getConnections)); app.put('/internal/cluster/inactive', utils.checkClientIp, docsCoServer.shutdown); app.delete('/internal/cluster/inactive', utils.checkClientIp, docsCoServer.shutdown); app.get('/internal/connections/edit', docsCoServer.getEditorConnectionsCount);