Built motion from commit 092f8824.|2.5.49
[motion2.git] / server / config / license / index.js
index 4822a43..21c3708 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 _0x1878=['%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','update','Disabled','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','DEMO\x20START\x20AT\x20%s','message','getUuid','License','spread','error','util','moment','request-promise','bluebird','pkginfo','../../mysqldb','../../components/encryptor','./hardware','../logger','license','https://www.xcallymotion.com','format','%s/api/servers/%s/check?version=%s','exports','version'];(function(_0x8c43de,_0x90ff31){var _0xa6591b=function(_0x469716){while(--_0x469716){_0x8c43de['push'](_0x8c43de['shift']());}};_0xa6591b(++_0x90ff31);}(_0x1878,0x1bf));var _0x8187=function(_0x5ca1f7,_0x52affb){_0x5ca1f7=_0x5ca1f7-0x0;var _0x92d1c=_0x1878[_0x5ca1f7];return _0x92d1c;};'use strict';var util=require(_0x8187('0x0'));var moment=require(_0x8187('0x1'));var rp=require(_0x8187('0x2'));var BPromise=require(_0x8187('0x3'));var pkginfo=require(_0x8187('0x4'))(module,'version');var db=require(_0x8187('0x5'))['db'];var encryptor=require(_0x8187('0x6'));var hardware=require(_0x8187('0x7'));var logger=require(_0x8187('0x8'))(_0x8187('0x9'));var HOST=_0x8187('0xa');var TIME=0x3c*0x1388;var DAYS=0x7;var GRAY_PERIOD_REASON;var oldToken;var isOldTokenSent=![];function httpRequest(_0x7beba2){return new BPromise(function(_0x53869e,_0x565500){var _0x7e2767=util[_0x8187('0xb')](_0x8187('0xc'),HOST,_0x7beba2,module[_0x8187('0xd')][_0x8187('0xe')]);if(oldToken){_0x7e2767=util[_0x8187('0xb')](_0x8187('0xf'),HOST,_0x7beba2,module[_0x8187('0xd')][_0x8187('0xe')],oldToken);}var _0x424222={'uri':_0x7e2767,'method':_0x8187('0x10'),'timeout':0xea60,'json':!![]};return rp(_0x424222)[_0x8187('0x11')](function(_0x42ff44){_0x53869e(_0x42ff44);})[_0x8187('0x12')](function(_0x26e813){_0x565500(_0x26e813);});});}function manageLicense(_0x22234e,_0x382200){var _0xb1b40c=_0x382200[_0x8187('0x13')]({'plain':!![]});if(!isOldTokenSent&&_0xb1b40c[_0x8187('0x14')]!==_0x22234e&&!_0xb1b40c[_0x8187('0x15')]){oldToken=_0xb1b40c[_0x8187('0x14')];}httpRequest(_0x22234e)['then'](function(_0x25612a){if(oldToken){oldToken=undefined;isOldTokenSent=!![];}if(_0x25612a['active']){isOldTokenSent=![];if(!_0xb1b40c[_0x8187('0x9')]&&_0xb1b40c[_0x8187('0x9')]!=_0x25612a[_0x8187('0x9')]||_0xb1b40c['license']&&_0xb1b40c[_0x8187('0x15')]){logger[_0x8187('0x16')](_0x8187('0x17'));}if(_0xb1b40c[_0x8187('0x9')]&&!_0xb1b40c[_0x8187('0x15')]&&_0xb1b40c[_0x8187('0x9')]!=_0x25612a['license']){logger[_0x8187('0x16')](_0x8187('0x18'));}if(_0xb1b40c[_0x8187('0x9')]&&!_0xb1b40c[_0x8187('0x15')]&&_0xb1b40c['license']==_0x25612a[_0x8187('0x9')]){return _0x382200;}return _0x382200[_0x8187('0x19')]({'data1':_0x22234e,'data2':null,'license':_0x25612a[_0x8187('0x9')]});}else{if(_0x25612a[_0x8187('0x9')]||_0xb1b40c[_0x8187('0x9')]){if(!_0xb1b40c['data2']){if(_0xb1b40c[_0x8187('0x14')]==_0x22234e){GRAY_PERIOD_REASON=_0x8187('0x1a');logger[_0x8187('0x16')]('THE\x20LICENSE\x20HAS\x20BEEN\x20DISABLED');}else{GRAY_PERIOD_REASON=_0x8187('0x1b');logger[_0x8187('0x16')](_0x8187('0x1c'),_0xb1b40c[_0x8187('0x14')],_0x22234e);}logger[_0x8187('0x16')](_0x8187('0x1d'),GRAY_PERIOD_REASON[_0x8187('0x1e')](),moment()[_0x8187('0xb')](_0x8187('0x1f')));return _0x382200['update']({'data2':encryptor[_0x8187('0x20')](moment()['format'](_0x8187('0x1f')))});}else{if(moment()[_0x8187('0x21')](encryptor[_0x8187('0x22')](_0xb1b40c[_0x8187('0x15')]),_0x8187('0x23'))>DAYS){logger[_0x8187('0x16')](_0x8187('0x24'),moment()[_0x8187('0xb')]('YYYY-MM-DD\x20HH:mm'));isOldTokenSent=![];return _0x382200['update']({'data1':_0x22234e,'data2':null,'license':null});}}}else{if(_0xb1b40c[_0x8187('0x14')]!=_0x22234e){logger['info'](_0x8187('0x1c'),_0xb1b40c[_0x8187('0x14')],_0x22234e);return _0x382200[_0x8187('0x19')]({'data1':_0x22234e,'data2':null,'license':null});}}}return _0x382200;})[_0x8187('0x11')](function(_0x28dd97){_0x382200=_0x28dd97;})['catch'](function(_0x3c9f1d){logger['error'](_0x3c9f1d[_0x8187('0x25')]);})['finally'](function(){setTimeout(function(){manageLicense(hardware['getUuid'](),_0x382200);},TIME);});}function defaultLicense(){var _0x5b9245=hardware[_0x8187('0x26')]();if(_0x5b9245){return db[_0x8187('0x27')]['findOrCreate']({'where':{'id':0x1},'defaults':{'data1':_0x5b9245}})[_0x8187('0x28')](function(_0x12d7cf,_0x4eb5b0){logger[_0x8187('0x16')]('SERVICE\x20LICENSE\x20STARTED\x20%s',_0x5b9245);manageLicense(_0x5b9245,_0x12d7cf);})[_0x8187('0x12')](function(_0x42de87){logger[_0x8187('0x29')](_0x42de87[_0x8187('0x25')]);});}}exports['default']=defaultLicense;
\ No newline at end of file