Built motion from commit 25580385.|2.6.2
[motion2.git] / server / config / license / index.js
index d47e9d8..d89fe4b 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x85b0=['email','|reason|','|uuid|','|machineUuid|','|email|','ipAddress','openIssue','Alert','get','active','license','info','THE\x20LICENSE\x20HAS\x20BEEN\x20ENABLED','data2','THE\x20LICENSE\x20HAS\x20BEEN\x20UPDATED','update','data1','NEW\x20UUID\x20DETECTED:\x20FROM\x20%s\x20TO\x20%s','uuid','%s\x20-\x20GRAY\x20PERIOD\x20STARTED\x20AT\x20%s','YYYY-MM-DD\x20HH:mm','encryptString','diff','days','error','message','getUuid','License','findOrCreate','SERVICE\x20LICENSE\x20STARTED\x20%s','default','util','request-promise','bluebird','pkginfo','version','../../mysqldb','./hardware','../logger','process','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','||FIELD||VALUE||\x0a','User','findOne','admin','fullname'];(function(_0x403e08,_0x27ab69){var _0x2d0488=function(_0x76eee3){while(--_0x76eee3){_0x403e08['push'](_0x403e08['shift']());}};_0x2d0488(++_0x27ab69);}(_0x85b0,0xf3));var _0x085b=function(_0x388b2b,_0x4bcdfb){_0x388b2b=_0x388b2b-0x0;var _0x491672=_0x85b0[_0x388b2b];return _0x491672;};'use strict';var util=require(_0x085b('0x0'));var moment=require('moment');var rp=require(_0x085b('0x1'));var BPromise=require(_0x085b('0x2'));var pkginfo=require(_0x085b('0x3'))(module,_0x085b('0x4'));var db=require(_0x085b('0x5'))['db'];var encryptor=require('../../components/encryptor');var hardware=require(_0x085b('0x6'));var logger=require(_0x085b('0x7'))('license');var jira=require('../../api/jira/jira.controller');const {config}=require(_0x085b('0x8'));var HOST=_0x085b('0x9');var TIME=0x3c*0x1388;var DAYS=0x7;var GRAY_PERIOD_REASON;var ADMIN;var oldToken;function httpRequest(_0x51bdb4){return new BPromise(function(_0x552948,_0x31f0c2){var _0x57acfc=util[_0x085b('0xa')](_0x085b('0xb'),HOST,_0x51bdb4,module[_0x085b('0xc')][_0x085b('0x4')]);if(oldToken){_0x57acfc=util[_0x085b('0xa')](_0x085b('0xd'),HOST,_0x51bdb4,module['exports'][_0x085b('0x4')],oldToken);}var _0x2bb1b2={'uri':_0x57acfc,'method':_0x085b('0xe'),'timeout':0xea60,'json':!![]};return rp(_0x2bb1b2)[_0x085b('0xf')](function(_0x4fbb0d){_0x552948(_0x4fbb0d);})[_0x085b('0x10')](function(_0xd24ae2){_0x31f0c2(_0xd24ae2);});});}function sendJiraAlert(_0x1c5aa7,_0xbb4557,_0x6aab26){var _0x371c8c=_0x085b('0x11');return db[_0x085b('0x12')][_0x085b('0x13')]({'where':{'role':_0x085b('0x14')},'attributes':[_0x085b('0x15'),_0x085b('0x16')],'raw':!![]})[_0x085b('0xf')](function(_0x427381){ADMIN=_0x427381;_0x371c8c+=_0x085b('0x17')+_0x6aab26+'|\x0a';_0x371c8c+=_0x085b('0x18')+_0x1c5aa7+'|\x0a';_0x371c8c+=_0x085b('0x19')+_0xbb4557+'|\x0a';_0x371c8c+='|name|'+ADMIN[_0x085b('0x15')]+'|\x0a';_0x371c8c+=_0x085b('0x1a')+ADMIN[_0x085b('0x16')]+'|\x0a';return _0x371c8c;})['then'](function(_0x108a71){var _0x2e4d53=hardware['getFirstInterface']()[_0x085b('0x1b')];return jira[_0x085b('0x1c')]({'key':'MOTLICENSE','summary':'Motion\x20License\x20Alert','description':_0x108a71,'issuetype':_0x085b('0x1d'),'oldToken':_0x1c5aa7,'newToken':_0xbb4557,'email':ADMIN[_0x085b('0x16')],'name':ADMIN[_0x085b('0x15')],'reason':GRAY_PERIOD_REASON,'ip':_0x2e4d53});});}function manageLicense(_0x4bfa2b,_0x14a37b){var _0x28a461=_0x14a37b[_0x085b('0x1e')]({'plain':!![]});httpRequest(_0x4bfa2b)[_0x085b('0xf')](function(_0x1c4e8f){if(oldToken){oldToken=undefined;}if(_0x1c4e8f[_0x085b('0x1f')]){if(!_0x28a461[_0x085b('0x20')]&&_0x28a461[_0x085b('0x20')]!=_0x1c4e8f[_0x085b('0x20')]||_0x28a461[_0x085b('0x20')]&&_0x28a461['data2']){logger[_0x085b('0x21')](_0x085b('0x22'));}if(_0x28a461[_0x085b('0x20')]&&!_0x28a461[_0x085b('0x23')]&&_0x28a461[_0x085b('0x20')]!=_0x1c4e8f[_0x085b('0x20')]){logger[_0x085b('0x21')](_0x085b('0x24'));}if(_0x28a461[_0x085b('0x20')]&&!_0x28a461[_0x085b('0x23')]&&_0x28a461['license']==_0x1c4e8f[_0x085b('0x20')]){return _0x14a37b;}return _0x14a37b[_0x085b('0x25')]({'data1':_0x4bfa2b,'data2':null,'license':_0x1c4e8f[_0x085b('0x20')]});}else{if(_0x1c4e8f['license']||_0x28a461['license']){if(!_0x28a461['data2']){if(_0x28a461[_0x085b('0x26')]==_0x4bfa2b){GRAY_PERIOD_REASON='Disabled';logger[_0x085b('0x21')]('THE\x20LICENSE\x20HAS\x20BEEN\x20DISABLED');}else{GRAY_PERIOD_REASON='Changed';oldToken=_0x28a461[_0x085b('0x26')];logger[_0x085b('0x21')](_0x085b('0x27'),_0x28a461[_0x085b('0x26')],_0x4bfa2b);}sendJiraAlert(_0x28a461[_0x085b('0x26')],_0x1c4e8f[_0x085b('0x28')],GRAY_PERIOD_REASON);logger[_0x085b('0x21')](_0x085b('0x29'),GRAY_PERIOD_REASON['toUpperCase'](),moment()[_0x085b('0xa')](_0x085b('0x2a')));return _0x14a37b[_0x085b('0x25')]({'data2':encryptor[_0x085b('0x2b')](moment()[_0x085b('0xa')](_0x085b('0x2a')))});}else{if(moment()[_0x085b('0x2c')](encryptor['decryptString'](_0x28a461[_0x085b('0x23')]),_0x085b('0x2d'))>DAYS){logger[_0x085b('0x21')]('DEMO\x20START\x20AT\x20%s',moment()[_0x085b('0xa')](_0x085b('0x2a')));return _0x14a37b[_0x085b('0x25')]({'data1':_0x4bfa2b,'data2':null,'license':null});}}}else{if(_0x28a461[_0x085b('0x26')]!=_0x4bfa2b){logger[_0x085b('0x21')](_0x085b('0x27'),_0x28a461[_0x085b('0x26')],_0x4bfa2b);return _0x14a37b[_0x085b('0x25')]({'data1':_0x4bfa2b,'data2':null,'license':null});}}}return _0x14a37b;})[_0x085b('0xf')](function(_0x4de980){_0x14a37b=_0x4de980;})[_0x085b('0x10')](function(_0x261a25){logger[_0x085b('0x2e')](_0x261a25[_0x085b('0x2f')]);})['finally'](function(){setTimeout(function(){manageLicense(hardware[_0x085b('0x30')](),_0x14a37b);},TIME);});}function defaultLicense(){var _0x54e6a5=hardware[_0x085b('0x30')]();if(_0x54e6a5){return db[_0x085b('0x31')][_0x085b('0x32')]({'where':{'id':0x1},'defaults':{'data1':_0x54e6a5}})['spread'](function(_0x388078,_0x2074b7){logger['info'](_0x085b('0x33'),_0x54e6a5);manageLicense(_0x54e6a5,_0x388078);})['catch'](function(_0x29368f){logger[_0x085b('0x2e')](_0x29368f[_0x085b('0x2f')]);});}}exports[_0x085b('0x34')]=defaultLicense;
\ No newline at end of file
+var _0x57f3=['Disabled','NEW\x20UUID\x20DETECTED:\x20FROM\x20%s\x20TO\x20%s','%s\x20-\x20GRAY\x20PERIOD\x20STARTED\x20AT\x20%s','YYYY-MM-DD\x20HH:mm','update','diff','decryptString','error','getUuid','License','findOrCreate','SERVICE\x20LICENSE\x20STARTED\x20%s','default','util','request-promise','bluebird','version','../../mysqldb','../../components/encryptor','../logger','license','https://www.xcallymotion.com','format','%s/api/servers/%s/check?version=%s','exports','then','catch','data2','data1','active','info','THE\x20LICENSE\x20HAS\x20BEEN\x20ENABLED','THE\x20LICENSE\x20HAS\x20BEEN\x20UPDATED'];(function(_0x568496,_0x565afd){var _0x26c5c1=function(_0x4d251e){while(--_0x4d251e){_0x568496['push'](_0x568496['shift']());}};_0x26c5c1(++_0x565afd);}(_0x57f3,0x178));var _0x357f=function(_0x17d9e3,_0x1f969c){_0x17d9e3=_0x17d9e3-0x0;var _0x14192d=_0x57f3[_0x17d9e3];return _0x14192d;};'use strict';var util=require(_0x357f('0x0'));var moment=require('moment');var rp=require(_0x357f('0x1'));var BPromise=require(_0x357f('0x2'));var pkginfo=require('pkginfo')(module,_0x357f('0x3'));var db=require(_0x357f('0x4'))['db'];var encryptor=require(_0x357f('0x5'));var hardware=require('./hardware');var logger=require(_0x357f('0x6'))(_0x357f('0x7'));var HOST=_0x357f('0x8');var TIME=0x3c*0x1388;var DAYS=0x7;var GRAY_PERIOD_REASON;var oldToken;var isOldTokenSent=![];function httpRequest(_0x68b72a){return new BPromise(function(_0x4e77f1,_0x5a052f){var _0x3af30c=util[_0x357f('0x9')](_0x357f('0xa'),HOST,_0x68b72a,module['exports'][_0x357f('0x3')]);if(oldToken){_0x3af30c=util[_0x357f('0x9')]('%s/api/servers/%s/check?version=%s&oldtoken=%s',HOST,_0x68b72a,module[_0x357f('0xb')][_0x357f('0x3')],oldToken);}var _0x3e197d={'uri':_0x3af30c,'method':'GET','timeout':0xea60,'json':!![]};return rp(_0x3e197d)[_0x357f('0xc')](function(_0x4c914f){_0x4e77f1(_0x4c914f);})[_0x357f('0xd')](function(_0x48116e){_0x5a052f(_0x48116e);});});}function manageLicense(_0x4192a4,_0x275faf){var _0x40156f=_0x275faf['get']({'plain':!![]});if(!isOldTokenSent&&_0x40156f['data1']!==_0x4192a4&&!_0x40156f[_0x357f('0xe')]){oldToken=_0x40156f[_0x357f('0xf')];}httpRequest(_0x4192a4)['then'](function(_0x551f6b){if(oldToken){oldToken=undefined;isOldTokenSent=!![];}if(_0x551f6b[_0x357f('0x10')]){isOldTokenSent=![];if(!_0x40156f[_0x357f('0x7')]&&_0x40156f[_0x357f('0x7')]!=_0x551f6b['license']||_0x40156f[_0x357f('0x7')]&&_0x40156f[_0x357f('0xe')]){logger[_0x357f('0x11')](_0x357f('0x12'));}if(_0x40156f[_0x357f('0x7')]&&!_0x40156f['data2']&&_0x40156f[_0x357f('0x7')]!=_0x551f6b[_0x357f('0x7')]){logger[_0x357f('0x11')](_0x357f('0x13'));}if(_0x40156f[_0x357f('0x7')]&&!_0x40156f['data2']&&_0x40156f[_0x357f('0x7')]==_0x551f6b[_0x357f('0x7')]){return _0x275faf;}return _0x275faf['update']({'data1':_0x4192a4,'data2':null,'license':_0x551f6b[_0x357f('0x7')]});}else{if(_0x551f6b[_0x357f('0x7')]||_0x40156f[_0x357f('0x7')]){if(!_0x40156f[_0x357f('0xe')]){if(_0x40156f['data1']==_0x4192a4){GRAY_PERIOD_REASON=_0x357f('0x14');logger['info']('THE\x20LICENSE\x20HAS\x20BEEN\x20DISABLED');}else{GRAY_PERIOD_REASON='Changed';logger['info'](_0x357f('0x15'),_0x40156f[_0x357f('0xf')],_0x4192a4);}logger[_0x357f('0x11')](_0x357f('0x16'),GRAY_PERIOD_REASON['toUpperCase'](),moment()[_0x357f('0x9')](_0x357f('0x17')));return _0x275faf[_0x357f('0x18')]({'data2':encryptor['encryptString'](moment()[_0x357f('0x9')](_0x357f('0x17')))});}else{if(moment()[_0x357f('0x19')](encryptor[_0x357f('0x1a')](_0x40156f[_0x357f('0xe')]),'days')>DAYS){logger[_0x357f('0x11')]('DEMO\x20START\x20AT\x20%s',moment()[_0x357f('0x9')]('YYYY-MM-DD\x20HH:mm'));isOldTokenSent=![];return _0x275faf[_0x357f('0x18')]({'data1':_0x4192a4,'data2':null,'license':null});}}}else{if(_0x40156f['data1']!=_0x4192a4){logger[_0x357f('0x11')](_0x357f('0x15'),_0x40156f[_0x357f('0xf')],_0x4192a4);return _0x275faf[_0x357f('0x18')]({'data1':_0x4192a4,'data2':null,'license':null});}}}return _0x275faf;})[_0x357f('0xc')](function(_0x52a73d){_0x275faf=_0x52a73d;})[_0x357f('0xd')](function(_0x3505c2){logger[_0x357f('0x1b')](_0x3505c2['message']);})['finally'](function(){setTimeout(function(){manageLicense(hardware['getUuid'](),_0x275faf);},TIME);});}function defaultLicense(){var _0x5e089b=hardware[_0x357f('0x1c')]();if(_0x5e089b){return db[_0x357f('0x1d')][_0x357f('0x1e')]({'where':{'id':0x1},'defaults':{'data1':_0x5e089b}})['spread'](function(_0x5c0dc7,_0x32bb7e){logger[_0x357f('0x11')](_0x357f('0x1f'),_0x5e089b);manageLicense(_0x5e089b,_0x5c0dc7);})[_0x357f('0xd')](function(_0x28f494){logger['error'](_0x28f494['message']);});}}exports[_0x357f('0x20')]=defaultLicense;
\ No newline at end of file