Built motion from commit 43538d75.|2.5.35
[motion2.git] / server / config / license / index.js
index c3bc1ec..de03cfb 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x6f24=['THE\x20LICENSE\x20HAS\x20BEEN\x20DISABLED','NEW\x20UUID\x20DETECTED:\x20FROM\x20%s\x20TO\x20%s','uuid','%s\x20-\x20GRAY\x20PERIOD\x20STARTED\x20AT\x20%s','toUpperCase','format','YYYY-MM-DD\x20HH:mm','encryptString','diff','days','DEMO\x20START\x20AT\x20%s','error','getUuid','findOrCreate','spread','SERVICE\x20LICENSE\x20STARTED\x20%s','message','default','util','moment','request-promise','pkginfo','version','../../mysqldb','../../components/encryptor','./hardware','../logger','license','../../api/jira/jira.controller','process','%s/api/servers/%s/check?version=%s','exports','%s/api/servers/%s/check?version=%s&oldtoken=%s','GET','then','catch','User','admin','fullname','email','|reason|','|machineUuid|','|name|','|email|','getFirstInterface','ipAddress','MOTLICENSE','Motion\x20License\x20Alert','Alert','get','active','info','data2','update','data1','Disabled'];(function(_0x8dc04d,_0xaa7559){var _0x2f5f28=function(_0xdd2d1d){while(--_0xdd2d1d){_0x8dc04d['push'](_0x8dc04d['shift']());}};_0x2f5f28(++_0xaa7559);}(_0x6f24,0x19a));var _0x46f2=function(_0x1e4f2d,_0x22e2bb){_0x1e4f2d=_0x1e4f2d-0x0;var _0xd05ce5=_0x6f24[_0x1e4f2d];return _0xd05ce5;};'use strict';var util=require(_0x46f2('0x0'));var moment=require(_0x46f2('0x1'));var rp=require(_0x46f2('0x2'));var BPromise=require('bluebird');var pkginfo=require(_0x46f2('0x3'))(module,_0x46f2('0x4'));var db=require(_0x46f2('0x5'))['db'];var encryptor=require(_0x46f2('0x6'));var hardware=require(_0x46f2('0x7'));var logger=require(_0x46f2('0x8'))(_0x46f2('0x9'));var jira=require(_0x46f2('0xa'));const {config}=require(_0x46f2('0xb'));var HOST='https://www.xcallymotion.com';var TIME=0x3c*0x1388;var DAYS=0x7;var GRAY_PERIOD_REASON;var ADMIN;var oldToken;function httpRequest(_0x3f8260){return new BPromise(function(_0x3d1c1c,_0x5f18c4){var _0x3f811a=util['format'](_0x46f2('0xc'),HOST,_0x3f8260,module[_0x46f2('0xd')][_0x46f2('0x4')]);if(oldToken){_0x3f811a=util['format'](_0x46f2('0xe'),HOST,_0x3f8260,module[_0x46f2('0xd')][_0x46f2('0x4')],oldToken);}var _0x29099c={'uri':_0x3f811a,'method':_0x46f2('0xf'),'timeout':0xea60,'json':!![]};return rp(_0x29099c)[_0x46f2('0x10')](function(_0x4b623f){_0x3d1c1c(_0x4b623f);})[_0x46f2('0x11')](function(_0xb27331){_0x5f18c4(_0xb27331);});});}function sendJiraAlert(_0x436a46,_0x409c0c,_0x12ece6){var _0x498c14='||FIELD||VALUE||\x0a';return db[_0x46f2('0x12')]['findOne']({'where':{'role':_0x46f2('0x13')},'attributes':[_0x46f2('0x14'),_0x46f2('0x15')],'raw':!![]})[_0x46f2('0x10')](function(_0x135c3b){ADMIN=_0x135c3b;_0x498c14+=_0x46f2('0x16')+_0x12ece6+'|\x0a';_0x498c14+='|uuid|'+_0x436a46+'|\x0a';_0x498c14+=_0x46f2('0x17')+_0x409c0c+'|\x0a';_0x498c14+=_0x46f2('0x18')+ADMIN[_0x46f2('0x14')]+'|\x0a';_0x498c14+=_0x46f2('0x19')+ADMIN[_0x46f2('0x15')]+'|\x0a';return _0x498c14;})[_0x46f2('0x10')](function(_0xb0b400){var _0x158d68=hardware[_0x46f2('0x1a')]()[_0x46f2('0x1b')];return jira['openIssue']({'key':_0x46f2('0x1c'),'summary':_0x46f2('0x1d'),'description':_0xb0b400,'issuetype':_0x46f2('0x1e'),'oldToken':_0x436a46,'newToken':_0x409c0c,'email':ADMIN[_0x46f2('0x15')],'name':ADMIN[_0x46f2('0x14')],'reason':GRAY_PERIOD_REASON,'ip':_0x158d68});});}function manageLicense(_0x52b4e7,_0x5e9285){var _0x2f20b2=_0x5e9285[_0x46f2('0x1f')]({'plain':!![]});httpRequest(_0x52b4e7)[_0x46f2('0x10')](function(_0x1711e6){if(oldToken){oldToken=undefined;}if(_0x1711e6[_0x46f2('0x20')]){if(!_0x2f20b2[_0x46f2('0x9')]&&_0x2f20b2['license']!=_0x1711e6[_0x46f2('0x9')]||_0x2f20b2[_0x46f2('0x9')]&&_0x2f20b2['data2']){logger[_0x46f2('0x21')]('THE\x20LICENSE\x20HAS\x20BEEN\x20ENABLED');}if(_0x2f20b2[_0x46f2('0x9')]&&!_0x2f20b2[_0x46f2('0x22')]&&_0x2f20b2[_0x46f2('0x9')]!=_0x1711e6[_0x46f2('0x9')]){logger[_0x46f2('0x21')]('THE\x20LICENSE\x20HAS\x20BEEN\x20UPDATED');}if(_0x2f20b2[_0x46f2('0x9')]&&!_0x2f20b2[_0x46f2('0x22')]&&_0x2f20b2[_0x46f2('0x9')]==_0x1711e6[_0x46f2('0x9')]){return _0x5e9285;}return _0x5e9285[_0x46f2('0x23')]({'data1':_0x52b4e7,'data2':null,'license':_0x1711e6['license']});}else{if(_0x1711e6[_0x46f2('0x9')]||_0x2f20b2[_0x46f2('0x9')]){if(!_0x2f20b2['data2']){if(_0x2f20b2[_0x46f2('0x24')]==_0x52b4e7){GRAY_PERIOD_REASON=_0x46f2('0x25');logger[_0x46f2('0x21')](_0x46f2('0x26'));}else{GRAY_PERIOD_REASON='Changed';oldToken=_0x2f20b2[_0x46f2('0x24')];logger[_0x46f2('0x21')](_0x46f2('0x27'),_0x2f20b2[_0x46f2('0x24')],_0x52b4e7);}sendJiraAlert(_0x2f20b2[_0x46f2('0x24')],_0x1711e6[_0x46f2('0x28')],GRAY_PERIOD_REASON);logger['info'](_0x46f2('0x29'),GRAY_PERIOD_REASON[_0x46f2('0x2a')](),moment()[_0x46f2('0x2b')](_0x46f2('0x2c')));return _0x5e9285[_0x46f2('0x23')]({'data2':encryptor[_0x46f2('0x2d')](moment()[_0x46f2('0x2b')](_0x46f2('0x2c')))});}else{if(moment()[_0x46f2('0x2e')](encryptor['decryptString'](_0x2f20b2[_0x46f2('0x22')]),_0x46f2('0x2f'))>DAYS){logger[_0x46f2('0x21')](_0x46f2('0x30'),moment()[_0x46f2('0x2b')](_0x46f2('0x2c')));return _0x5e9285['update']({'data1':_0x52b4e7,'data2':null,'license':null});}}}else{if(_0x2f20b2[_0x46f2('0x24')]!=_0x52b4e7){logger[_0x46f2('0x21')](_0x46f2('0x27'),_0x2f20b2[_0x46f2('0x24')],_0x52b4e7);return _0x5e9285[_0x46f2('0x23')]({'data1':_0x52b4e7,'data2':null,'license':null});}}}return _0x5e9285;})[_0x46f2('0x10')](function(_0x4ca84a){_0x5e9285=_0x4ca84a;})[_0x46f2('0x11')](function(_0x120887){logger[_0x46f2('0x31')](_0x120887['message']);})['finally'](function(){setTimeout(function(){manageLicense(hardware[_0x46f2('0x32')](),_0x5e9285);},TIME);});}function defaultLicense(){var _0x146e24=hardware[_0x46f2('0x32')]();if(_0x146e24){return db['License'][_0x46f2('0x33')]({'where':{'id':0x1},'defaults':{'data1':_0x146e24}})[_0x46f2('0x34')](function(_0x45dcf5,_0x580c04){logger[_0x46f2('0x21')](_0x46f2('0x35'),_0x146e24);manageLicense(_0x146e24,_0x45dcf5);})[_0x46f2('0x11')](function(_0x176d88){logger[_0x46f2('0x31')](_0x176d88[_0x46f2('0x36')]);});}}exports[_0x46f2('0x37')]=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