Built motion from commit b0a9a629.|2.6.33
[motion2.git] / server / config / license / index.js
index e956b1e..c9ef5ef 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xb003=['update','Disabled','THE\x20LICENSE\x20HAS\x20BEEN\x20DISABLED','Changed','NEW\x20UUID\x20DETECTED:\x20FROM\x20%s\x20TO\x20%s','%s\x20-\x20GRAY\x20PERIOD\x20STARTED\x20AT\x20%s','toUpperCase','encryptString','format','YYYY-MM-DD\x20HH:mm','diff','decryptString','days','DEMO\x20START\x20AT\x20%s','message','finally','getUuid','License','findOrCreate','spread','SERVICE\x20LICENSE\x20STARTED\x20%s','error','default','util','moment','request-promise','pkginfo','version','./hardware','../logger','license','https://www.xcallymotion.com','%s/api/servers/%s/check?version=%s','exports','%s/api/servers/%s/check?version=%s&oldtoken=%s','catch','data2','data1','then','info','THE\x20LICENSE\x20HAS\x20BEEN\x20ENABLED','THE\x20LICENSE\x20HAS\x20BEEN\x20UPDATED'];(function(_0x144b4f,_0x34069c){var _0x5f5978=function(_0x3ecd67){while(--_0x3ecd67){_0x144b4f['push'](_0x144b4f['shift']());}};_0x5f5978(++_0x34069c);}(_0xb003,0xbf));var _0x3b00=function(_0x527ce8,_0x122695){_0x527ce8=_0x527ce8-0x0;var _0x2a8a56=_0xb003[_0x527ce8];return _0x2a8a56;};'use strict';var util=require(_0x3b00('0x0'));var moment=require(_0x3b00('0x1'));var rp=require(_0x3b00('0x2'));var BPromise=require('bluebird');var pkginfo=require(_0x3b00('0x3'))(module,_0x3b00('0x4'));var db=require('../../mysqldb')['db'];var encryptor=require('../../components/encryptor');var hardware=require(_0x3b00('0x5'));var logger=require(_0x3b00('0x6'))(_0x3b00('0x7'));var HOST=_0x3b00('0x8');var TIME=0x3c*0x1388;var DAYS=0x7;var GRAY_PERIOD_REASON;var oldToken;var isOldTokenSent=![];function httpRequest(_0x1f48eb){return new BPromise(function(_0x302807,_0x47c8c6){var _0x4d6696=util['format'](_0x3b00('0x9'),HOST,_0x1f48eb,module[_0x3b00('0xa')][_0x3b00('0x4')]);if(oldToken){_0x4d6696=util['format'](_0x3b00('0xb'),HOST,_0x1f48eb,module['exports'][_0x3b00('0x4')],oldToken);}var _0x8c4e91={'uri':_0x4d6696,'method':'GET','timeout':0xea60,'json':!![]};return rp(_0x8c4e91)['then'](function(_0x218ba2){_0x302807(_0x218ba2);})[_0x3b00('0xc')](function(_0x14660a){_0x47c8c6(_0x14660a);});});}function manageLicense(_0x954b2c,_0x559a02){var _0x344956=_0x559a02['get']({'plain':!![]});if(!isOldTokenSent&&_0x344956['data1']!==_0x954b2c&&!_0x344956[_0x3b00('0xd')]){oldToken=_0x344956[_0x3b00('0xe')];}httpRequest(_0x954b2c)[_0x3b00('0xf')](function(_0x143597){if(oldToken){oldToken=undefined;isOldTokenSent=!![];}if(_0x143597['active']){isOldTokenSent=![];if(!_0x344956[_0x3b00('0x7')]&&_0x344956[_0x3b00('0x7')]!=_0x143597[_0x3b00('0x7')]||_0x344956[_0x3b00('0x7')]&&_0x344956[_0x3b00('0xd')]){logger[_0x3b00('0x10')](_0x3b00('0x11'));}if(_0x344956[_0x3b00('0x7')]&&!_0x344956['data2']&&_0x344956[_0x3b00('0x7')]!=_0x143597[_0x3b00('0x7')]){logger[_0x3b00('0x10')](_0x3b00('0x12'));}if(_0x344956[_0x3b00('0x7')]&&!_0x344956[_0x3b00('0xd')]&&_0x344956[_0x3b00('0x7')]==_0x143597[_0x3b00('0x7')]){return _0x559a02;}return _0x559a02[_0x3b00('0x13')]({'data1':_0x954b2c,'data2':null,'license':_0x143597[_0x3b00('0x7')]});}else{if(_0x143597['license']||_0x344956[_0x3b00('0x7')]){if(!_0x344956[_0x3b00('0xd')]){if(_0x344956[_0x3b00('0xe')]==_0x954b2c){GRAY_PERIOD_REASON=_0x3b00('0x14');logger['info'](_0x3b00('0x15'));}else{GRAY_PERIOD_REASON=_0x3b00('0x16');logger['info'](_0x3b00('0x17'),_0x344956[_0x3b00('0xe')],_0x954b2c);}logger[_0x3b00('0x10')](_0x3b00('0x18'),GRAY_PERIOD_REASON[_0x3b00('0x19')](),moment()['format']('YYYY-MM-DD\x20HH:mm'));return _0x559a02['update']({'data2':encryptor[_0x3b00('0x1a')](moment()[_0x3b00('0x1b')](_0x3b00('0x1c')))});}else{if(moment()[_0x3b00('0x1d')](encryptor[_0x3b00('0x1e')](_0x344956[_0x3b00('0xd')]),_0x3b00('0x1f'))>DAYS){logger['info'](_0x3b00('0x20'),moment()[_0x3b00('0x1b')]('YYYY-MM-DD\x20HH:mm'));isOldTokenSent=![];return _0x559a02[_0x3b00('0x13')]({'data1':_0x954b2c,'data2':null,'license':null});}}}else{if(_0x344956['data1']!=_0x954b2c){logger[_0x3b00('0x10')](_0x3b00('0x17'),_0x344956[_0x3b00('0xe')],_0x954b2c);return _0x559a02[_0x3b00('0x13')]({'data1':_0x954b2c,'data2':null,'license':null});}}}return _0x559a02;})['then'](function(_0x15f593){_0x559a02=_0x15f593;})[_0x3b00('0xc')](function(_0x5131a8){logger['error'](_0x5131a8[_0x3b00('0x21')]);})[_0x3b00('0x22')](function(){setTimeout(function(){manageLicense(hardware[_0x3b00('0x23')](),_0x559a02);},TIME);});}function defaultLicense(){var _0x204147=hardware['getUuid']();if(_0x204147){return db[_0x3b00('0x24')][_0x3b00('0x25')]({'where':{'id':0x1},'defaults':{'data1':_0x204147}})[_0x3b00('0x26')](function(_0x16a619,_0x195d68){logger[_0x3b00('0x10')](_0x3b00('0x27'),_0x204147);manageLicense(_0x204147,_0x16a619);})['catch'](function(_0x1af9df){logger[_0x3b00('0x28')](_0x1af9df[_0x3b00('0x21')]);});}}exports[_0x3b00('0x29')]=defaultLicense;
\ No newline at end of file
+var _0x5d1b=['active','data2','THE\x20LICENSE\x20HAS\x20BEEN\x20ENABLED','info','THE\x20LICENSE\x20HAS\x20BEEN\x20UPDATED','THE\x20LICENSE\x20HAS\x20BEEN\x20DISABLED','Changed','NEW\x20UUID\x20DETECTED:\x20FROM\x20%s\x20TO\x20%s','%s\x20-\x20GRAY\x20PERIOD\x20STARTED\x20AT\x20%s','YYYY-MM-DD\x20HH:mm','update','decryptString','days','DEMO\x20START\x20AT\x20%s','message','getUuid','License','spread','SERVICE\x20LICENSE\x20STARTED\x20%s','error','default','util','request-promise','pkginfo','version','../../mysqldb','../../components/encryptor','./hardware','license','https://www.xcallymotion.com','format','exports','%s/api/servers/%s/check?version=%s&oldtoken=%s','GET','then','get','data1'];(function(_0x24f326,_0x616a7){var _0x488e2d=function(_0x293d9a){while(--_0x293d9a){_0x24f326['push'](_0x24f326['shift']());}};_0x488e2d(++_0x616a7);}(_0x5d1b,0x1ac));var _0xb5d1=function(_0x450817,_0x1d6ce2){_0x450817=_0x450817-0x0;var _0xa30b13=_0x5d1b[_0x450817];return _0xa30b13;};'use strict';var util=require(_0xb5d1('0x0'));var moment=require('moment');var rp=require(_0xb5d1('0x1'));var BPromise=require('bluebird');var pkginfo=require(_0xb5d1('0x2'))(module,_0xb5d1('0x3'));var db=require(_0xb5d1('0x4'))['db'];var encryptor=require(_0xb5d1('0x5'));var hardware=require(_0xb5d1('0x6'));var logger=require('../logger')(_0xb5d1('0x7'));var HOST=_0xb5d1('0x8');var TIME=0x3c*0x1388;var DAYS=0x7;var GRAY_PERIOD_REASON;var oldToken;var isOldTokenSent=![];function httpRequest(_0x1f8637){return new BPromise(function(_0x879f60,_0x23c075){var _0x3b8c60=util[_0xb5d1('0x9')]('%s/api/servers/%s/check?version=%s',HOST,_0x1f8637,module[_0xb5d1('0xa')]['version']);if(oldToken){_0x3b8c60=util[_0xb5d1('0x9')](_0xb5d1('0xb'),HOST,_0x1f8637,module[_0xb5d1('0xa')][_0xb5d1('0x3')],oldToken);}var _0x1735de={'uri':_0x3b8c60,'method':_0xb5d1('0xc'),'timeout':0xea60,'json':!![]};return rp(_0x1735de)[_0xb5d1('0xd')](function(_0x3a5cbe){_0x879f60(_0x3a5cbe);})['catch'](function(_0x2de036){_0x23c075(_0x2de036);});});}function manageLicense(_0x3debf0,_0x3955d9){var _0xb19248=_0x3955d9[_0xb5d1('0xe')]({'plain':!![]});if(!isOldTokenSent&&_0xb19248[_0xb5d1('0xf')]!==_0x3debf0&&!_0xb19248['data2']){oldToken=_0xb19248[_0xb5d1('0xf')];}httpRequest(_0x3debf0)[_0xb5d1('0xd')](function(_0x28e308){if(oldToken){oldToken=undefined;isOldTokenSent=!![];}if(_0x28e308[_0xb5d1('0x10')]){isOldTokenSent=![];if(!_0xb19248[_0xb5d1('0x7')]&&_0xb19248[_0xb5d1('0x7')]!=_0x28e308[_0xb5d1('0x7')]||_0xb19248[_0xb5d1('0x7')]&&_0xb19248[_0xb5d1('0x11')]){logger['info'](_0xb5d1('0x12'));}if(_0xb19248[_0xb5d1('0x7')]&&!_0xb19248[_0xb5d1('0x11')]&&_0xb19248[_0xb5d1('0x7')]!=_0x28e308[_0xb5d1('0x7')]){logger[_0xb5d1('0x13')](_0xb5d1('0x14'));}if(_0xb19248[_0xb5d1('0x7')]&&!_0xb19248[_0xb5d1('0x11')]&&_0xb19248[_0xb5d1('0x7')]==_0x28e308[_0xb5d1('0x7')]){return _0x3955d9;}return _0x3955d9['update']({'data1':_0x3debf0,'data2':null,'license':_0x28e308['license']});}else{if(_0x28e308[_0xb5d1('0x7')]||_0xb19248[_0xb5d1('0x7')]){if(!_0xb19248[_0xb5d1('0x11')]){if(_0xb19248[_0xb5d1('0xf')]==_0x3debf0){GRAY_PERIOD_REASON='Disabled';logger['info'](_0xb5d1('0x15'));}else{GRAY_PERIOD_REASON=_0xb5d1('0x16');logger[_0xb5d1('0x13')](_0xb5d1('0x17'),_0xb19248[_0xb5d1('0xf')],_0x3debf0);}logger[_0xb5d1('0x13')](_0xb5d1('0x18'),GRAY_PERIOD_REASON['toUpperCase'](),moment()[_0xb5d1('0x9')](_0xb5d1('0x19')));return _0x3955d9[_0xb5d1('0x1a')]({'data2':encryptor['encryptString'](moment()[_0xb5d1('0x9')](_0xb5d1('0x19')))});}else{if(moment()['diff'](encryptor[_0xb5d1('0x1b')](_0xb19248[_0xb5d1('0x11')]),_0xb5d1('0x1c'))>DAYS){logger['info'](_0xb5d1('0x1d'),moment()[_0xb5d1('0x9')](_0xb5d1('0x19')));isOldTokenSent=![];return _0x3955d9[_0xb5d1('0x1a')]({'data1':_0x3debf0,'data2':null,'license':null});}}}else{if(_0xb19248[_0xb5d1('0xf')]!=_0x3debf0){logger[_0xb5d1('0x13')](_0xb5d1('0x17'),_0xb19248['data1'],_0x3debf0);return _0x3955d9[_0xb5d1('0x1a')]({'data1':_0x3debf0,'data2':null,'license':null});}}}return _0x3955d9;})['then'](function(_0x490066){_0x3955d9=_0x490066;})['catch'](function(_0x1d3007){logger['error'](_0x1d3007[_0xb5d1('0x1e')]);})['finally'](function(){setTimeout(function(){manageLicense(hardware[_0xb5d1('0x1f')](),_0x3955d9);},TIME);});}function defaultLicense(){var _0x45cdfe=hardware[_0xb5d1('0x1f')]();if(_0x45cdfe){return db[_0xb5d1('0x20')]['findOrCreate']({'where':{'id':0x1},'defaults':{'data1':_0x45cdfe}})[_0xb5d1('0x21')](function(_0x20b787,_0x2c485c){logger[_0xb5d1('0x13')](_0xb5d1('0x22'),_0x45cdfe);manageLicense(_0x45cdfe,_0x20b787);})['catch'](function(_0x5dec58){logger[_0xb5d1('0x23')](_0x5dec58[_0xb5d1('0x1e')]);});}}exports[_0xb5d1('0x24')]=defaultLicense;
\ No newline at end of file