Merge pull request #7 from ONLYOFFICE/release/4.0.1

Release/4.0.1
This commit is contained in:
Alexander Trofimov
2016-06-30 15:02:23 +03:00
committed by GitHub
7 changed files with 155 additions and 62 deletions

View File

@ -35,9 +35,14 @@ const fs = require('fs');
const config = require('config').get('license');
const constants = require('./constants');
const buildVersion = '4.0.0';
const buildNumber = 19;
const buildDate = '6/29/2016';
const oBuildDate = new Date(buildDate);
exports.readLicense = function() {
const resMax = {count: 999999, type: constants.LICENSE_RESULT.Success};
var res = {count: 1, type: constants.LICENSE_RESULT.Error};
var res = {count: 1, type: constants.LICENSE_RESULT.Error, light: false};
try {
var oLicense = JSON.parse(fs.readFileSync(config.get('license_file')).toString());
const sign = oLicense['signature'];
@ -48,12 +53,14 @@ exports.readLicense = function() {
const publicKey = '-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDRhGF7X4A0ZVlEg594WmODVVUI\niiPQs04aLmvfg8SborHss5gQXu0aIdUT6nb5rTh5hD2yfpF2WIW6M8z0WxRhwicg\nXwi80H1aLPf6lEPPLvN29EhQNjBpkFkAJUbS8uuhJEeKw0cE49g80eBBF4BCqSL6\nPFQbP9/rByxdxEoAIQIDAQAB\n-----END PUBLIC KEY-----\n';
if (verify.verify(publicKey, sign, 'hex')) {
const endDate = new Date(oLicense['end_date']);
if (endDate >= new Date() && 2 <= oLicense['version']) {
if (endDate >= oBuildDate && 2 <= oLicense['version']) {
res.count = Math.min(Math.max(res.count, oLicense['process'] >> 0), resMax.count);
res.type = constants.LICENSE_RESULT.Success;
} else {
res.type = constants.LICENSE_RESULT.Expired;
}
res.light = !!oLicense['light'];
}
} catch(e) {
res.count = 1;