Built motion from commit ffdca78c.|2.6.24
[motion2.git] / server / config / license / index.js
index 4822a43..0d34819 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x3f97=['https://www.xcallymotion.com','format','%s/api/servers/%s/check?version=%s','exports','%s/api/servers/%s/check?version=%s&oldtoken=%s','GET','then','catch','data1','active','THE\x20LICENSE\x20HAS\x20BEEN\x20ENABLED','data2','info','THE\x20LICENSE\x20HAS\x20BEEN\x20UPDATED','Disabled','THE\x20LICENSE\x20HAS\x20BEEN\x20DISABLED','Changed','%s\x20-\x20GRAY\x20PERIOD\x20STARTED\x20AT\x20%s','toUpperCase','YYYY-MM-DD\x20HH:mm','update','diff','days','DEMO\x20START\x20AT\x20%s','NEW\x20UUID\x20DETECTED:\x20FROM\x20%s\x20TO\x20%s','finally','getUuid','License','spread','SERVICE\x20LICENSE\x20STARTED\x20%s','message','default','util','request-promise','version','../../mysqldb','../../components/encryptor','./hardware','license'];(function(_0x5416db,_0x55683a){var _0x243e35=function(_0x1eb623){while(--_0x1eb623){_0x5416db['push'](_0x5416db['shift']());}};_0x243e35(++_0x55683a);}(_0x3f97,0x1f4));var _0x73f9=function(_0x1140dd,_0x4c5fba){_0x1140dd=_0x1140dd-0x0;var _0x1d46a7=_0x3f97[_0x1140dd];return _0x1d46a7;};'use strict';var util=require(_0x73f9('0x0'));var moment=require('moment');var rp=require(_0x73f9('0x1'));var BPromise=require('bluebird');var pkginfo=require('pkginfo')(module,_0x73f9('0x2'));var db=require(_0x73f9('0x3'))['db'];var encryptor=require(_0x73f9('0x4'));var hardware=require(_0x73f9('0x5'));var logger=require('../logger')(_0x73f9('0x6'));var HOST=_0x73f9('0x7');var TIME=0x3c*0x1388;var DAYS=0x7;var GRAY_PERIOD_REASON;var oldToken;var isOldTokenSent=![];function httpRequest(_0x565384){return new BPromise(function(_0x2071fe,_0x43e2d0){var _0x293746=util[_0x73f9('0x8')](_0x73f9('0x9'),HOST,_0x565384,module[_0x73f9('0xa')]['version']);if(oldToken){_0x293746=util[_0x73f9('0x8')](_0x73f9('0xb'),HOST,_0x565384,module[_0x73f9('0xa')]['version'],oldToken);}var _0x5be7d3={'uri':_0x293746,'method':_0x73f9('0xc'),'timeout':0xea60,'json':!![]};return rp(_0x5be7d3)[_0x73f9('0xd')](function(_0x2d368c){_0x2071fe(_0x2d368c);})[_0x73f9('0xe')](function(_0x3fd7f5){_0x43e2d0(_0x3fd7f5);});});}function manageLicense(_0x51b1b2,_0x2d7b6e){var _0x53f52e=_0x2d7b6e['get']({'plain':!![]});if(!isOldTokenSent&&_0x53f52e[_0x73f9('0xf')]!==_0x51b1b2&&!_0x53f52e['data2']){oldToken=_0x53f52e[_0x73f9('0xf')];}httpRequest(_0x51b1b2)['then'](function(_0xdc80d1){if(oldToken){oldToken=undefined;isOldTokenSent=!![];}if(_0xdc80d1[_0x73f9('0x10')]){isOldTokenSent=![];if(!_0x53f52e['license']&&_0x53f52e[_0x73f9('0x6')]!=_0xdc80d1[_0x73f9('0x6')]||_0x53f52e['license']&&_0x53f52e['data2']){logger['info'](_0x73f9('0x11'));}if(_0x53f52e[_0x73f9('0x6')]&&!_0x53f52e[_0x73f9('0x12')]&&_0x53f52e[_0x73f9('0x6')]!=_0xdc80d1['license']){logger[_0x73f9('0x13')](_0x73f9('0x14'));}if(_0x53f52e[_0x73f9('0x6')]&&!_0x53f52e['data2']&&_0x53f52e['license']==_0xdc80d1['license']){return _0x2d7b6e;}return _0x2d7b6e['update']({'data1':_0x51b1b2,'data2':null,'license':_0xdc80d1['license']});}else{if(_0xdc80d1[_0x73f9('0x6')]||_0x53f52e[_0x73f9('0x6')]){if(!_0x53f52e['data2']){if(_0x53f52e[_0x73f9('0xf')]==_0x51b1b2){GRAY_PERIOD_REASON=_0x73f9('0x15');logger['info'](_0x73f9('0x16'));}else{GRAY_PERIOD_REASON=_0x73f9('0x17');logger[_0x73f9('0x13')]('NEW\x20UUID\x20DETECTED:\x20FROM\x20%s\x20TO\x20%s',_0x53f52e[_0x73f9('0xf')],_0x51b1b2);}logger[_0x73f9('0x13')](_0x73f9('0x18'),GRAY_PERIOD_REASON[_0x73f9('0x19')](),moment()[_0x73f9('0x8')](_0x73f9('0x1a')));return _0x2d7b6e[_0x73f9('0x1b')]({'data2':encryptor['encryptString'](moment()[_0x73f9('0x8')](_0x73f9('0x1a')))});}else{if(moment()[_0x73f9('0x1c')](encryptor['decryptString'](_0x53f52e[_0x73f9('0x12')]),_0x73f9('0x1d'))>DAYS){logger[_0x73f9('0x13')](_0x73f9('0x1e'),moment()[_0x73f9('0x8')]('YYYY-MM-DD\x20HH:mm'));isOldTokenSent=![];return _0x2d7b6e[_0x73f9('0x1b')]({'data1':_0x51b1b2,'data2':null,'license':null});}}}else{if(_0x53f52e[_0x73f9('0xf')]!=_0x51b1b2){logger[_0x73f9('0x13')](_0x73f9('0x1f'),_0x53f52e['data1'],_0x51b1b2);return _0x2d7b6e[_0x73f9('0x1b')]({'data1':_0x51b1b2,'data2':null,'license':null});}}}return _0x2d7b6e;})[_0x73f9('0xd')](function(_0x4bc04b){_0x2d7b6e=_0x4bc04b;})['catch'](function(_0x374942){logger['error'](_0x374942['message']);})[_0x73f9('0x20')](function(){setTimeout(function(){manageLicense(hardware[_0x73f9('0x21')](),_0x2d7b6e);},TIME);});}function defaultLicense(){var _0x29c6c1=hardware[_0x73f9('0x21')]();if(_0x29c6c1){return db[_0x73f9('0x22')]['findOrCreate']({'where':{'id':0x1},'defaults':{'data1':_0x29c6c1}})[_0x73f9('0x23')](function(_0x4ac057,_0xac30fe){logger['info'](_0x73f9('0x24'),_0x29c6c1);manageLicense(_0x29c6c1,_0x4ac057);})[_0x73f9('0xe')](function(_0x9f3b90){logger['error'](_0x9f3b90[_0x73f9('0x25')]);});}}exports[_0x73f9('0x26')]=defaultLicense;
\ No newline at end of file
+var _0x6b7b=['DEMO\x20START\x20AT\x20%s','error','message','finally','getUuid','findOrCreate','SERVICE\x20LICENSE\x20STARTED\x20%s','default','util','request-promise','pkginfo','version','../../mysqldb','../../components/encryptor','./hardware','https://www.xcallymotion.com','format','exports','%s/api/servers/%s/check?version=%s&oldtoken=%s','GET','then','catch','get','data1','active','license','data2','THE\x20LICENSE\x20HAS\x20BEEN\x20ENABLED','THE\x20LICENSE\x20HAS\x20BEEN\x20UPDATED','update','info','THE\x20LICENSE\x20HAS\x20BEEN\x20DISABLED','Changed','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'];(function(_0x3704a0,_0x3720ec){var _0x2dbc0e=function(_0x9eb8e7){while(--_0x9eb8e7){_0x3704a0['push'](_0x3704a0['shift']());}};_0x2dbc0e(++_0x3720ec);}(_0x6b7b,0x1a2));var _0xb6b7=function(_0x160f12,_0x2389d5){_0x160f12=_0x160f12-0x0;var _0x4cdf65=_0x6b7b[_0x160f12];return _0x4cdf65;};'use strict';var util=require(_0xb6b7('0x0'));var moment=require('moment');var rp=require(_0xb6b7('0x1'));var BPromise=require('bluebird');var pkginfo=require(_0xb6b7('0x2'))(module,_0xb6b7('0x3'));var db=require(_0xb6b7('0x4'))['db'];var encryptor=require(_0xb6b7('0x5'));var hardware=require(_0xb6b7('0x6'));var logger=require('../logger')('license');var HOST=_0xb6b7('0x7');var TIME=0x3c*0x1388;var DAYS=0x7;var GRAY_PERIOD_REASON;var oldToken;var isOldTokenSent=![];function httpRequest(_0xe1e0e){return new BPromise(function(_0x2cb117,_0x1a0eb1){var _0x53e86b=util[_0xb6b7('0x8')]('%s/api/servers/%s/check?version=%s',HOST,_0xe1e0e,module[_0xb6b7('0x9')][_0xb6b7('0x3')]);if(oldToken){_0x53e86b=util[_0xb6b7('0x8')](_0xb6b7('0xa'),HOST,_0xe1e0e,module[_0xb6b7('0x9')][_0xb6b7('0x3')],oldToken);}var _0x430085={'uri':_0x53e86b,'method':_0xb6b7('0xb'),'timeout':0xea60,'json':!![]};return rp(_0x430085)[_0xb6b7('0xc')](function(_0x499764){_0x2cb117(_0x499764);})[_0xb6b7('0xd')](function(_0x154193){_0x1a0eb1(_0x154193);});});}function manageLicense(_0x480323,_0x471fbf){var _0x162d12=_0x471fbf[_0xb6b7('0xe')]({'plain':!![]});if(!isOldTokenSent&&_0x162d12[_0xb6b7('0xf')]!==_0x480323&&!_0x162d12['data2']){oldToken=_0x162d12[_0xb6b7('0xf')];}httpRequest(_0x480323)[_0xb6b7('0xc')](function(_0x30cec0){if(oldToken){oldToken=undefined;isOldTokenSent=!![];}if(_0x30cec0[_0xb6b7('0x10')]){isOldTokenSent=![];if(!_0x162d12[_0xb6b7('0x11')]&&_0x162d12[_0xb6b7('0x11')]!=_0x30cec0[_0xb6b7('0x11')]||_0x162d12[_0xb6b7('0x11')]&&_0x162d12[_0xb6b7('0x12')]){logger['info'](_0xb6b7('0x13'));}if(_0x162d12[_0xb6b7('0x11')]&&!_0x162d12['data2']&&_0x162d12['license']!=_0x30cec0['license']){logger['info'](_0xb6b7('0x14'));}if(_0x162d12[_0xb6b7('0x11')]&&!_0x162d12[_0xb6b7('0x12')]&&_0x162d12['license']==_0x30cec0['license']){return _0x471fbf;}return _0x471fbf[_0xb6b7('0x15')]({'data1':_0x480323,'data2':null,'license':_0x30cec0[_0xb6b7('0x11')]});}else{if(_0x30cec0['license']||_0x162d12[_0xb6b7('0x11')]){if(!_0x162d12[_0xb6b7('0x12')]){if(_0x162d12[_0xb6b7('0xf')]==_0x480323){GRAY_PERIOD_REASON='Disabled';logger[_0xb6b7('0x16')](_0xb6b7('0x17'));}else{GRAY_PERIOD_REASON=_0xb6b7('0x18');logger[_0xb6b7('0x16')](_0xb6b7('0x19'),_0x162d12[_0xb6b7('0xf')],_0x480323);}logger['info'](_0xb6b7('0x1a'),GRAY_PERIOD_REASON[_0xb6b7('0x1b')](),moment()[_0xb6b7('0x8')](_0xb6b7('0x1c')));return _0x471fbf[_0xb6b7('0x15')]({'data2':encryptor[_0xb6b7('0x1d')](moment()[_0xb6b7('0x8')]('YYYY-MM-DD\x20HH:mm'))});}else{if(moment()[_0xb6b7('0x1e')](encryptor[_0xb6b7('0x1f')](_0x162d12[_0xb6b7('0x12')]),_0xb6b7('0x20'))>DAYS){logger['info'](_0xb6b7('0x21'),moment()['format'](_0xb6b7('0x1c')));isOldTokenSent=![];return _0x471fbf[_0xb6b7('0x15')]({'data1':_0x480323,'data2':null,'license':null});}}}else{if(_0x162d12[_0xb6b7('0xf')]!=_0x480323){logger[_0xb6b7('0x16')](_0xb6b7('0x19'),_0x162d12[_0xb6b7('0xf')],_0x480323);return _0x471fbf[_0xb6b7('0x15')]({'data1':_0x480323,'data2':null,'license':null});}}}return _0x471fbf;})[_0xb6b7('0xc')](function(_0x1aa604){_0x471fbf=_0x1aa604;})['catch'](function(_0x5761cb){logger[_0xb6b7('0x22')](_0x5761cb[_0xb6b7('0x23')]);})[_0xb6b7('0x24')](function(){setTimeout(function(){manageLicense(hardware[_0xb6b7('0x25')](),_0x471fbf);},TIME);});}function defaultLicense(){var _0x213a79=hardware[_0xb6b7('0x25')]();if(_0x213a79){return db['License'][_0xb6b7('0x26')]({'where':{'id':0x1},'defaults':{'data1':_0x213a79}})['spread'](function(_0xc318a8,_0x268689){logger[_0xb6b7('0x16')](_0xb6b7('0x27'),_0x213a79);manageLicense(_0x213a79,_0xc318a8);})[_0xb6b7('0xd')](function(_0x52869a){logger[_0xb6b7('0x22')](_0x52869a['message']);});}}exports[_0xb6b7('0x28')]=defaultLicense;
\ No newline at end of file