diff --git a/Common/config/default.json b/Common/config/default.json index 359b3479..a50763da 100644 --- a/Common/config/default.json +++ b/Common/config/default.json @@ -182,7 +182,8 @@ } }, "license" : { - "license_file": "" + "license_file": "", + "warning_limit_percents": "70" }, "FileConverter": { "converter": { diff --git a/Common/config/development-mac.json b/Common/config/development-mac.json index d967cf01..284e9b75 100644 --- a/Common/config/development-mac.json +++ b/Common/config/development-mac.json @@ -47,7 +47,8 @@ } }, "license": { - "license_file": "./../../license.lic" + "license_file": "./../../license.lic", + "warning_limit_percents": "70" }, "FileConverter": { "converter": { diff --git a/Common/config/development-windows.json b/Common/config/development-windows.json index 0733cb5d..179d3d3a 100644 --- a/Common/config/development-windows.json +++ b/Common/config/development-windows.json @@ -47,7 +47,8 @@ } }, "license": { - "license_file": "./../../license.lic" + "license_file": "./../../license.lic", + "warning_limit_percents": "70" }, "FileConverter": { "converter": { diff --git a/Common/config/production-linux.json b/Common/config/production-linux.json index 1b083c61..2f4a42f1 100644 --- a/Common/config/production-linux.json +++ b/Common/config/production-linux.json @@ -42,7 +42,8 @@ } }, "license": { - "license_file": "/var/www/onlyoffice/Data/license.lic" + "license_file": "/var/www/onlyoffice/Data/license.lic", + "warning_limit_percents": "70" }, "FileConverter": { "converter": { diff --git a/Common/config/production-windows.json b/Common/config/production-windows.json index b581531e..77cfde6f 100644 --- a/Common/config/production-windows.json +++ b/Common/config/production-windows.json @@ -42,7 +42,8 @@ } }, "license": { - "license_file": "./../../license.lic" + "license_file": "./../../license.lic", + "warning_limit_percents": "70" }, "FileConverter": { "converter": { diff --git a/Common/sources/license.js b/Common/sources/license.js index 54deebf3..1e689132 100644 --- a/Common/sources/license.js +++ b/Common/sources/license.js @@ -127,7 +127,7 @@ exports.readLicense = function*() { } if (res.type === c_LR.Expired || res.type === c_LR.ExpiredTrial) { res.count = 1; - logger.error('License Expired!!!'); + logger.error('License: License Expired!!!'); } if (checkFile) { diff --git a/DocService/sources/DocsCoServer.js b/DocService/sources/DocsCoServer.js index 6c22af69..cf000488 100644 --- a/DocService/sources/DocsCoServer.js +++ b/DocService/sources/DocsCoServer.js @@ -143,6 +143,7 @@ const cfgForceSaveStep = ms(config.get('autoAssembly.step')); const cfgQueueRetentionPeriod = configCommon.get('queue.retentionPeriod'); const cfgForgottenFiles = config.get('server.forgottenfiles'); const cfgMaxRequestChanges = config.get('server.maxRequestChanges'); +const cfgWarningLimitPercents = configCommon.get('license.warning_limit_percents') / 100; const redisKeySaveLock = cfgRedisPrefix + constants.REDIS_KEY_SAVE_LOCK; const redisKeyPresenceHash = cfgRedisPrefix + constants.REDIS_KEY_PRESENCE_HASH; @@ -2695,6 +2696,7 @@ exports.install = function(server, callbackFunction) { } function* _checkLicenseAuth(userId) { + let licenseWarningLimit = false; const c_LR = constants.LICENSE_RESULT; let licenseType = licenseInfo.type; if (licenseInfo.usersCount) { @@ -2712,6 +2714,7 @@ exports.install = function(server, callbackFunction) { } else { licenseType = -1 === execRes[0].indexOf(userId) ? c_LR.UsersCount : c_LR.Success; } + licenseWarningLimit = licenseInfo.usersCount * cfgWarningLimitPercents <= execRes[0].length; } } else { // Warning. Cluster version or if workers > 1 will work with increasing numbers. @@ -2727,6 +2730,7 @@ exports.install = function(server, callbackFunction) { return true !== el.isCloseCoAuthoring && el.user.view !== true; })).length; licenseType = (connectionsCount > editConnectionsCount) ? licenseType : c_LR.Connections; + licenseWarningLimit = connectionsCount * cfgWarningLimitPercents <= editConnectionsCount; } /*if (constants.PACKAGE_TYPE_OS === licenseInfo.packageType && c_LR.Error === licenseType) { licenseType = c_LR.SuccessLimit; @@ -2760,6 +2764,14 @@ exports.install = function(server, callbackFunction) { } }*/ } + + if (c_LR.UsersCount === licenseType) { + logger.error('License: User limit exceeded!!!'); + } else if (c_LR.Connections === licenseType) { + logger.error('License: Connection limit exceeded!!!'); + } else if (licenseWarningLimit) { + logger.warn('License: Warning limit exceeded!!!'); + } return licenseType; }