Built motion from commit 00bf23f6.|2.6.16
[motion2.git] / server / config / license / index.js
index 2a62d36..afdc8b2 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x4b65=['moment','request-promise','bluebird','pkginfo','../../mysqldb','../../components/encryptor','./hardware','license','https://www.xcallymotion.com','%s/api/servers/%s/check?version=%s','exports','format','%s/api/servers/%s/check?version=%s&oldtoken=%s','GET','then','catch','get','data1','data2','active','info','THE\x20LICENSE\x20HAS\x20BEEN\x20ENABLED','update','Disabled','THE\x20LICENSE\x20HAS\x20BEEN\x20DISABLED','Changed','%s\x20-\x20GRAY\x20PERIOD\x20STARTED\x20AT\x20%s','toUpperCase','YYYY-MM-DD\x20HH:mm','encryptString','diff','days','DEMO\x20START\x20AT\x20%s','NEW\x20UUID\x20DETECTED:\x20FROM\x20%s\x20TO\x20%s','message','getUuid','spread','SERVICE\x20LICENSE\x20STARTED\x20%s','error','default'];(function(_0x338f73,_0x1945c8){var _0x163fdf=function(_0x4cd033){while(--_0x4cd033){_0x338f73['push'](_0x338f73['shift']());}};_0x163fdf(++_0x1945c8);}(_0x4b65,0xf0));var _0x54b6=function(_0x2385a5,_0x4512ea){_0x2385a5=_0x2385a5-0x0;var _0x22622c=_0x4b65[_0x2385a5];return _0x22622c;};'use strict';var util=require('util');var moment=require(_0x54b6('0x0'));var rp=require(_0x54b6('0x1'));var BPromise=require(_0x54b6('0x2'));var pkginfo=require(_0x54b6('0x3'))(module,'version');var db=require(_0x54b6('0x4'))['db'];var encryptor=require(_0x54b6('0x5'));var hardware=require(_0x54b6('0x6'));var logger=require('../logger')(_0x54b6('0x7'));var HOST=_0x54b6('0x8');var TIME=0x3c*0x1388;var DAYS=0x7;var GRAY_PERIOD_REASON;var oldToken;var isOldTokenSent=![];function httpRequest(_0x48b06c){return new BPromise(function(_0x41706c,_0x248fe7){var _0x50e1dc=util['format'](_0x54b6('0x9'),HOST,_0x48b06c,module[_0x54b6('0xa')]['version']);if(oldToken){_0x50e1dc=util[_0x54b6('0xb')](_0x54b6('0xc'),HOST,_0x48b06c,module[_0x54b6('0xa')]['version'],oldToken);}var _0x15e554={'uri':_0x50e1dc,'method':_0x54b6('0xd'),'timeout':0xea60,'json':!![]};return rp(_0x15e554)[_0x54b6('0xe')](function(_0x13d9c1){_0x41706c(_0x13d9c1);})[_0x54b6('0xf')](function(_0x5dd9b0){_0x248fe7(_0x5dd9b0);});});}function manageLicense(_0x22caf5,_0x44cb4e){var _0x3e8179=_0x44cb4e[_0x54b6('0x10')]({'plain':!![]});if(!isOldTokenSent&&_0x3e8179[_0x54b6('0x11')]!==_0x22caf5&&!_0x3e8179[_0x54b6('0x12')]){oldToken=_0x3e8179['data1'];}httpRequest(_0x22caf5)[_0x54b6('0xe')](function(_0x138655){if(oldToken){oldToken=undefined;isOldTokenSent=!![];}if(_0x138655[_0x54b6('0x13')]){isOldTokenSent=![];if(!_0x3e8179[_0x54b6('0x7')]&&_0x3e8179[_0x54b6('0x7')]!=_0x138655[_0x54b6('0x7')]||_0x3e8179['license']&&_0x3e8179[_0x54b6('0x12')]){logger[_0x54b6('0x14')](_0x54b6('0x15'));}if(_0x3e8179[_0x54b6('0x7')]&&!_0x3e8179['data2']&&_0x3e8179['license']!=_0x138655['license']){logger[_0x54b6('0x14')]('THE\x20LICENSE\x20HAS\x20BEEN\x20UPDATED');}if(_0x3e8179[_0x54b6('0x7')]&&!_0x3e8179[_0x54b6('0x12')]&&_0x3e8179[_0x54b6('0x7')]==_0x138655[_0x54b6('0x7')]){return _0x44cb4e;}return _0x44cb4e[_0x54b6('0x16')]({'data1':_0x22caf5,'data2':null,'license':_0x138655[_0x54b6('0x7')]});}else{if(_0x138655[_0x54b6('0x7')]||_0x3e8179[_0x54b6('0x7')]){if(!_0x3e8179['data2']){if(_0x3e8179[_0x54b6('0x11')]==_0x22caf5){GRAY_PERIOD_REASON=_0x54b6('0x17');logger[_0x54b6('0x14')](_0x54b6('0x18'));}else{GRAY_PERIOD_REASON=_0x54b6('0x19');logger[_0x54b6('0x14')]('NEW\x20UUID\x20DETECTED:\x20FROM\x20%s\x20TO\x20%s',_0x3e8179[_0x54b6('0x11')],_0x22caf5);}logger[_0x54b6('0x14')](_0x54b6('0x1a'),GRAY_PERIOD_REASON[_0x54b6('0x1b')](),moment()[_0x54b6('0xb')](_0x54b6('0x1c')));return _0x44cb4e[_0x54b6('0x16')]({'data2':encryptor[_0x54b6('0x1d')](moment()[_0x54b6('0xb')](_0x54b6('0x1c')))});}else{if(moment()[_0x54b6('0x1e')](encryptor['decryptString'](_0x3e8179['data2']),_0x54b6('0x1f'))>DAYS){logger[_0x54b6('0x14')](_0x54b6('0x20'),moment()['format']('YYYY-MM-DD\x20HH:mm'));isOldTokenSent=![];return _0x44cb4e[_0x54b6('0x16')]({'data1':_0x22caf5,'data2':null,'license':null});}}}else{if(_0x3e8179['data1']!=_0x22caf5){logger[_0x54b6('0x14')](_0x54b6('0x21'),_0x3e8179[_0x54b6('0x11')],_0x22caf5);return _0x44cb4e[_0x54b6('0x16')]({'data1':_0x22caf5,'data2':null,'license':null});}}}return _0x44cb4e;})[_0x54b6('0xe')](function(_0xc911b){_0x44cb4e=_0xc911b;})[_0x54b6('0xf')](function(_0x3bcfbf){logger['error'](_0x3bcfbf[_0x54b6('0x22')]);})['finally'](function(){setTimeout(function(){manageLicense(hardware[_0x54b6('0x23')](),_0x44cb4e);},TIME);});}function defaultLicense(){var _0x5b038f=hardware[_0x54b6('0x23')]();if(_0x5b038f){return db['License']['findOrCreate']({'where':{'id':0x1},'defaults':{'data1':_0x5b038f}})[_0x54b6('0x24')](function(_0x1690bb,_0xacabe7){logger['info'](_0x54b6('0x25'),_0x5b038f);manageLicense(_0x5b038f,_0x1690bb);})['catch'](function(_0x1e5f0b){logger[_0x54b6('0x26')](_0x1e5f0b[_0x54b6('0x22')]);});}}exports[_0x54b6('0x27')]=defaultLicense;
\ No newline at end of file
+var _0x6806=['SERVICE\x20LICENSE\x20STARTED\x20%s','message','default','util','moment','request-promise','bluebird','pkginfo','version','../../components/encryptor','./hardware','license','https://www.xcallymotion.com','format','%s/api/servers/%s/check?version=%s','%s/api/servers/%s/check?version=%s&oldtoken=%s','GET','then','catch','get','data1','data2','info','THE\x20LICENSE\x20HAS\x20BEEN\x20ENABLED','THE\x20LICENSE\x20HAS\x20BEEN\x20UPDATED','THE\x20LICENSE\x20HAS\x20BEEN\x20DISABLED','Changed','%s\x20-\x20GRAY\x20PERIOD\x20STARTED\x20AT\x20%s','toUpperCase','YYYY-MM-DD\x20HH:mm','update','encryptString','diff','decryptString','DEMO\x20START\x20AT\x20%s','NEW\x20UUID\x20DETECTED:\x20FROM\x20%s\x20TO\x20%s','error','finally','getUuid','License','spread'];(function(_0x47f14c,_0x18fe67){var _0x119dc9=function(_0x335cbf){while(--_0x335cbf){_0x47f14c['push'](_0x47f14c['shift']());}};_0x119dc9(++_0x18fe67);}(_0x6806,0x174));var _0x6680=function(_0x4aecf1,_0x4b2396){_0x4aecf1=_0x4aecf1-0x0;var _0x21af74=_0x6806[_0x4aecf1];return _0x21af74;};'use strict';var util=require(_0x6680('0x0'));var moment=require(_0x6680('0x1'));var rp=require(_0x6680('0x2'));var BPromise=require(_0x6680('0x3'));var pkginfo=require(_0x6680('0x4'))(module,_0x6680('0x5'));var db=require('../../mysqldb')['db'];var encryptor=require(_0x6680('0x6'));var hardware=require(_0x6680('0x7'));var logger=require('../logger')(_0x6680('0x8'));var HOST=_0x6680('0x9');var TIME=0x3c*0x1388;var DAYS=0x7;var GRAY_PERIOD_REASON;var oldToken;var isOldTokenSent=![];function httpRequest(_0x2e4471){return new BPromise(function(_0x230d00,_0x759254){var _0x105ee1=util[_0x6680('0xa')](_0x6680('0xb'),HOST,_0x2e4471,module['exports'][_0x6680('0x5')]);if(oldToken){_0x105ee1=util['format'](_0x6680('0xc'),HOST,_0x2e4471,module['exports'][_0x6680('0x5')],oldToken);}var _0x139ef9={'uri':_0x105ee1,'method':_0x6680('0xd'),'timeout':0xea60,'json':!![]};return rp(_0x139ef9)[_0x6680('0xe')](function(_0x2de7e8){_0x230d00(_0x2de7e8);})[_0x6680('0xf')](function(_0xbfdaaf){_0x759254(_0xbfdaaf);});});}function manageLicense(_0xc51332,_0x25d4c0){var _0x5d8ad8=_0x25d4c0[_0x6680('0x10')]({'plain':!![]});if(!isOldTokenSent&&_0x5d8ad8[_0x6680('0x11')]!==_0xc51332&&!_0x5d8ad8[_0x6680('0x12')]){oldToken=_0x5d8ad8[_0x6680('0x11')];}httpRequest(_0xc51332)['then'](function(_0x7b651e){if(oldToken){oldToken=undefined;isOldTokenSent=!![];}if(_0x7b651e['active']){isOldTokenSent=![];if(!_0x5d8ad8[_0x6680('0x8')]&&_0x5d8ad8[_0x6680('0x8')]!=_0x7b651e[_0x6680('0x8')]||_0x5d8ad8[_0x6680('0x8')]&&_0x5d8ad8[_0x6680('0x12')]){logger[_0x6680('0x13')](_0x6680('0x14'));}if(_0x5d8ad8[_0x6680('0x8')]&&!_0x5d8ad8[_0x6680('0x12')]&&_0x5d8ad8[_0x6680('0x8')]!=_0x7b651e[_0x6680('0x8')]){logger[_0x6680('0x13')](_0x6680('0x15'));}if(_0x5d8ad8[_0x6680('0x8')]&&!_0x5d8ad8[_0x6680('0x12')]&&_0x5d8ad8['license']==_0x7b651e[_0x6680('0x8')]){return _0x25d4c0;}return _0x25d4c0['update']({'data1':_0xc51332,'data2':null,'license':_0x7b651e[_0x6680('0x8')]});}else{if(_0x7b651e[_0x6680('0x8')]||_0x5d8ad8['license']){if(!_0x5d8ad8[_0x6680('0x12')]){if(_0x5d8ad8[_0x6680('0x11')]==_0xc51332){GRAY_PERIOD_REASON='Disabled';logger[_0x6680('0x13')](_0x6680('0x16'));}else{GRAY_PERIOD_REASON=_0x6680('0x17');logger[_0x6680('0x13')]('NEW\x20UUID\x20DETECTED:\x20FROM\x20%s\x20TO\x20%s',_0x5d8ad8[_0x6680('0x11')],_0xc51332);}logger[_0x6680('0x13')](_0x6680('0x18'),GRAY_PERIOD_REASON[_0x6680('0x19')](),moment()[_0x6680('0xa')](_0x6680('0x1a')));return _0x25d4c0[_0x6680('0x1b')]({'data2':encryptor[_0x6680('0x1c')](moment()['format'](_0x6680('0x1a')))});}else{if(moment()[_0x6680('0x1d')](encryptor[_0x6680('0x1e')](_0x5d8ad8[_0x6680('0x12')]),'days')>DAYS){logger[_0x6680('0x13')](_0x6680('0x1f'),moment()[_0x6680('0xa')](_0x6680('0x1a')));isOldTokenSent=![];return _0x25d4c0['update']({'data1':_0xc51332,'data2':null,'license':null});}}}else{if(_0x5d8ad8[_0x6680('0x11')]!=_0xc51332){logger[_0x6680('0x13')](_0x6680('0x20'),_0x5d8ad8[_0x6680('0x11')],_0xc51332);return _0x25d4c0['update']({'data1':_0xc51332,'data2':null,'license':null});}}}return _0x25d4c0;})[_0x6680('0xe')](function(_0x4590fa){_0x25d4c0=_0x4590fa;})['catch'](function(_0x226722){logger[_0x6680('0x21')](_0x226722['message']);})[_0x6680('0x22')](function(){setTimeout(function(){manageLicense(hardware[_0x6680('0x23')](),_0x25d4c0);},TIME);});}function defaultLicense(){var _0x39baab=hardware[_0x6680('0x23')]();if(_0x39baab){return db[_0x6680('0x24')]['findOrCreate']({'where':{'id':0x1},'defaults':{'data1':_0x39baab}})[_0x6680('0x25')](function(_0x56c838,_0x120032){logger['info'](_0x6680('0x26'),_0x39baab);manageLicense(_0x39baab,_0x56c838);})['catch'](function(_0x21c3bf){logger[_0x6680('0x21')](_0x21c3bf[_0x6680('0x27')]);});}}exports[_0x6680('0x28')]=defaultLicense;
\ No newline at end of file