Built motion from commit (unavailable).|2.5.24
[motion2.git] / server / config / license / index.js
index 6cc0cd8..cc79830 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xaf32=['default','moment','pkginfo','version','../../mysqldb','../../components/encryptor','./hardware','../logger','license','https://www.xcallymotion.com','exports','format','%s/api/servers/%s/check?version=%s&oldtoken=%s','GET','then','get','data1','data2','info','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','decryptString','days','DEMO\x20START\x20AT\x20%s','error','finally','getUuid','License','findOrCreate','message'];(function(_0x49c3cf,_0x3234dc){var _0x3bae4d=function(_0x4b1d9c){while(--_0x4b1d9c){_0x49c3cf['push'](_0x49c3cf['shift']());}};_0x3bae4d(++_0x3234dc);}(_0xaf32,0x70));var _0x2af3=function(_0x5cfdf4,_0x278351){_0x5cfdf4=_0x5cfdf4-0x0;var _0xe40152=_0xaf32[_0x5cfdf4];return _0xe40152;};'use strict';var util=require('util');var moment=require(_0x2af3('0x0'));var rp=require('request-promise');var BPromise=require('bluebird');var pkginfo=require(_0x2af3('0x1'))(module,_0x2af3('0x2'));var db=require(_0x2af3('0x3'))['db'];var encryptor=require(_0x2af3('0x4'));var hardware=require(_0x2af3('0x5'));var logger=require(_0x2af3('0x6'))(_0x2af3('0x7'));var HOST=_0x2af3('0x8');var TIME=0x3c*0x1388;var DAYS=0x7;var GRAY_PERIOD_REASON;var oldToken;var isOldTokenSent=![];function httpRequest(_0x43c8db){return new BPromise(function(_0xabf8fc,_0x11c2c2){var _0x1b884c=util['format']('%s/api/servers/%s/check?version=%s',HOST,_0x43c8db,module[_0x2af3('0x9')][_0x2af3('0x2')]);if(oldToken){_0x1b884c=util[_0x2af3('0xa')](_0x2af3('0xb'),HOST,_0x43c8db,module[_0x2af3('0x9')][_0x2af3('0x2')],oldToken);}var _0x59a7f1={'uri':_0x1b884c,'method':_0x2af3('0xc'),'timeout':0xea60,'json':!![]};return rp(_0x59a7f1)[_0x2af3('0xd')](function(_0x1246c6){_0xabf8fc(_0x1246c6);})['catch'](function(_0x41ac72){_0x11c2c2(_0x41ac72);});});}function manageLicense(_0x230b32,_0x572878){var _0x1bf0d0=_0x572878[_0x2af3('0xe')]({'plain':!![]});if(!isOldTokenSent&&_0x1bf0d0[_0x2af3('0xf')]!==_0x230b32&&!_0x1bf0d0[_0x2af3('0x10')]){oldToken=_0x1bf0d0[_0x2af3('0xf')];}httpRequest(_0x230b32)[_0x2af3('0xd')](function(_0x3f16ad){if(oldToken){oldToken=undefined;isOldTokenSent=!![];}if(_0x3f16ad['active']){isOldTokenSent=![];if(!_0x1bf0d0[_0x2af3('0x7')]&&_0x1bf0d0[_0x2af3('0x7')]!=_0x3f16ad['license']||_0x1bf0d0[_0x2af3('0x7')]&&_0x1bf0d0[_0x2af3('0x10')]){logger[_0x2af3('0x11')]('THE\x20LICENSE\x20HAS\x20BEEN\x20ENABLED');}if(_0x1bf0d0['license']&&!_0x1bf0d0['data2']&&_0x1bf0d0[_0x2af3('0x7')]!=_0x3f16ad[_0x2af3('0x7')]){logger[_0x2af3('0x11')](_0x2af3('0x12'));}if(_0x1bf0d0['license']&&!_0x1bf0d0['data2']&&_0x1bf0d0['license']==_0x3f16ad[_0x2af3('0x7')]){return _0x572878;}return _0x572878[_0x2af3('0x13')]({'data1':_0x230b32,'data2':null,'license':_0x3f16ad['license']});}else{if(_0x3f16ad['license']||_0x1bf0d0[_0x2af3('0x7')]){if(!_0x1bf0d0[_0x2af3('0x10')]){if(_0x1bf0d0['data1']==_0x230b32){GRAY_PERIOD_REASON=_0x2af3('0x14');logger['info']('THE\x20LICENSE\x20HAS\x20BEEN\x20DISABLED');}else{GRAY_PERIOD_REASON=_0x2af3('0x15');logger['info'](_0x2af3('0x16'),_0x1bf0d0['data1'],_0x230b32);}logger[_0x2af3('0x11')](_0x2af3('0x17'),GRAY_PERIOD_REASON[_0x2af3('0x18')](),moment()['format'](_0x2af3('0x19')));return _0x572878['update']({'data2':encryptor[_0x2af3('0x1a')](moment()[_0x2af3('0xa')](_0x2af3('0x19')))});}else{if(moment()['diff'](encryptor[_0x2af3('0x1b')](_0x1bf0d0[_0x2af3('0x10')]),_0x2af3('0x1c'))>DAYS){logger[_0x2af3('0x11')](_0x2af3('0x1d'),moment()[_0x2af3('0xa')](_0x2af3('0x19')));isOldTokenSent=![];return _0x572878[_0x2af3('0x13')]({'data1':_0x230b32,'data2':null,'license':null});}}}else{if(_0x1bf0d0[_0x2af3('0xf')]!=_0x230b32){logger[_0x2af3('0x11')]('NEW\x20UUID\x20DETECTED:\x20FROM\x20%s\x20TO\x20%s',_0x1bf0d0['data1'],_0x230b32);return _0x572878[_0x2af3('0x13')]({'data1':_0x230b32,'data2':null,'license':null});}}}return _0x572878;})[_0x2af3('0xd')](function(_0x510d86){_0x572878=_0x510d86;})['catch'](function(_0x4c267c){logger[_0x2af3('0x1e')](_0x4c267c['message']);})[_0x2af3('0x1f')](function(){setTimeout(function(){manageLicense(hardware[_0x2af3('0x20')](),_0x572878);},TIME);});}function defaultLicense(){var _0x124c15=hardware[_0x2af3('0x20')]();if(_0x124c15){return db[_0x2af3('0x21')][_0x2af3('0x22')]({'where':{'id':0x1},'defaults':{'data1':_0x124c15}})['spread'](function(_0x2396ca,_0x2b8094){logger[_0x2af3('0x11')]('SERVICE\x20LICENSE\x20STARTED\x20%s',_0x124c15);manageLicense(_0x124c15,_0x2396ca);})['catch'](function(_0x225d5b){logger[_0x2af3('0x1e')](_0x225d5b[_0x2af3('0x23')]);});}}exports[_0x2af3('0x24')]=defaultLicense;
\ No newline at end of file
+var _0x9fea=['../../components/encryptor','./hardware','../logger','license','https://www.xcallymotion.com','format','%s/api/servers/%s/check?version=%s','exports','GET','catch','get','data2','data1','then','info','THE\x20LICENSE\x20HAS\x20BEEN\x20ENABLED','THE\x20LICENSE\x20HAS\x20BEEN\x20UPDATED','update','Disabled','THE\x20LICENSE\x20HAS\x20BEEN\x20DISABLED','NEW\x20UUID\x20DETECTED:\x20FROM\x20%s\x20TO\x20%s','%s\x20-\x20GRAY\x20PERIOD\x20STARTED\x20AT\x20%s','toUpperCase','YYYY-MM-DD\x20HH:mm','encryptString','decryptString','days','DEMO\x20START\x20AT\x20%s','error','finally','getUuid','findOrCreate','spread','message','default','util','moment','request-promise','pkginfo','version','../../mysqldb'];(function(_0x8ee422,_0x5c815f){var _0x322f12=function(_0x5d7a04){while(--_0x5d7a04){_0x8ee422['push'](_0x8ee422['shift']());}};_0x322f12(++_0x5c815f);}(_0x9fea,0x75));var _0xa9fe=function(_0x5d2033,_0x8e34f8){_0x5d2033=_0x5d2033-0x0;var _0x340eda=_0x9fea[_0x5d2033];return _0x340eda;};'use strict';var util=require(_0xa9fe('0x0'));var moment=require(_0xa9fe('0x1'));var rp=require(_0xa9fe('0x2'));var BPromise=require('bluebird');var pkginfo=require(_0xa9fe('0x3'))(module,_0xa9fe('0x4'));var db=require(_0xa9fe('0x5'))['db'];var encryptor=require(_0xa9fe('0x6'));var hardware=require(_0xa9fe('0x7'));var logger=require(_0xa9fe('0x8'))(_0xa9fe('0x9'));var HOST=_0xa9fe('0xa');var TIME=0x3c*0x1388;var DAYS=0x7;var GRAY_PERIOD_REASON;var oldToken;var isOldTokenSent=![];function httpRequest(_0x469849){return new BPromise(function(_0x14938a,_0x32c21d){var _0x499a0b=util[_0xa9fe('0xb')](_0xa9fe('0xc'),HOST,_0x469849,module[_0xa9fe('0xd')]['version']);if(oldToken){_0x499a0b=util[_0xa9fe('0xb')]('%s/api/servers/%s/check?version=%s&oldtoken=%s',HOST,_0x469849,module[_0xa9fe('0xd')][_0xa9fe('0x4')],oldToken);}var _0x58c7ac={'uri':_0x499a0b,'method':_0xa9fe('0xe'),'timeout':0xea60,'json':!![]};return rp(_0x58c7ac)['then'](function(_0x3f44d0){_0x14938a(_0x3f44d0);})[_0xa9fe('0xf')](function(_0xfb58c0){_0x32c21d(_0xfb58c0);});});}function manageLicense(_0x5e90a4,_0x11ba57){var _0x41f3a1=_0x11ba57[_0xa9fe('0x10')]({'plain':!![]});if(!isOldTokenSent&&_0x41f3a1['data1']!==_0x5e90a4&&!_0x41f3a1[_0xa9fe('0x11')]){oldToken=_0x41f3a1[_0xa9fe('0x12')];}httpRequest(_0x5e90a4)[_0xa9fe('0x13')](function(_0x4333c4){if(oldToken){oldToken=undefined;isOldTokenSent=!![];}if(_0x4333c4['active']){isOldTokenSent=![];if(!_0x41f3a1[_0xa9fe('0x9')]&&_0x41f3a1[_0xa9fe('0x9')]!=_0x4333c4['license']||_0x41f3a1[_0xa9fe('0x9')]&&_0x41f3a1[_0xa9fe('0x11')]){logger[_0xa9fe('0x14')](_0xa9fe('0x15'));}if(_0x41f3a1['license']&&!_0x41f3a1[_0xa9fe('0x11')]&&_0x41f3a1[_0xa9fe('0x9')]!=_0x4333c4['license']){logger['info'](_0xa9fe('0x16'));}if(_0x41f3a1['license']&&!_0x41f3a1[_0xa9fe('0x11')]&&_0x41f3a1[_0xa9fe('0x9')]==_0x4333c4['license']){return _0x11ba57;}return _0x11ba57[_0xa9fe('0x17')]({'data1':_0x5e90a4,'data2':null,'license':_0x4333c4[_0xa9fe('0x9')]});}else{if(_0x4333c4['license']||_0x41f3a1[_0xa9fe('0x9')]){if(!_0x41f3a1[_0xa9fe('0x11')]){if(_0x41f3a1[_0xa9fe('0x12')]==_0x5e90a4){GRAY_PERIOD_REASON=_0xa9fe('0x18');logger[_0xa9fe('0x14')](_0xa9fe('0x19'));}else{GRAY_PERIOD_REASON='Changed';logger['info'](_0xa9fe('0x1a'),_0x41f3a1[_0xa9fe('0x12')],_0x5e90a4);}logger[_0xa9fe('0x14')](_0xa9fe('0x1b'),GRAY_PERIOD_REASON[_0xa9fe('0x1c')](),moment()[_0xa9fe('0xb')](_0xa9fe('0x1d')));return _0x11ba57['update']({'data2':encryptor[_0xa9fe('0x1e')](moment()['format'](_0xa9fe('0x1d')))});}else{if(moment()['diff'](encryptor[_0xa9fe('0x1f')](_0x41f3a1[_0xa9fe('0x11')]),_0xa9fe('0x20'))>DAYS){logger[_0xa9fe('0x14')](_0xa9fe('0x21'),moment()[_0xa9fe('0xb')](_0xa9fe('0x1d')));isOldTokenSent=![];return _0x11ba57[_0xa9fe('0x17')]({'data1':_0x5e90a4,'data2':null,'license':null});}}}else{if(_0x41f3a1[_0xa9fe('0x12')]!=_0x5e90a4){logger['info'](_0xa9fe('0x1a'),_0x41f3a1[_0xa9fe('0x12')],_0x5e90a4);return _0x11ba57[_0xa9fe('0x17')]({'data1':_0x5e90a4,'data2':null,'license':null});}}}return _0x11ba57;})[_0xa9fe('0x13')](function(_0x48d6c7){_0x11ba57=_0x48d6c7;})[_0xa9fe('0xf')](function(_0x25ca46){logger[_0xa9fe('0x22')](_0x25ca46['message']);})[_0xa9fe('0x23')](function(){setTimeout(function(){manageLicense(hardware[_0xa9fe('0x24')](),_0x11ba57);},TIME);});}function defaultLicense(){var _0x482b1e=hardware[_0xa9fe('0x24')]();if(_0x482b1e){return db['License'][_0xa9fe('0x25')]({'where':{'id':0x1},'defaults':{'data1':_0x482b1e}})[_0xa9fe('0x26')](function(_0x435d5e,_0x13c1af){logger[_0xa9fe('0x14')]('SERVICE\x20LICENSE\x20STARTED\x20%s',_0x482b1e);manageLicense(_0x482b1e,_0x435d5e);})[_0xa9fe('0xf')](function(_0x40bfb5){logger[_0xa9fe('0x22')](_0x40bfb5[_0xa9fe('0x27')]);});}}exports[_0xa9fe('0x28')]=defaultLicense;
\ No newline at end of file