Built motion from commit 25580385.|2.6.2
[motion2.git] / server / config / license / index.js
index 81f4e03..d89fe4b 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x5aef=['Changed','NEW\x20UUID\x20DETECTED:\x20FROM\x20%s\x20TO\x20%s','toUpperCase','update','YYYY-MM-DD\x20HH:mm','diff','decryptString','days','DEMO\x20START\x20AT\x20%s','error','message','finally','getUuid','License','spread','SERVICE\x20LICENSE\x20STARTED\x20%s','catch','default','request-promise','bluebird','pkginfo','version','../../mysqldb','../../components/encryptor','../logger','license','format','%s/api/servers/%s/check?version=%s','exports','%s/api/servers/%s/check?version=%s&oldtoken=%s','GET','then','get','data1','active','data2','info','THE\x20LICENSE\x20HAS\x20BEEN\x20ENABLED','THE\x20LICENSE\x20HAS\x20BEEN\x20UPDATED','Disabled','THE\x20LICENSE\x20HAS\x20BEEN\x20DISABLED'];(function(_0x5b24a1,_0x5c816b){var _0xe5bd71=function(_0x4e3632){while(--_0x4e3632){_0x5b24a1['push'](_0x5b24a1['shift']());}};_0xe5bd71(++_0x5c816b);}(_0x5aef,0x131));var _0xf5ae=function(_0xac0de1,_0x12d3d9){_0xac0de1=_0xac0de1-0x0;var _0x1c1995=_0x5aef[_0xac0de1];return _0x1c1995;};'use strict';var util=require('util');var moment=require('moment');var rp=require(_0xf5ae('0x0'));var BPromise=require(_0xf5ae('0x1'));var pkginfo=require(_0xf5ae('0x2'))(module,_0xf5ae('0x3'));var db=require(_0xf5ae('0x4'))['db'];var encryptor=require(_0xf5ae('0x5'));var hardware=require('./hardware');var logger=require(_0xf5ae('0x6'))(_0xf5ae('0x7'));var HOST='https://www.xcallymotion.com';var TIME=0x3c*0x1388;var DAYS=0x7;var GRAY_PERIOD_REASON;var oldToken;var isOldTokenSent=![];function httpRequest(_0x2694ff){return new BPromise(function(_0x24c7e8,_0x303018){var _0x3d4f27=util[_0xf5ae('0x8')](_0xf5ae('0x9'),HOST,_0x2694ff,module[_0xf5ae('0xa')][_0xf5ae('0x3')]);if(oldToken){_0x3d4f27=util[_0xf5ae('0x8')](_0xf5ae('0xb'),HOST,_0x2694ff,module['exports']['version'],oldToken);}var _0x16b980={'uri':_0x3d4f27,'method':_0xf5ae('0xc'),'timeout':0xea60,'json':!![]};return rp(_0x16b980)[_0xf5ae('0xd')](function(_0x2267a9){_0x24c7e8(_0x2267a9);})['catch'](function(_0x119a8e){_0x303018(_0x119a8e);});});}function manageLicense(_0x1e1972,_0x15507f){var _0x272731=_0x15507f[_0xf5ae('0xe')]({'plain':!![]});if(!isOldTokenSent&&_0x272731[_0xf5ae('0xf')]!==_0x1e1972&&!_0x272731['data2']){oldToken=_0x272731[_0xf5ae('0xf')];}httpRequest(_0x1e1972)[_0xf5ae('0xd')](function(_0x26a4ef){if(oldToken){oldToken=undefined;isOldTokenSent=!![];}if(_0x26a4ef[_0xf5ae('0x10')]){isOldTokenSent=![];if(!_0x272731[_0xf5ae('0x7')]&&_0x272731['license']!=_0x26a4ef[_0xf5ae('0x7')]||_0x272731[_0xf5ae('0x7')]&&_0x272731[_0xf5ae('0x11')]){logger[_0xf5ae('0x12')](_0xf5ae('0x13'));}if(_0x272731['license']&&!_0x272731[_0xf5ae('0x11')]&&_0x272731[_0xf5ae('0x7')]!=_0x26a4ef[_0xf5ae('0x7')]){logger[_0xf5ae('0x12')](_0xf5ae('0x14'));}if(_0x272731[_0xf5ae('0x7')]&&!_0x272731[_0xf5ae('0x11')]&&_0x272731['license']==_0x26a4ef[_0xf5ae('0x7')]){return _0x15507f;}return _0x15507f['update']({'data1':_0x1e1972,'data2':null,'license':_0x26a4ef['license']});}else{if(_0x26a4ef[_0xf5ae('0x7')]||_0x272731[_0xf5ae('0x7')]){if(!_0x272731[_0xf5ae('0x11')]){if(_0x272731[_0xf5ae('0xf')]==_0x1e1972){GRAY_PERIOD_REASON=_0xf5ae('0x15');logger['info'](_0xf5ae('0x16'));}else{GRAY_PERIOD_REASON=_0xf5ae('0x17');logger[_0xf5ae('0x12')](_0xf5ae('0x18'),_0x272731[_0xf5ae('0xf')],_0x1e1972);}logger['info']('%s\x20-\x20GRAY\x20PERIOD\x20STARTED\x20AT\x20%s',GRAY_PERIOD_REASON[_0xf5ae('0x19')](),moment()[_0xf5ae('0x8')]('YYYY-MM-DD\x20HH:mm'));return _0x15507f[_0xf5ae('0x1a')]({'data2':encryptor['encryptString'](moment()[_0xf5ae('0x8')](_0xf5ae('0x1b')))});}else{if(moment()[_0xf5ae('0x1c')](encryptor[_0xf5ae('0x1d')](_0x272731[_0xf5ae('0x11')]),_0xf5ae('0x1e'))>DAYS){logger[_0xf5ae('0x12')](_0xf5ae('0x1f'),moment()[_0xf5ae('0x8')](_0xf5ae('0x1b')));isOldTokenSent=![];return _0x15507f[_0xf5ae('0x1a')]({'data1':_0x1e1972,'data2':null,'license':null});}}}else{if(_0x272731[_0xf5ae('0xf')]!=_0x1e1972){logger[_0xf5ae('0x12')]('NEW\x20UUID\x20DETECTED:\x20FROM\x20%s\x20TO\x20%s',_0x272731[_0xf5ae('0xf')],_0x1e1972);return _0x15507f[_0xf5ae('0x1a')]({'data1':_0x1e1972,'data2':null,'license':null});}}}return _0x15507f;})['then'](function(_0x1d49ae){_0x15507f=_0x1d49ae;})['catch'](function(_0x49ffb3){logger[_0xf5ae('0x20')](_0x49ffb3[_0xf5ae('0x21')]);})[_0xf5ae('0x22')](function(){setTimeout(function(){manageLicense(hardware[_0xf5ae('0x23')](),_0x15507f);},TIME);});}function defaultLicense(){var _0x307339=hardware[_0xf5ae('0x23')]();if(_0x307339){return db[_0xf5ae('0x24')]['findOrCreate']({'where':{'id':0x1},'defaults':{'data1':_0x307339}})[_0xf5ae('0x25')](function(_0x55e1e6,_0x2908b5){logger[_0xf5ae('0x12')](_0xf5ae('0x26'),_0x307339);manageLicense(_0x307339,_0x55e1e6);})[_0xf5ae('0x27')](function(_0x5dcad0){logger[_0xf5ae('0x20')](_0x5dcad0[_0xf5ae('0x21')]);});}}exports[_0xf5ae('0x28')]=defaultLicense;
\ No newline at end of file
+var _0x57f3=['Disabled','NEW\x20UUID\x20DETECTED:\x20FROM\x20%s\x20TO\x20%s','%s\x20-\x20GRAY\x20PERIOD\x20STARTED\x20AT\x20%s','YYYY-MM-DD\x20HH:mm','update','diff','decryptString','error','getUuid','License','findOrCreate','SERVICE\x20LICENSE\x20STARTED\x20%s','default','util','request-promise','bluebird','version','../../mysqldb','../../components/encryptor','../logger','license','https://www.xcallymotion.com','format','%s/api/servers/%s/check?version=%s','exports','then','catch','data2','data1','active','info','THE\x20LICENSE\x20HAS\x20BEEN\x20ENABLED','THE\x20LICENSE\x20HAS\x20BEEN\x20UPDATED'];(function(_0x568496,_0x565afd){var _0x26c5c1=function(_0x4d251e){while(--_0x4d251e){_0x568496['push'](_0x568496['shift']());}};_0x26c5c1(++_0x565afd);}(_0x57f3,0x178));var _0x357f=function(_0x17d9e3,_0x1f969c){_0x17d9e3=_0x17d9e3-0x0;var _0x14192d=_0x57f3[_0x17d9e3];return _0x14192d;};'use strict';var util=require(_0x357f('0x0'));var moment=require('moment');var rp=require(_0x357f('0x1'));var BPromise=require(_0x357f('0x2'));var pkginfo=require('pkginfo')(module,_0x357f('0x3'));var db=require(_0x357f('0x4'))['db'];var encryptor=require(_0x357f('0x5'));var hardware=require('./hardware');var logger=require(_0x357f('0x6'))(_0x357f('0x7'));var HOST=_0x357f('0x8');var TIME=0x3c*0x1388;var DAYS=0x7;var GRAY_PERIOD_REASON;var oldToken;var isOldTokenSent=![];function httpRequest(_0x68b72a){return new BPromise(function(_0x4e77f1,_0x5a052f){var _0x3af30c=util[_0x357f('0x9')](_0x357f('0xa'),HOST,_0x68b72a,module['exports'][_0x357f('0x3')]);if(oldToken){_0x3af30c=util[_0x357f('0x9')]('%s/api/servers/%s/check?version=%s&oldtoken=%s',HOST,_0x68b72a,module[_0x357f('0xb')][_0x357f('0x3')],oldToken);}var _0x3e197d={'uri':_0x3af30c,'method':'GET','timeout':0xea60,'json':!![]};return rp(_0x3e197d)[_0x357f('0xc')](function(_0x4c914f){_0x4e77f1(_0x4c914f);})[_0x357f('0xd')](function(_0x48116e){_0x5a052f(_0x48116e);});});}function manageLicense(_0x4192a4,_0x275faf){var _0x40156f=_0x275faf['get']({'plain':!![]});if(!isOldTokenSent&&_0x40156f['data1']!==_0x4192a4&&!_0x40156f[_0x357f('0xe')]){oldToken=_0x40156f[_0x357f('0xf')];}httpRequest(_0x4192a4)['then'](function(_0x551f6b){if(oldToken){oldToken=undefined;isOldTokenSent=!![];}if(_0x551f6b[_0x357f('0x10')]){isOldTokenSent=![];if(!_0x40156f[_0x357f('0x7')]&&_0x40156f[_0x357f('0x7')]!=_0x551f6b['license']||_0x40156f[_0x357f('0x7')]&&_0x40156f[_0x357f('0xe')]){logger[_0x357f('0x11')](_0x357f('0x12'));}if(_0x40156f[_0x357f('0x7')]&&!_0x40156f['data2']&&_0x40156f[_0x357f('0x7')]!=_0x551f6b[_0x357f('0x7')]){logger[_0x357f('0x11')](_0x357f('0x13'));}if(_0x40156f[_0x357f('0x7')]&&!_0x40156f['data2']&&_0x40156f[_0x357f('0x7')]==_0x551f6b[_0x357f('0x7')]){return _0x275faf;}return _0x275faf['update']({'data1':_0x4192a4,'data2':null,'license':_0x551f6b[_0x357f('0x7')]});}else{if(_0x551f6b[_0x357f('0x7')]||_0x40156f[_0x357f('0x7')]){if(!_0x40156f[_0x357f('0xe')]){if(_0x40156f['data1']==_0x4192a4){GRAY_PERIOD_REASON=_0x357f('0x14');logger['info']('THE\x20LICENSE\x20HAS\x20BEEN\x20DISABLED');}else{GRAY_PERIOD_REASON='Changed';logger['info'](_0x357f('0x15'),_0x40156f[_0x357f('0xf')],_0x4192a4);}logger[_0x357f('0x11')](_0x357f('0x16'),GRAY_PERIOD_REASON['toUpperCase'](),moment()[_0x357f('0x9')](_0x357f('0x17')));return _0x275faf[_0x357f('0x18')]({'data2':encryptor['encryptString'](moment()[_0x357f('0x9')](_0x357f('0x17')))});}else{if(moment()[_0x357f('0x19')](encryptor[_0x357f('0x1a')](_0x40156f[_0x357f('0xe')]),'days')>DAYS){logger[_0x357f('0x11')]('DEMO\x20START\x20AT\x20%s',moment()[_0x357f('0x9')]('YYYY-MM-DD\x20HH:mm'));isOldTokenSent=![];return _0x275faf[_0x357f('0x18')]({'data1':_0x4192a4,'data2':null,'license':null});}}}else{if(_0x40156f['data1']!=_0x4192a4){logger[_0x357f('0x11')](_0x357f('0x15'),_0x40156f[_0x357f('0xf')],_0x4192a4);return _0x275faf[_0x357f('0x18')]({'data1':_0x4192a4,'data2':null,'license':null});}}}return _0x275faf;})[_0x357f('0xc')](function(_0x52a73d){_0x275faf=_0x52a73d;})[_0x357f('0xd')](function(_0x3505c2){logger[_0x357f('0x1b')](_0x3505c2['message']);})['finally'](function(){setTimeout(function(){manageLicense(hardware['getUuid'](),_0x275faf);},TIME);});}function defaultLicense(){var _0x5e089b=hardware[_0x357f('0x1c')]();if(_0x5e089b){return db[_0x357f('0x1d')][_0x357f('0x1e')]({'where':{'id':0x1},'defaults':{'data1':_0x5e089b}})['spread'](function(_0x5c0dc7,_0x32bb7e){logger[_0x357f('0x11')](_0x357f('0x1f'),_0x5e089b);manageLicense(_0x5e089b,_0x5c0dc7);})[_0x357f('0xd')](function(_0x28f494){logger['error'](_0x28f494['message']);});}}exports[_0x357f('0x20')]=defaultLicense;
\ No newline at end of file