Built motion from commit (unavailable).|2.6.0
[motion2.git] / server / config / license / index.js
index 4a1e268..c810040 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf150=['%s\x20-\x20GRAY\x20PERIOD\x20STARTED\x20AT\x20%s','toUpperCase','YYYY-MM-DD\x20HH:mm','update','diff','days','DEMO\x20START\x20AT\x20%s','then','catch','error','message','finally','getUuid','License','spread','SERVICE\x20LICENSE\x20STARTED\x20%s','default','moment','request-promise','bluebird','pkginfo','version','../../mysqldb','../../components/encryptor','./hardware','license','https://www.xcallymotion.com','format','%s/api/servers/%s/check?version=%s','%s/api/servers/%s/check?version=%s&oldtoken=%s','exports','GET','get','data1','data2','active','info','THE\x20LICENSE\x20HAS\x20BEEN\x20ENABLED','THE\x20LICENSE\x20HAS\x20BEEN\x20UPDATED','Disabled','THE\x20LICENSE\x20HAS\x20BEEN\x20DISABLED','Changed','NEW\x20UUID\x20DETECTED:\x20FROM\x20%s\x20TO\x20%s'];(function(_0x4114dd,_0x2ad862){var _0x26f44c=function(_0xad2246){while(--_0xad2246){_0x4114dd['push'](_0x4114dd['shift']());}};_0x26f44c(++_0x2ad862);}(_0xf150,0x13e));var _0x0f15=function(_0x4bfec6,_0x449de5){_0x4bfec6=_0x4bfec6-0x0;var _0x33d474=_0xf150[_0x4bfec6];return _0x33d474;};'use strict';var util=require('util');var moment=require(_0x0f15('0x0'));var rp=require(_0x0f15('0x1'));var BPromise=require(_0x0f15('0x2'));var pkginfo=require(_0x0f15('0x3'))(module,_0x0f15('0x4'));var db=require(_0x0f15('0x5'))['db'];var encryptor=require(_0x0f15('0x6'));var hardware=require(_0x0f15('0x7'));var logger=require('../logger')(_0x0f15('0x8'));var HOST=_0x0f15('0x9');var TIME=0x3c*0x1388;var DAYS=0x7;var GRAY_PERIOD_REASON;var oldToken;var isOldTokenSent=![];function httpRequest(_0x3336ef){return new BPromise(function(_0x90026a,_0x106980){var _0xaaee8f=util[_0x0f15('0xa')](_0x0f15('0xb'),HOST,_0x3336ef,module['exports'][_0x0f15('0x4')]);if(oldToken){_0xaaee8f=util[_0x0f15('0xa')](_0x0f15('0xc'),HOST,_0x3336ef,module[_0x0f15('0xd')]['version'],oldToken);}var _0x39065f={'uri':_0xaaee8f,'method':_0x0f15('0xe'),'timeout':0xea60,'json':!![]};return rp(_0x39065f)['then'](function(_0x3276ef){_0x90026a(_0x3276ef);})['catch'](function(_0xc33baa){_0x106980(_0xc33baa);});});}function manageLicense(_0x4063d9,_0x19574d){var _0x28266c=_0x19574d[_0x0f15('0xf')]({'plain':!![]});if(!isOldTokenSent&&_0x28266c[_0x0f15('0x10')]!==_0x4063d9&&!_0x28266c[_0x0f15('0x11')]){oldToken=_0x28266c[_0x0f15('0x10')];}httpRequest(_0x4063d9)['then'](function(_0x56fcff){if(oldToken){oldToken=undefined;isOldTokenSent=!![];}if(_0x56fcff[_0x0f15('0x12')]){isOldTokenSent=![];if(!_0x28266c[_0x0f15('0x8')]&&_0x28266c[_0x0f15('0x8')]!=_0x56fcff[_0x0f15('0x8')]||_0x28266c[_0x0f15('0x8')]&&_0x28266c['data2']){logger[_0x0f15('0x13')](_0x0f15('0x14'));}if(_0x28266c[_0x0f15('0x8')]&&!_0x28266c[_0x0f15('0x11')]&&_0x28266c[_0x0f15('0x8')]!=_0x56fcff[_0x0f15('0x8')]){logger[_0x0f15('0x13')](_0x0f15('0x15'));}if(_0x28266c[_0x0f15('0x8')]&&!_0x28266c[_0x0f15('0x11')]&&_0x28266c['license']==_0x56fcff[_0x0f15('0x8')]){return _0x19574d;}return _0x19574d['update']({'data1':_0x4063d9,'data2':null,'license':_0x56fcff[_0x0f15('0x8')]});}else{if(_0x56fcff[_0x0f15('0x8')]||_0x28266c[_0x0f15('0x8')]){if(!_0x28266c[_0x0f15('0x11')]){if(_0x28266c[_0x0f15('0x10')]==_0x4063d9){GRAY_PERIOD_REASON=_0x0f15('0x16');logger[_0x0f15('0x13')](_0x0f15('0x17'));}else{GRAY_PERIOD_REASON=_0x0f15('0x18');logger[_0x0f15('0x13')](_0x0f15('0x19'),_0x28266c[_0x0f15('0x10')],_0x4063d9);}logger[_0x0f15('0x13')](_0x0f15('0x1a'),GRAY_PERIOD_REASON[_0x0f15('0x1b')](),moment()[_0x0f15('0xa')](_0x0f15('0x1c')));return _0x19574d[_0x0f15('0x1d')]({'data2':encryptor['encryptString'](moment()['format']('YYYY-MM-DD\x20HH:mm'))});}else{if(moment()[_0x0f15('0x1e')](encryptor['decryptString'](_0x28266c[_0x0f15('0x11')]),_0x0f15('0x1f'))>DAYS){logger['info'](_0x0f15('0x20'),moment()['format'](_0x0f15('0x1c')));isOldTokenSent=![];return _0x19574d['update']({'data1':_0x4063d9,'data2':null,'license':null});}}}else{if(_0x28266c[_0x0f15('0x10')]!=_0x4063d9){logger[_0x0f15('0x13')](_0x0f15('0x19'),_0x28266c[_0x0f15('0x10')],_0x4063d9);return _0x19574d['update']({'data1':_0x4063d9,'data2':null,'license':null});}}}return _0x19574d;})[_0x0f15('0x21')](function(_0x511a00){_0x19574d=_0x511a00;})[_0x0f15('0x22')](function(_0x5a5dd0){logger[_0x0f15('0x23')](_0x5a5dd0[_0x0f15('0x24')]);})[_0x0f15('0x25')](function(){setTimeout(function(){manageLicense(hardware[_0x0f15('0x26')](),_0x19574d);},TIME);});}function defaultLicense(){var _0xbc0697=hardware[_0x0f15('0x26')]();if(_0xbc0697){return db[_0x0f15('0x27')]['findOrCreate']({'where':{'id':0x1},'defaults':{'data1':_0xbc0697}})[_0x0f15('0x28')](function(_0x590ce9,_0x58c2b9){logger[_0x0f15('0x13')](_0x0f15('0x29'),_0xbc0697);manageLicense(_0xbc0697,_0x590ce9);})[_0x0f15('0x22')](function(_0x183035){logger[_0x0f15('0x23')](_0x183035[_0x0f15('0x24')]);});}}exports[_0x0f15('0x2a')]=defaultLicense;
\ No newline at end of file
+var _0x0f38=['../../components/encryptor','./hardware','license','format','%s/api/servers/%s/check?version=%s','%s/api/servers/%s/check?version=%s&oldtoken=%s','GET','catch','get','data2','data1','then','info','THE\x20LICENSE\x20HAS\x20BEEN\x20ENABLED','update','Disabled','THE\x20LICENSE\x20HAS\x20BEEN\x20DISABLED','Changed','NEW\x20UUID\x20DETECTED:\x20FROM\x20%s\x20TO\x20%s','toUpperCase','YYYY-MM-DD\x20HH:mm','encryptString','DEMO\x20START\x20AT\x20%s','error','message','finally','getUuid','License','findOrCreate','default','util','moment','request-promise','bluebird','pkginfo','version','../../mysqldb'];(function(_0xeff2c3,_0x3a5a82){var _0x2cade6=function(_0x5a26a1){while(--_0x5a26a1){_0xeff2c3['push'](_0xeff2c3['shift']());}};_0x2cade6(++_0x3a5a82);}(_0x0f38,0x68));var _0x80f3=function(_0x381c88,_0x2cb161){_0x381c88=_0x381c88-0x0;var _0x59c5bb=_0x0f38[_0x381c88];return _0x59c5bb;};'use strict';var util=require(_0x80f3('0x0'));var moment=require(_0x80f3('0x1'));var rp=require(_0x80f3('0x2'));var BPromise=require(_0x80f3('0x3'));var pkginfo=require(_0x80f3('0x4'))(module,_0x80f3('0x5'));var db=require(_0x80f3('0x6'))['db'];var encryptor=require(_0x80f3('0x7'));var hardware=require(_0x80f3('0x8'));var logger=require('../logger')(_0x80f3('0x9'));var HOST='https://www.xcallymotion.com';var TIME=0x3c*0x1388;var DAYS=0x7;var GRAY_PERIOD_REASON;var oldToken;var isOldTokenSent=![];function httpRequest(_0x39bd5a){return new BPromise(function(_0x3e26e4,_0x5548a2){var _0x11ecc0=util[_0x80f3('0xa')](_0x80f3('0xb'),HOST,_0x39bd5a,module['exports']['version']);if(oldToken){_0x11ecc0=util[_0x80f3('0xa')](_0x80f3('0xc'),HOST,_0x39bd5a,module['exports'][_0x80f3('0x5')],oldToken);}var _0x4e999e={'uri':_0x11ecc0,'method':_0x80f3('0xd'),'timeout':0xea60,'json':!![]};return rp(_0x4e999e)['then'](function(_0x556e25){_0x3e26e4(_0x556e25);})[_0x80f3('0xe')](function(_0x772a14){_0x5548a2(_0x772a14);});});}function manageLicense(_0x13f541,_0x253616){var _0x15ac6a=_0x253616[_0x80f3('0xf')]({'plain':!![]});if(!isOldTokenSent&&_0x15ac6a['data1']!==_0x13f541&&!_0x15ac6a[_0x80f3('0x10')]){oldToken=_0x15ac6a[_0x80f3('0x11')];}httpRequest(_0x13f541)[_0x80f3('0x12')](function(_0x3b1900){if(oldToken){oldToken=undefined;isOldTokenSent=!![];}if(_0x3b1900['active']){isOldTokenSent=![];if(!_0x15ac6a['license']&&_0x15ac6a[_0x80f3('0x9')]!=_0x3b1900[_0x80f3('0x9')]||_0x15ac6a['license']&&_0x15ac6a[_0x80f3('0x10')]){logger[_0x80f3('0x13')](_0x80f3('0x14'));}if(_0x15ac6a[_0x80f3('0x9')]&&!_0x15ac6a[_0x80f3('0x10')]&&_0x15ac6a['license']!=_0x3b1900['license']){logger[_0x80f3('0x13')]('THE\x20LICENSE\x20HAS\x20BEEN\x20UPDATED');}if(_0x15ac6a[_0x80f3('0x9')]&&!_0x15ac6a['data2']&&_0x15ac6a[_0x80f3('0x9')]==_0x3b1900[_0x80f3('0x9')]){return _0x253616;}return _0x253616[_0x80f3('0x15')]({'data1':_0x13f541,'data2':null,'license':_0x3b1900[_0x80f3('0x9')]});}else{if(_0x3b1900[_0x80f3('0x9')]||_0x15ac6a[_0x80f3('0x9')]){if(!_0x15ac6a['data2']){if(_0x15ac6a[_0x80f3('0x11')]==_0x13f541){GRAY_PERIOD_REASON=_0x80f3('0x16');logger[_0x80f3('0x13')](_0x80f3('0x17'));}else{GRAY_PERIOD_REASON=_0x80f3('0x18');logger[_0x80f3('0x13')](_0x80f3('0x19'),_0x15ac6a[_0x80f3('0x11')],_0x13f541);}logger['info']('%s\x20-\x20GRAY\x20PERIOD\x20STARTED\x20AT\x20%s',GRAY_PERIOD_REASON[_0x80f3('0x1a')](),moment()[_0x80f3('0xa')](_0x80f3('0x1b')));return _0x253616[_0x80f3('0x15')]({'data2':encryptor[_0x80f3('0x1c')](moment()[_0x80f3('0xa')](_0x80f3('0x1b')))});}else{if(moment()['diff'](encryptor['decryptString'](_0x15ac6a[_0x80f3('0x10')]),'days')>DAYS){logger[_0x80f3('0x13')](_0x80f3('0x1d'),moment()[_0x80f3('0xa')](_0x80f3('0x1b')));isOldTokenSent=![];return _0x253616[_0x80f3('0x15')]({'data1':_0x13f541,'data2':null,'license':null});}}}else{if(_0x15ac6a[_0x80f3('0x11')]!=_0x13f541){logger[_0x80f3('0x13')](_0x80f3('0x19'),_0x15ac6a['data1'],_0x13f541);return _0x253616['update']({'data1':_0x13f541,'data2':null,'license':null});}}}return _0x253616;})['then'](function(_0x4f3ad2){_0x253616=_0x4f3ad2;})['catch'](function(_0xdc0158){logger[_0x80f3('0x1e')](_0xdc0158[_0x80f3('0x1f')]);})[_0x80f3('0x20')](function(){setTimeout(function(){manageLicense(hardware[_0x80f3('0x21')](),_0x253616);},TIME);});}function defaultLicense(){var _0x5e8fe4=hardware[_0x80f3('0x21')]();if(_0x5e8fe4){return db[_0x80f3('0x22')][_0x80f3('0x23')]({'where':{'id':0x1},'defaults':{'data1':_0x5e8fe4}})['spread'](function(_0xdbee9d,_0x42b1be){logger[_0x80f3('0x13')]('SERVICE\x20LICENSE\x20STARTED\x20%s',_0x5e8fe4);manageLicense(_0x5e8fe4,_0xdbee9d);})[_0x80f3('0xe')](function(_0x28f2bb){logger[_0x80f3('0x1e')](_0x28f2bb[_0x80f3('0x1f')]);});}}exports[_0x80f3('0x24')]=defaultLicense;
\ No newline at end of file