Built motion from commit a61a4a20.|2.5.46
[motion2.git] / server / config / license / index.js
index ec44b89..facc9bd 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x92f6=['data1','data2','info','THE\x20LICENSE\x20HAS\x20BEEN\x20ENABLED','THE\x20LICENSE\x20HAS\x20BEEN\x20UPDATED','update','Disabled','NEW\x20UUID\x20DETECTED:\x20FROM\x20%s\x20TO\x20%s','%s\x20-\x20GRAY\x20PERIOD\x20STARTED\x20AT\x20%s','toUpperCase','YYYY-MM-DD\x20HH:mm','encryptString','diff','decryptString','days','error','finally','getUuid','License','findOrCreate','spread','SERVICE\x20LICENSE\x20STARTED\x20%s','default','util','moment','request-promise','bluebird','pkginfo','version','../../mysqldb','./hardware','../logger','license','https://www.xcallymotion.com','format','%s/api/servers/%s/check?version=%s','%s/api/servers/%s/check?version=%s&oldtoken=%s','exports','GET','then','catch','get'];(function(_0x14add3,_0x13ce8d){var _0x4a174f=function(_0x2b3ed7){while(--_0x2b3ed7){_0x14add3['push'](_0x14add3['shift']());}};_0x4a174f(++_0x13ce8d);}(_0x92f6,0x95));var _0x692f=function(_0x4ff231,_0x5519af){_0x4ff231=_0x4ff231-0x0;var _0x289c46=_0x92f6[_0x4ff231];return _0x289c46;};'use strict';var util=require(_0x692f('0x0'));var moment=require(_0x692f('0x1'));var rp=require(_0x692f('0x2'));var BPromise=require(_0x692f('0x3'));var pkginfo=require(_0x692f('0x4'))(module,_0x692f('0x5'));var db=require(_0x692f('0x6'))['db'];var encryptor=require('../../components/encryptor');var hardware=require(_0x692f('0x7'));var logger=require(_0x692f('0x8'))(_0x692f('0x9'));var HOST=_0x692f('0xa');var TIME=0x3c*0x1388;var DAYS=0x7;var GRAY_PERIOD_REASON;var oldToken;var isOldTokenSent=![];function httpRequest(_0x5bdc37){return new BPromise(function(_0x445ed1,_0x111126){var _0x5f35be=util[_0x692f('0xb')](_0x692f('0xc'),HOST,_0x5bdc37,module['exports']['version']);if(oldToken){_0x5f35be=util['format'](_0x692f('0xd'),HOST,_0x5bdc37,module[_0x692f('0xe')][_0x692f('0x5')],oldToken);}var _0x340a0c={'uri':_0x5f35be,'method':_0x692f('0xf'),'timeout':0xea60,'json':!![]};return rp(_0x340a0c)[_0x692f('0x10')](function(_0x4cd665){_0x445ed1(_0x4cd665);})[_0x692f('0x11')](function(_0x4f7085){_0x111126(_0x4f7085);});});}function manageLicense(_0x4d706f,_0x384908){var _0x431cc6=_0x384908[_0x692f('0x12')]({'plain':!![]});if(!isOldTokenSent&&_0x431cc6[_0x692f('0x13')]!==_0x4d706f&&!_0x431cc6[_0x692f('0x14')]){oldToken=_0x431cc6['data1'];}httpRequest(_0x4d706f)['then'](function(_0x291788){if(oldToken){oldToken=undefined;isOldTokenSent=!![];}if(_0x291788['active']){isOldTokenSent=![];if(!_0x431cc6[_0x692f('0x9')]&&_0x431cc6[_0x692f('0x9')]!=_0x291788['license']||_0x431cc6[_0x692f('0x9')]&&_0x431cc6[_0x692f('0x14')]){logger[_0x692f('0x15')](_0x692f('0x16'));}if(_0x431cc6[_0x692f('0x9')]&&!_0x431cc6[_0x692f('0x14')]&&_0x431cc6[_0x692f('0x9')]!=_0x291788[_0x692f('0x9')]){logger['info'](_0x692f('0x17'));}if(_0x431cc6[_0x692f('0x9')]&&!_0x431cc6[_0x692f('0x14')]&&_0x431cc6[_0x692f('0x9')]==_0x291788[_0x692f('0x9')]){return _0x384908;}return _0x384908[_0x692f('0x18')]({'data1':_0x4d706f,'data2':null,'license':_0x291788['license']});}else{if(_0x291788[_0x692f('0x9')]||_0x431cc6[_0x692f('0x9')]){if(!_0x431cc6[_0x692f('0x14')]){if(_0x431cc6[_0x692f('0x13')]==_0x4d706f){GRAY_PERIOD_REASON=_0x692f('0x19');logger[_0x692f('0x15')]('THE\x20LICENSE\x20HAS\x20BEEN\x20DISABLED');}else{GRAY_PERIOD_REASON='Changed';logger[_0x692f('0x15')](_0x692f('0x1a'),_0x431cc6[_0x692f('0x13')],_0x4d706f);}logger[_0x692f('0x15')](_0x692f('0x1b'),GRAY_PERIOD_REASON[_0x692f('0x1c')](),moment()[_0x692f('0xb')](_0x692f('0x1d')));return _0x384908[_0x692f('0x18')]({'data2':encryptor[_0x692f('0x1e')](moment()['format'](_0x692f('0x1d')))});}else{if(moment()[_0x692f('0x1f')](encryptor[_0x692f('0x20')](_0x431cc6['data2']),_0x692f('0x21'))>DAYS){logger[_0x692f('0x15')]('DEMO\x20START\x20AT\x20%s',moment()[_0x692f('0xb')]('YYYY-MM-DD\x20HH:mm'));isOldTokenSent=![];return _0x384908[_0x692f('0x18')]({'data1':_0x4d706f,'data2':null,'license':null});}}}else{if(_0x431cc6[_0x692f('0x13')]!=_0x4d706f){logger['info']('NEW\x20UUID\x20DETECTED:\x20FROM\x20%s\x20TO\x20%s',_0x431cc6[_0x692f('0x13')],_0x4d706f);return _0x384908[_0x692f('0x18')]({'data1':_0x4d706f,'data2':null,'license':null});}}}return _0x384908;})[_0x692f('0x10')](function(_0xd330f1){_0x384908=_0xd330f1;})['catch'](function(_0x3b9185){logger[_0x692f('0x22')](_0x3b9185['message']);})[_0x692f('0x23')](function(){setTimeout(function(){manageLicense(hardware['getUuid'](),_0x384908);},TIME);});}function defaultLicense(){var _0x42f885=hardware[_0x692f('0x24')]();if(_0x42f885){return db[_0x692f('0x25')][_0x692f('0x26')]({'where':{'id':0x1},'defaults':{'data1':_0x42f885}})[_0x692f('0x27')](function(_0x23cbb0,_0x4a32fb){logger[_0x692f('0x15')](_0x692f('0x28'),_0x42f885);manageLicense(_0x42f885,_0x23cbb0);})[_0x692f('0x11')](function(_0x3a31f4){logger['error'](_0x3a31f4['message']);});}}exports[_0x692f('0x29')]=defaultLicense;
\ No newline at end of file
+var _0x058f=['toUpperCase','YYYY-MM-DD\x20HH:mm','encryptString','diff','decryptString','days','DEMO\x20START\x20AT\x20%s','NEW\x20UUID\x20DETECTED:\x20FROM\x20%s\x20TO\x20%s','message','finally','getUuid','License','findOrCreate','spread','default','util','moment','request-promise','bluebird','version','../../mysqldb','../../components/encryptor','../logger','license','https://www.xcallymotion.com','format','%s/api/servers/%s/check?version=%s','exports','%s/api/servers/%s/check?version=%s&oldtoken=%s','GET','then','data2','data1','active','info','THE\x20LICENSE\x20HAS\x20BEEN\x20UPDATED','update','Disabled','Changed'];(function(_0x167cc1,_0x56ef5a){var _0x10bc4b=function(_0xd6a255){while(--_0xd6a255){_0x167cc1['push'](_0x167cc1['shift']());}};_0x10bc4b(++_0x56ef5a);}(_0x058f,0x147));var _0xf058=function(_0x26215,_0x48ad48){_0x26215=_0x26215-0x0;var _0x4c84b7=_0x058f[_0x26215];return _0x4c84b7;};'use strict';var util=require(_0xf058('0x0'));var moment=require(_0xf058('0x1'));var rp=require(_0xf058('0x2'));var BPromise=require(_0xf058('0x3'));var pkginfo=require('pkginfo')(module,_0xf058('0x4'));var db=require(_0xf058('0x5'))['db'];var encryptor=require(_0xf058('0x6'));var hardware=require('./hardware');var logger=require(_0xf058('0x7'))(_0xf058('0x8'));var HOST=_0xf058('0x9');var TIME=0x3c*0x1388;var DAYS=0x7;var GRAY_PERIOD_REASON;var oldToken;var isOldTokenSent=![];function httpRequest(_0x2d4a59){return new BPromise(function(_0xac1176,_0x12a625){var _0x370b46=util[_0xf058('0xa')](_0xf058('0xb'),HOST,_0x2d4a59,module[_0xf058('0xc')][_0xf058('0x4')]);if(oldToken){_0x370b46=util[_0xf058('0xa')](_0xf058('0xd'),HOST,_0x2d4a59,module['exports']['version'],oldToken);}var _0x2e91bb={'uri':_0x370b46,'method':_0xf058('0xe'),'timeout':0xea60,'json':!![]};return rp(_0x2e91bb)[_0xf058('0xf')](function(_0x195620){_0xac1176(_0x195620);})['catch'](function(_0x515309){_0x12a625(_0x515309);});});}function manageLicense(_0x33eebd,_0x14cbee){var _0x283b12=_0x14cbee['get']({'plain':!![]});if(!isOldTokenSent&&_0x283b12['data1']!==_0x33eebd&&!_0x283b12[_0xf058('0x10')]){oldToken=_0x283b12[_0xf058('0x11')];}httpRequest(_0x33eebd)[_0xf058('0xf')](function(_0x206a7c){if(oldToken){oldToken=undefined;isOldTokenSent=!![];}if(_0x206a7c[_0xf058('0x12')]){isOldTokenSent=![];if(!_0x283b12['license']&&_0x283b12[_0xf058('0x8')]!=_0x206a7c[_0xf058('0x8')]||_0x283b12[_0xf058('0x8')]&&_0x283b12['data2']){logger['info']('THE\x20LICENSE\x20HAS\x20BEEN\x20ENABLED');}if(_0x283b12['license']&&!_0x283b12[_0xf058('0x10')]&&_0x283b12[_0xf058('0x8')]!=_0x206a7c[_0xf058('0x8')]){logger[_0xf058('0x13')](_0xf058('0x14'));}if(_0x283b12[_0xf058('0x8')]&&!_0x283b12['data2']&&_0x283b12[_0xf058('0x8')]==_0x206a7c[_0xf058('0x8')]){return _0x14cbee;}return _0x14cbee[_0xf058('0x15')]({'data1':_0x33eebd,'data2':null,'license':_0x206a7c['license']});}else{if(_0x206a7c['license']||_0x283b12[_0xf058('0x8')]){if(!_0x283b12['data2']){if(_0x283b12['data1']==_0x33eebd){GRAY_PERIOD_REASON=_0xf058('0x16');logger[_0xf058('0x13')]('THE\x20LICENSE\x20HAS\x20BEEN\x20DISABLED');}else{GRAY_PERIOD_REASON=_0xf058('0x17');logger['info']('NEW\x20UUID\x20DETECTED:\x20FROM\x20%s\x20TO\x20%s',_0x283b12[_0xf058('0x11')],_0x33eebd);}logger[_0xf058('0x13')]('%s\x20-\x20GRAY\x20PERIOD\x20STARTED\x20AT\x20%s',GRAY_PERIOD_REASON[_0xf058('0x18')](),moment()['format'](_0xf058('0x19')));return _0x14cbee['update']({'data2':encryptor[_0xf058('0x1a')](moment()[_0xf058('0xa')](_0xf058('0x19')))});}else{if(moment()[_0xf058('0x1b')](encryptor[_0xf058('0x1c')](_0x283b12[_0xf058('0x10')]),_0xf058('0x1d'))>DAYS){logger[_0xf058('0x13')](_0xf058('0x1e'),moment()[_0xf058('0xa')]('YYYY-MM-DD\x20HH:mm'));isOldTokenSent=![];return _0x14cbee[_0xf058('0x15')]({'data1':_0x33eebd,'data2':null,'license':null});}}}else{if(_0x283b12[_0xf058('0x11')]!=_0x33eebd){logger[_0xf058('0x13')](_0xf058('0x1f'),_0x283b12['data1'],_0x33eebd);return _0x14cbee[_0xf058('0x15')]({'data1':_0x33eebd,'data2':null,'license':null});}}}return _0x14cbee;})[_0xf058('0xf')](function(_0x271c8b){_0x14cbee=_0x271c8b;})['catch'](function(_0x26f9e6){logger['error'](_0x26f9e6[_0xf058('0x20')]);})[_0xf058('0x21')](function(){setTimeout(function(){manageLicense(hardware['getUuid'](),_0x14cbee);},TIME);});}function defaultLicense(){var _0x3f522c=hardware[_0xf058('0x22')]();if(_0x3f522c){return db[_0xf058('0x23')][_0xf058('0x24')]({'where':{'id':0x1},'defaults':{'data1':_0x3f522c}})[_0xf058('0x25')](function(_0x5a0a44,_0x3b16e0){logger[_0xf058('0x13')]('SERVICE\x20LICENSE\x20STARTED\x20%s',_0x3f522c);manageLicense(_0x3f522c,_0x5a0a44);})['catch'](function(_0x5415cd){logger['error'](_0x5415cd[_0xf058('0x20')]);});}}exports[_0xf058('0x26')]=defaultLicense;
\ No newline at end of file