Built motion from commit 43538d75.|2.5.35
[motion2.git] / server / config / license / index.js
index ec44b89..de03cfb 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x92f6=['data1','data2','info','THE\x20LICENSE\x20HAS\x20BEEN\x20ENABLED','THE\x20LICENSE\x20HAS\x20BEEN\x20UPDATED','update','Disabled','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','error','finally','getUuid','License','findOrCreate','spread','SERVICE\x20LICENSE\x20STARTED\x20%s','default','util','moment','request-promise','bluebird','pkginfo','version','../../mysqldb','./hardware','../logger','license','https://www.xcallymotion.com','format','%s/api/servers/%s/check?version=%s','%s/api/servers/%s/check?version=%s&oldtoken=%s','exports','GET','then','catch','get'];(function(_0x14add3,_0x13ce8d){var _0x4a174f=function(_0x2b3ed7){while(--_0x2b3ed7){_0x14add3['push'](_0x14add3['shift']());}};_0x4a174f(++_0x13ce8d);}(_0x92f6,0x95));var _0x692f=function(_0x4ff231,_0x5519af){_0x4ff231=_0x4ff231-0x0;var _0x289c46=_0x92f6[_0x4ff231];return _0x289c46;};'use strict';var util=require(_0x692f('0x0'));var moment=require(_0x692f('0x1'));var rp=require(_0x692f('0x2'));var BPromise=require(_0x692f('0x3'));var pkginfo=require(_0x692f('0x4'))(module,_0x692f('0x5'));var db=require(_0x692f('0x6'))['db'];var encryptor=require('../../components/encryptor');var hardware=require(_0x692f('0x7'));var logger=require(_0x692f('0x8'))(_0x692f('0x9'));var HOST=_0x692f('0xa');var TIME=0x3c*0x1388;var DAYS=0x7;var GRAY_PERIOD_REASON;var oldToken;var isOldTokenSent=![];function httpRequest(_0x5bdc37){return new BPromise(function(_0x445ed1,_0x111126){var _0x5f35be=util[_0x692f('0xb')](_0x692f('0xc'),HOST,_0x5bdc37,module['exports']['version']);if(oldToken){_0x5f35be=util['format'](_0x692f('0xd'),HOST,_0x5bdc37,module[_0x692f('0xe')][_0x692f('0x5')],oldToken);}var _0x340a0c={'uri':_0x5f35be,'method':_0x692f('0xf'),'timeout':0xea60,'json':!![]};return rp(_0x340a0c)[_0x692f('0x10')](function(_0x4cd665){_0x445ed1(_0x4cd665);})[_0x692f('0x11')](function(_0x4f7085){_0x111126(_0x4f7085);});});}function manageLicense(_0x4d706f,_0x384908){var _0x431cc6=_0x384908[_0x692f('0x12')]({'plain':!![]});if(!isOldTokenSent&&_0x431cc6[_0x692f('0x13')]!==_0x4d706f&&!_0x431cc6[_0x692f('0x14')]){oldToken=_0x431cc6['data1'];}httpRequest(_0x4d706f)['then'](function(_0x291788){if(oldToken){oldToken=undefined;isOldTokenSent=!![];}if(_0x291788['active']){isOldTokenSent=![];if(!_0x431cc6[_0x692f('0x9')]&&_0x431cc6[_0x692f('0x9')]!=_0x291788['license']||_0x431cc6[_0x692f('0x9')]&&_0x431cc6[_0x692f('0x14')]){logger[_0x692f('0x15')](_0x692f('0x16'));}if(_0x431cc6[_0x692f('0x9')]&&!_0x431cc6[_0x692f('0x14')]&&_0x431cc6[_0x692f('0x9')]!=_0x291788[_0x692f('0x9')]){logger['info'](_0x692f('0x17'));}if(_0x431cc6[_0x692f('0x9')]&&!_0x431cc6[_0x692f('0x14')]&&_0x431cc6[_0x692f('0x9')]==_0x291788[_0x692f('0x9')]){return _0x384908;}return _0x384908[_0x692f('0x18')]({'data1':_0x4d706f,'data2':null,'license':_0x291788['license']});}else{if(_0x291788[_0x692f('0x9')]||_0x431cc6[_0x692f('0x9')]){if(!_0x431cc6[_0x692f('0x14')]){if(_0x431cc6[_0x692f('0x13')]==_0x4d706f){GRAY_PERIOD_REASON=_0x692f('0x19');logger[_0x692f('0x15')]('THE\x20LICENSE\x20HAS\x20BEEN\x20DISABLED');}else{GRAY_PERIOD_REASON='Changed';logger[_0x692f('0x15')](_0x692f('0x1a'),_0x431cc6[_0x692f('0x13')],_0x4d706f);}logger[_0x692f('0x15')](_0x692f('0x1b'),GRAY_PERIOD_REASON[_0x692f('0x1c')](),moment()[_0x692f('0xb')](_0x692f('0x1d')));return _0x384908[_0x692f('0x18')]({'data2':encryptor[_0x692f('0x1e')](moment()['format'](_0x692f('0x1d')))});}else{if(moment()[_0x692f('0x1f')](encryptor[_0x692f('0x20')](_0x431cc6['data2']),_0x692f('0x21'))>DAYS){logger[_0x692f('0x15')]('DEMO\x20START\x20AT\x20%s',moment()[_0x692f('0xb')]('YYYY-MM-DD\x20HH:mm'));isOldTokenSent=![];return _0x384908[_0x692f('0x18')]({'data1':_0x4d706f,'data2':null,'license':null});}}}else{if(_0x431cc6[_0x692f('0x13')]!=_0x4d706f){logger['info']('NEW\x20UUID\x20DETECTED:\x20FROM\x20%s\x20TO\x20%s',_0x431cc6[_0x692f('0x13')],_0x4d706f);return _0x384908[_0x692f('0x18')]({'data1':_0x4d706f,'data2':null,'license':null});}}}return _0x384908;})[_0x692f('0x10')](function(_0xd330f1){_0x384908=_0xd330f1;})['catch'](function(_0x3b9185){logger[_0x692f('0x22')](_0x3b9185['message']);})[_0x692f('0x23')](function(){setTimeout(function(){manageLicense(hardware['getUuid'](),_0x384908);},TIME);});}function defaultLicense(){var _0x42f885=hardware[_0x692f('0x24')]();if(_0x42f885){return db[_0x692f('0x25')][_0x692f('0x26')]({'where':{'id':0x1},'defaults':{'data1':_0x42f885}})[_0x692f('0x27')](function(_0x23cbb0,_0x4a32fb){logger[_0x692f('0x15')](_0x692f('0x28'),_0x42f885);manageLicense(_0x42f885,_0x23cbb0);})[_0x692f('0x11')](function(_0x3a31f4){logger['error'](_0x3a31f4['message']);});}}exports[_0x692f('0x29')]=defaultLicense;
\ No newline at end of file
+var _0x685e=['active','info','THE\x20LICENSE\x20HAS\x20BEEN\x20ENABLED','THE\x20LICENSE\x20HAS\x20BEEN\x20UPDATED','update','Disabled','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','decryptString','days','DEMO\x20START\x20AT\x20%s','then','catch','error','message','finally','getUuid','SERVICE\x20LICENSE\x20STARTED\x20%s','default','moment','bluebird','pkginfo','version','../../components/encryptor','./hardware','../logger','license','format','%s/api/servers/%s/check?version=%s','exports','%s/api/servers/%s/check?version=%s&oldtoken=%s','data2','data1'];(function(_0x514bd1,_0x25ea3e){var _0x58a281=function(_0x25567a){while(--_0x25567a){_0x514bd1['push'](_0x514bd1['shift']());}};_0x58a281(++_0x25ea3e);}(_0x685e,0x1e0));var _0xe685=function(_0x56b138,_0x2396d6){_0x56b138=_0x56b138-0x0;var _0x3df878=_0x685e[_0x56b138];return _0x3df878;};'use strict';var util=require('util');var moment=require(_0xe685('0x0'));var rp=require('request-promise');var BPromise=require(_0xe685('0x1'));var pkginfo=require(_0xe685('0x2'))(module,_0xe685('0x3'));var db=require('../../mysqldb')['db'];var encryptor=require(_0xe685('0x4'));var hardware=require(_0xe685('0x5'));var logger=require(_0xe685('0x6'))(_0xe685('0x7'));var HOST='https://www.xcallymotion.com';var TIME=0x3c*0x1388;var DAYS=0x7;var GRAY_PERIOD_REASON;var oldToken;var isOldTokenSent=![];function httpRequest(_0x25803c){return new BPromise(function(_0x543da1,_0x2fdd9a){var _0x1da30f=util[_0xe685('0x8')](_0xe685('0x9'),HOST,_0x25803c,module[_0xe685('0xa')]['version']);if(oldToken){_0x1da30f=util['format'](_0xe685('0xb'),HOST,_0x25803c,module[_0xe685('0xa')]['version'],oldToken);}var _0x38c0a8={'uri':_0x1da30f,'method':'GET','timeout':0xea60,'json':!![]};return rp(_0x38c0a8)['then'](function(_0x23c5f7){_0x543da1(_0x23c5f7);})['catch'](function(_0x292745){_0x2fdd9a(_0x292745);});});}function manageLicense(_0x65ee02,_0xda3ca){var _0x14748d=_0xda3ca['get']({'plain':!![]});if(!isOldTokenSent&&_0x14748d['data1']!==_0x65ee02&&!_0x14748d[_0xe685('0xc')]){oldToken=_0x14748d[_0xe685('0xd')];}httpRequest(_0x65ee02)['then'](function(_0x37579f){if(oldToken){oldToken=undefined;isOldTokenSent=!![];}if(_0x37579f[_0xe685('0xe')]){isOldTokenSent=![];if(!_0x14748d[_0xe685('0x7')]&&_0x14748d[_0xe685('0x7')]!=_0x37579f['license']||_0x14748d['license']&&_0x14748d[_0xe685('0xc')]){logger[_0xe685('0xf')](_0xe685('0x10'));}if(_0x14748d[_0xe685('0x7')]&&!_0x14748d[_0xe685('0xc')]&&_0x14748d[_0xe685('0x7')]!=_0x37579f[_0xe685('0x7')]){logger['info'](_0xe685('0x11'));}if(_0x14748d[_0xe685('0x7')]&&!_0x14748d[_0xe685('0xc')]&&_0x14748d[_0xe685('0x7')]==_0x37579f[_0xe685('0x7')]){return _0xda3ca;}return _0xda3ca[_0xe685('0x12')]({'data1':_0x65ee02,'data2':null,'license':_0x37579f[_0xe685('0x7')]});}else{if(_0x37579f['license']||_0x14748d[_0xe685('0x7')]){if(!_0x14748d[_0xe685('0xc')]){if(_0x14748d[_0xe685('0xd')]==_0x65ee02){GRAY_PERIOD_REASON=_0xe685('0x13');logger[_0xe685('0xf')](_0xe685('0x14'));}else{GRAY_PERIOD_REASON=_0xe685('0x15');logger[_0xe685('0xf')](_0xe685('0x16'),_0x14748d['data1'],_0x65ee02);}logger[_0xe685('0xf')](_0xe685('0x17'),GRAY_PERIOD_REASON[_0xe685('0x18')](),moment()[_0xe685('0x8')](_0xe685('0x19')));return _0xda3ca[_0xe685('0x12')]({'data2':encryptor[_0xe685('0x1a')](moment()[_0xe685('0x8')](_0xe685('0x19')))});}else{if(moment()['diff'](encryptor[_0xe685('0x1b')](_0x14748d[_0xe685('0xc')]),_0xe685('0x1c'))>DAYS){logger[_0xe685('0xf')](_0xe685('0x1d'),moment()[_0xe685('0x8')](_0xe685('0x19')));isOldTokenSent=![];return _0xda3ca['update']({'data1':_0x65ee02,'data2':null,'license':null});}}}else{if(_0x14748d[_0xe685('0xd')]!=_0x65ee02){logger['info'](_0xe685('0x16'),_0x14748d[_0xe685('0xd')],_0x65ee02);return _0xda3ca[_0xe685('0x12')]({'data1':_0x65ee02,'data2':null,'license':null});}}}return _0xda3ca;})[_0xe685('0x1e')](function(_0x331f94){_0xda3ca=_0x331f94;})[_0xe685('0x1f')](function(_0x615a5e){logger[_0xe685('0x20')](_0x615a5e[_0xe685('0x21')]);})[_0xe685('0x22')](function(){setTimeout(function(){manageLicense(hardware[_0xe685('0x23')](),_0xda3ca);},TIME);});}function defaultLicense(){var _0x17be0f=hardware[_0xe685('0x23')]();if(_0x17be0f){return db['License']['findOrCreate']({'where':{'id':0x1},'defaults':{'data1':_0x17be0f}})['spread'](function(_0x5f2561,_0x578999){logger['info'](_0xe685('0x24'),_0x17be0f);manageLicense(_0x17be0f,_0x5f2561);})[_0xe685('0x1f')](function(_0x50f3e0){logger[_0xe685('0x20')](_0x50f3e0['message']);});}}exports[_0xe685('0x25')]=defaultLicense;
\ No newline at end of file