Built motion from commit ffdca78c.|2.6.24
[motion2.git] / server / api / network / network.controller.js
index 0e434cb..839eabb 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xcb79=['model','query','keys','filters','attributes','intersection','fields','length','limit','order','sort','pick','filter','where','merge','type','VIRTUAL','options','Network','includeAll','include','findAll','show','params','find','create','sequelize','body','readFileSync','join','root','server/files/templates/stun_multiple.ejs','utf8','/etc/asterisk/stun_xcally.conf','Reload','res_stun_monitor.so','toUpperCase','server/files/templates/turn_multiple.ejs','render','writeFileSync','/etc/asterisk/turn_xcally.conf','server/files/templates/network.ejs','format','chan_sip.so','STUN','/etc/asterisk/sip_xcally_%s.conf','toLowerCase','TURN','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','mustache','util','path','sox','to-csv','ejs','fs-extra','squel','jsforce','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/environment','../../config/license/util','jayson/promise','client','request','then','info','Network,\x20%s,\x20%s','debug','stringify','error','code','message','result','catch','sendStatus','status','end','json','offset','undefined','count','Content-Range','apply','reject','update','destroy','stack','name','send','map','rawAttributes'];(function(_0x5ecf8c,_0xcb8460){var _0x31e967=function(_0x14a767){while(--_0x14a767){_0x5ecf8c['push'](_0x5ecf8c['shift']());}};_0x31e967(++_0xcb8460);}(_0xcb79,0x15f));var _0x9cb7=function(_0x270880,_0x2968e6){_0x270880=_0x270880-0x0;var _0x50cfe1=_0xcb79[_0x270880];return _0x50cfe1;};'use strict';var emlformat=require(_0x9cb7('0x0'));var rimraf=require(_0x9cb7('0x1'));var zipdir=require(_0x9cb7('0x2'));var jsonpatch=require(_0x9cb7('0x3'));var rp=require(_0x9cb7('0x4'));var moment=require(_0x9cb7('0x5'));var BPromise=require('bluebird');var Mustache=require(_0x9cb7('0x6'));var util=require(_0x9cb7('0x7'));var path=require(_0x9cb7('0x8'));var sox=require(_0x9cb7('0x9'));var csv=require(_0x9cb7('0xa'));var ejs=require(_0x9cb7('0xb'));var fs=require('fs');var fs_extra=require(_0x9cb7('0xc'));var _=require('lodash');var squel=require(_0x9cb7('0xd'));var crypto=require('crypto');var jsforce=require(_0x9cb7('0xe'));var deskjs=require(_0x9cb7('0xf'));var toCsv=require('to-csv');var querystring=require(_0x9cb7('0x10'));var Papa=require('papaparse');var Redis=require(_0x9cb7('0x11'));var authService=require(_0x9cb7('0x12'));var qs=require(_0x9cb7('0x13'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x9cb7('0x14'));var logger=require('../../config/logger')('api');var utils=require('../../config/utils');var config=require(_0x9cb7('0x15'));var licenseUtil=require(_0x9cb7('0x16'));var db=require('../../mysqldb')['db'];var jayson=require(_0x9cb7('0x17'));var client=jayson[_0x9cb7('0x18')]['http']({'port':0x232a});function respondWithRpcPromise(_0x468b2b,_0x30f166,_0x599e09,_0x43041e){return new BPromise(function(_0x5a9958,_0x226173){var _0x3c9afe=_0x43041e||client;return _0x3c9afe[_0x9cb7('0x19')](_0x468b2b,_0x599e09)[_0x9cb7('0x1a')](function(_0xfb283c){logger[_0x9cb7('0x1b')](_0x9cb7('0x1c'),_0x30f166,'request\x20sent');logger[_0x9cb7('0x1d')]('Network,\x20%s,\x20%s,\x20%s',_0x30f166,'request\x20sent',JSON[_0x9cb7('0x1e')](_0xfb283c));if(_0xfb283c[_0x9cb7('0x1f')]){if(_0xfb283c[_0x9cb7('0x1f')][_0x9cb7('0x20')]===0x1f4){logger[_0x9cb7('0x1f')](_0x9cb7('0x1c'),_0x30f166,_0xfb283c[_0x9cb7('0x1f')][_0x9cb7('0x21')]);return _0x226173(_0xfb283c[_0x9cb7('0x1f')][_0x9cb7('0x21')]);}logger['error']('Network,\x20%s,\x20%s',_0x30f166,_0xfb283c[_0x9cb7('0x1f')]['message']);return _0x5a9958(_0xfb283c['error']['message']);}else{logger[_0x9cb7('0x1b')]('Network,\x20%s,\x20%s',_0x30f166,'request\x20sent');_0x5a9958(_0xfb283c[_0x9cb7('0x22')][_0x9cb7('0x21')]);}})[_0x9cb7('0x23')](function(_0x79a2c){logger[_0x9cb7('0x1f')]('Network,\x20%s,\x20%s',_0x30f166,_0x79a2c);_0x226173(_0x79a2c);});});}function respondWithStatusCode(_0x3255a6,_0x30a4aa){_0x30a4aa=_0x30a4aa||0xcc;return function(_0x1b1bca){if(_0x1b1bca){return _0x3255a6[_0x9cb7('0x24')](_0x30a4aa);}return _0x3255a6[_0x9cb7('0x25')](_0x30a4aa)[_0x9cb7('0x26')]();};}function respondWithResult(_0x5bb3e1,_0x3c5922){_0x3c5922=_0x3c5922||0xc8;return function(_0x2ff45e){if(_0x2ff45e){return _0x5bb3e1['status'](_0x3c5922)[_0x9cb7('0x27')](_0x2ff45e);}};}function respondWithFilteredResult(_0x1b5c16,_0xf33b2c){return function(_0x3c7461){if(_0x3c7461){var _0x5507d2=typeof _0xf33b2c[_0x9cb7('0x28')]===_0x9cb7('0x29')&&typeof _0xf33b2c['limit']===_0x9cb7('0x29');var _0x51d8a3=_0x3c7461[_0x9cb7('0x2a')];var _0x508546=_0x5507d2?0x0:_0xf33b2c[_0x9cb7('0x28')];var _0x3b1de5=_0x5507d2?_0x3c7461[_0x9cb7('0x2a')]:_0xf33b2c[_0x9cb7('0x28')]+_0xf33b2c['limit'];var _0x29d633;if(_0x3b1de5>=_0x51d8a3){_0x3b1de5=_0x51d8a3;_0x29d633=0xc8;}else{_0x29d633=0xce;}_0x1b5c16[_0x9cb7('0x25')](_0x29d633);return _0x1b5c16['set'](_0x9cb7('0x2b'),_0x508546+'-'+_0x3b1de5+'/'+_0x51d8a3)[_0x9cb7('0x27')](_0x3c7461);}return null;};}function patchUpdates(_0x1527c6){return function(_0x3ac804){try{jsonpatch[_0x9cb7('0x2c')](_0x3ac804,_0x1527c6,!![]);}catch(_0x2cdc49){return BPromise[_0x9cb7('0x2d')](_0x2cdc49);}return _0x3ac804['save']();};}function saveUpdates(_0x15ba4d,_0x703551){return function(_0x52dad4){if(_0x52dad4){return _0x52dad4[_0x9cb7('0x2e')](_0x15ba4d)[_0x9cb7('0x1a')](function(_0x55485a){return _0x55485a;});}return null;};}function removeEntity(_0x232378,_0x374d4e){return function(_0xd7294c){if(_0xd7294c){return _0xd7294c[_0x9cb7('0x2f')]()[_0x9cb7('0x1a')](function(){_0x232378[_0x9cb7('0x25')](0xcc)['end']();});}};}function handleEntityNotFound(_0x2980b9,_0x9720c){return function(_0x101e82){if(!_0x101e82){_0x2980b9['sendStatus'](0x194);}return _0x101e82;};}function handleError(_0x320952,_0x1d42d6){_0x1d42d6=_0x1d42d6||0x1f4;return function(_0x28f76c){logger[_0x9cb7('0x1f')](_0x28f76c[_0x9cb7('0x30')]);if(_0x28f76c[_0x9cb7('0x31')]){delete _0x28f76c[_0x9cb7('0x31')];}_0x320952[_0x9cb7('0x25')](_0x1d42d6)[_0x9cb7('0x32')](_0x28f76c);};}exports['index']=function(_0x25ea57,_0x109c06){var _0x2def03={},_0x3e8604={},_0x2a9eb0={'count':0x0,'rows':[]};var _0x11b495=_[_0x9cb7('0x33')](db['Network'][_0x9cb7('0x34')],function(_0x1119df){return{'name':_0x1119df['fieldName'],'type':_0x1119df['type']['key']};});_0x3e8604[_0x9cb7('0x35')]=_[_0x9cb7('0x33')](_0x11b495,'name');_0x3e8604[_0x9cb7('0x36')]=_[_0x9cb7('0x37')](_0x25ea57['query']);_0x3e8604[_0x9cb7('0x38')]=_['intersection'](_0x3e8604[_0x9cb7('0x35')],_0x3e8604['query']);_0x2def03[_0x9cb7('0x39')]=_[_0x9cb7('0x3a')](_0x3e8604[_0x9cb7('0x35')],qs[_0x9cb7('0x3b')](_0x25ea57['query']['fields']));_0x2def03[_0x9cb7('0x39')]=_0x2def03[_0x9cb7('0x39')][_0x9cb7('0x3c')]?_0x2def03[_0x9cb7('0x39')]:_0x3e8604[_0x9cb7('0x35')];if(!_0x25ea57[_0x9cb7('0x36')]['hasOwnProperty']('nolimit')){_0x2def03['limit']=qs[_0x9cb7('0x3d')](_0x25ea57[_0x9cb7('0x36')][_0x9cb7('0x3d')]);_0x2def03[_0x9cb7('0x28')]=qs[_0x9cb7('0x28')](_0x25ea57['query'][_0x9cb7('0x28')]);}_0x2def03[_0x9cb7('0x3e')]=qs[_0x9cb7('0x3f')](_0x25ea57[_0x9cb7('0x36')]['sort']);_0x2def03['where']=qs['filters'](_[_0x9cb7('0x40')](_0x25ea57[_0x9cb7('0x36')],_0x3e8604[_0x9cb7('0x38')]),_0x11b495);if(_0x25ea57[_0x9cb7('0x36')][_0x9cb7('0x41')]){_0x2def03[_0x9cb7('0x42')]=_[_0x9cb7('0x43')](_0x2def03[_0x9cb7('0x42')],{'$or':_['map'](_0x11b495,function(_0x43af4a){if(_0x43af4a[_0x9cb7('0x44')]!==_0x9cb7('0x45')){var _0x386093={};_0x386093[_0x43af4a['name']]={'$like':'%'+_0x25ea57[_0x9cb7('0x36')][_0x9cb7('0x41')]+'%'};return _0x386093;}})});}_0x2def03=_['merge']({},_0x2def03,_0x25ea57[_0x9cb7('0x46')]);var _0x8fb60={'where':_0x2def03[_0x9cb7('0x42')]};return db[_0x9cb7('0x47')][_0x9cb7('0x2a')](_0x8fb60)[_0x9cb7('0x1a')](function(_0x284ed4){_0x2a9eb0[_0x9cb7('0x2a')]=_0x284ed4;if(_0x25ea57[_0x9cb7('0x36')][_0x9cb7('0x48')]){_0x2def03[_0x9cb7('0x49')]=[{'all':!![]}];}return db[_0x9cb7('0x47')][_0x9cb7('0x4a')](_0x2def03);})[_0x9cb7('0x1a')](function(_0x40d23c){_0x2a9eb0['rows']=_0x40d23c;return _0x2a9eb0;})[_0x9cb7('0x1a')](respondWithFilteredResult(_0x109c06,_0x2def03))[_0x9cb7('0x23')](handleError(_0x109c06,null));};exports[_0x9cb7('0x4b')]=function(_0x4b279a,_0x3bd999){var _0x516479={'raw':!![],'where':{'id':_0x4b279a[_0x9cb7('0x4c')]['id']}},_0x1f9111={};_0x1f9111['model']=_[_0x9cb7('0x37')](db[_0x9cb7('0x47')]['rawAttributes']);_0x1f9111[_0x9cb7('0x36')]=_[_0x9cb7('0x37')](_0x4b279a[_0x9cb7('0x36')]);_0x1f9111[_0x9cb7('0x38')]=_[_0x9cb7('0x3a')](_0x1f9111[_0x9cb7('0x35')],_0x1f9111[_0x9cb7('0x36')]);_0x516479[_0x9cb7('0x39')]=_[_0x9cb7('0x3a')](_0x1f9111[_0x9cb7('0x35')],qs[_0x9cb7('0x3b')](_0x4b279a[_0x9cb7('0x36')][_0x9cb7('0x3b')]));_0x516479[_0x9cb7('0x39')]=_0x516479[_0x9cb7('0x39')][_0x9cb7('0x3c')]?_0x516479['attributes']:_0x1f9111['model'];if(_0x4b279a[_0x9cb7('0x36')][_0x9cb7('0x48')]){_0x516479[_0x9cb7('0x49')]=[{'all':!![]}];}_0x516479=_[_0x9cb7('0x43')]({},_0x516479,_0x4b279a['options']);return db[_0x9cb7('0x47')][_0x9cb7('0x4d')](_0x516479)[_0x9cb7('0x1a')](handleEntityNotFound(_0x3bd999,null))[_0x9cb7('0x1a')](respondWithResult(_0x3bd999,null))[_0x9cb7('0x23')](handleError(_0x3bd999,null));};exports[_0x9cb7('0x4e')]=function(_0x146dfd,_0x475576,_0x3ba2fc){var _0x203feb;return db[_0x9cb7('0x4f')]['transaction'](function(_0x4c6b0d){return db[_0x9cb7('0x47')][_0x9cb7('0x4e')](_0x146dfd[_0x9cb7('0x50')],{'raw':!![]})[_0x9cb7('0x1a')](function(_0x47c45c){_0x203feb=_0x47c45c;return db[_0x9cb7('0x47')]['findAll']({'where':{'type':_0x146dfd[_0x9cb7('0x50')]['type']},'raw':!![]});})[_0x9cb7('0x1a')](function(_0x77d3b4){if(_0x203feb['type']['toUpperCase']()=='STUN'){var _0x202cf9=fs[_0x9cb7('0x51')](path[_0x9cb7('0x52')](config[_0x9cb7('0x53')],_0x9cb7('0x54')),_0x9cb7('0x55'));var _0x42d215=ejs['render'](_0x202cf9,{'networks':_0x77d3b4||[]});fs['writeFileSync'](_0x9cb7('0x56'),_0x42d215);return respondWithRpcPromise(_0x9cb7('0x57'),'create',{'module':_0x9cb7('0x58')});}else if(_0x203feb[_0x9cb7('0x44')][_0x9cb7('0x59')]()=='TURN'){var _0x34076e=fs[_0x9cb7('0x51')](path[_0x9cb7('0x52')](config[_0x9cb7('0x53')],_0x9cb7('0x5a')),_0x9cb7('0x55'));var _0xd2c7af=ejs[_0x9cb7('0x5b')](_0x34076e,{'networks':_0x77d3b4||[]});fs[_0x9cb7('0x5c')](_0x9cb7('0x5d'),_0xd2c7af);return respondWithRpcPromise(_0x9cb7('0x57'),'create',{'module':_0x9cb7('0x58')});}else{var _0x330e04=fs[_0x9cb7('0x51')](path[_0x9cb7('0x52')](config['root'],_0x9cb7('0x5e')),_0x9cb7('0x55'));var _0x3d9e02=ejs[_0x9cb7('0x5b')](_0x330e04,{'networks':_0x77d3b4||[]});fs[_0x9cb7('0x5c')](util[_0x9cb7('0x5f')]('/etc/asterisk/sip_xcally_%s.conf',_0x146dfd[_0x9cb7('0x50')][_0x9cb7('0x44')]['toLowerCase']()),_0x3d9e02);return respondWithRpcPromise(_0x9cb7('0x57'),_0x9cb7('0x4e'),{'module':_0x9cb7('0x60')});}return null;})[_0x9cb7('0x1a')](function(){return _0x203feb;});})[_0x9cb7('0x1a')](respondWithResult(_0x475576,0xc9))[_0x9cb7('0x23')](handleError(_0x475576,null));};exports[_0x9cb7('0x2e')]=function(_0x1fb1f2,_0x55cb2e,_0x4fc4d1){var _0x3c4a93;return db[_0x9cb7('0x4f')]['transaction'](function(_0x48675e){return db['Network'][_0x9cb7('0x4d')]({'where':{'id':_0x1fb1f2[_0x9cb7('0x4c')]['id']}})[_0x9cb7('0x1a')](handleEntityNotFound(_0x55cb2e,null))['then'](saveUpdates(_0x1fb1f2[_0x9cb7('0x50')],null))['then'](function(_0x25b3b1){if(_0x25b3b1){_0x3c4a93=_0x25b3b1;return db[_0x9cb7('0x47')]['findAll']({'where':{'type':_0x3c4a93[_0x9cb7('0x44')]},'raw':!![]});}return null;})[_0x9cb7('0x1a')](function(_0x38467e){if(_0x3c4a93[_0x9cb7('0x44')][_0x9cb7('0x59')]()==_0x9cb7('0x61')){var _0xe71a3b=fs['readFileSync'](path['join'](config[_0x9cb7('0x53')],_0x9cb7('0x54')),_0x9cb7('0x55'));var _0x1accea=ejs[_0x9cb7('0x5b')](_0xe71a3b,{'networks':_0x38467e||[]});fs['writeFileSync'](_0x9cb7('0x56'),_0x1accea);return respondWithRpcPromise(_0x9cb7('0x57'),_0x9cb7('0x2e'),{'module':'res_stun_monitor.so'});}else if(_0x3c4a93[_0x9cb7('0x44')]['toUpperCase']()=='TURN'){var _0x3866c0=fs[_0x9cb7('0x51')](path[_0x9cb7('0x52')](config[_0x9cb7('0x53')],_0x9cb7('0x5a')),_0x9cb7('0x55'));var _0x5e16fd=ejs[_0x9cb7('0x5b')](_0x3866c0,{'networks':_0x38467e||[]});fs[_0x9cb7('0x5c')](_0x9cb7('0x5d'),_0x5e16fd);return respondWithRpcPromise(_0x9cb7('0x57'),_0x9cb7('0x2e'),{'module':_0x9cb7('0x58')});}else{var _0x3d7645=fs['readFileSync'](path[_0x9cb7('0x52')](config[_0x9cb7('0x53')],_0x9cb7('0x5e')),_0x9cb7('0x55'));var _0x6c7117=ejs['render'](_0x3d7645,{'networks':_0x38467e||[]});fs[_0x9cb7('0x5c')](util[_0x9cb7('0x5f')](_0x9cb7('0x62'),_0x1fb1f2[_0x9cb7('0x50')][_0x9cb7('0x44')][_0x9cb7('0x63')]()),_0x6c7117);return respondWithRpcPromise('Reload',_0x9cb7('0x2e'),{'module':_0x9cb7('0x60')});}return null;})[_0x9cb7('0x1a')](function(_0x35b007){if(_0x35b007){return _0x3c4a93;}return null;});})['then'](respondWithResult(_0x55cb2e,null))[_0x9cb7('0x23')](handleError(_0x55cb2e,null));};exports[_0x9cb7('0x2f')]=function(_0x3ab034,_0xf9ca00,_0x2da34b){var _0x451a92;return db['Network'][_0x9cb7('0x4d')]({'where':{'id':_0x3ab034[_0x9cb7('0x4c')]['id']}})[_0x9cb7('0x1a')](function(_0x207c26){_0x451a92=_0x207c26;return _0x207c26;})[_0x9cb7('0x1a')](handleEntityNotFound(_0xf9ca00,null))[_0x9cb7('0x1a')](removeEntity(_0xf9ca00,null))['then'](function(){if(_0x451a92){return db['Network'][_0x9cb7('0x4a')]({'where':{'type':_0x451a92[_0x9cb7('0x44')]},'raw':!![]});}})[_0x9cb7('0x1a')](function(_0x499375){if(_0x451a92[_0x9cb7('0x44')]['toUpperCase']()==_0x9cb7('0x61')){var _0x574488=fs['readFileSync'](path[_0x9cb7('0x52')](config['root'],_0x9cb7('0x54')),_0x9cb7('0x55'));var _0x22999b=ejs[_0x9cb7('0x5b')](_0x574488,{'networks':_0x499375||[]});fs[_0x9cb7('0x5c')]('/etc/asterisk/stun_xcally.conf',_0x22999b);return respondWithRpcPromise(_0x9cb7('0x57'),_0x9cb7('0x2f'),{'module':'res_stun_monitor.so'});}else if(_0x451a92[_0x9cb7('0x44')]['toUpperCase']()==_0x9cb7('0x64')){var _0x4ddec4=fs[_0x9cb7('0x51')](path[_0x9cb7('0x52')](config[_0x9cb7('0x53')],_0x9cb7('0x5a')),'utf8');var _0x2b35f3=ejs[_0x9cb7('0x5b')](_0x4ddec4,{'networks':_0x499375||[]});fs[_0x9cb7('0x5c')](_0x9cb7('0x5d'),_0x2b35f3);return respondWithRpcPromise(_0x9cb7('0x57'),_0x9cb7('0x2f'),{'module':'res_stun_monitor.so'});}else{var _0x47da00=fs[_0x9cb7('0x51')](path['join'](config[_0x9cb7('0x53')],_0x9cb7('0x5e')),_0x9cb7('0x55'));var _0x47d900=ejs[_0x9cb7('0x5b')](_0x47da00,{'networks':_0x499375||[]});fs[_0x9cb7('0x5c')](util['format']('/etc/asterisk/sip_xcally_%s.conf',_0x3ab034[_0x9cb7('0x50')][_0x9cb7('0x44')]['toLowerCase']()),_0x47d900);return respondWithRpcPromise('Reload',_0x9cb7('0x2f'),{'module':_0x9cb7('0x60')});}return null;})[_0x9cb7('0x23')](handleError(_0xf9ca00,null));};
\ No newline at end of file
+var _0xf507=['res_stun_monitor.so','toUpperCase','TURN','join','utf8','server/files/templates/network.ejs','/etc/asterisk/sip_xcally_%s.conf','chan_sip.so','update','params','STUN','server/files/templates/turn_multiple.ejs','/etc/asterisk/turn_xcally.conf','toLowerCase','format','path','ejs','lodash','../../components/parsers/qs','../../config/environment','jayson/promise','client','http','then','info','request\x20sent','debug','Network,\x20%s,\x20%s,\x20%s','stringify','error','message','Network,\x20%s,\x20%s','result','status','json','limit','undefined','count','offset','set','Content-Range','destroy','end','sendStatus','stack','name','send','index','map','Network','rawAttributes','fieldName','type','key','query','filters','intersection','model','fields','attributes','length','hasOwnProperty','nolimit','sort','where','pick','VIRTUAL','filter','merge','options','includeAll','include','findAll','rows','show','keys','find','catch','create','body','readFileSync','root','server/files/templates/stun_multiple.ejs','render','writeFileSync','/etc/asterisk/stun_xcally.conf','Reload'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0xf507,0xbd));var _0x7f50=function(_0x827d61,_0x127d23){_0x827d61=_0x827d61-0x0;var _0x3d2398=_0xf507[_0x827d61];return _0x3d2398;};'use strict';var util=require('util');var path=require(_0x7f50('0x0'));var ejs=require(_0x7f50('0x1'));var fs=require('fs');var _=require(_0x7f50('0x2'));var qs=require(_0x7f50('0x3'));var logger=require('../../config/logger')('api');var config=require(_0x7f50('0x4'));var db=require('../../mysqldb')['db'];var jayson=require(_0x7f50('0x5'));var client=jayson[_0x7f50('0x6')][_0x7f50('0x7')]({'port':0x232a});function respondWithRpcPromise(_0x6d929f,_0x416eac,_0x266631,_0xd62dc9){return new Promise(function(_0x15a443,_0x3aca22){var _0x20c697=_0xd62dc9||client;return _0x20c697['request'](_0x6d929f,_0x266631)[_0x7f50('0x8')](function(_0x3d6efe){logger[_0x7f50('0x9')]('Network,\x20%s,\x20%s',_0x416eac,_0x7f50('0xa'));logger[_0x7f50('0xb')](_0x7f50('0xc'),_0x416eac,_0x7f50('0xa'),JSON[_0x7f50('0xd')](_0x3d6efe));if(_0x3d6efe[_0x7f50('0xe')]){if(_0x3d6efe['error']['code']===0x1f4){logger[_0x7f50('0xe')]('Network,\x20%s,\x20%s',_0x416eac,_0x3d6efe[_0x7f50('0xe')]['message']);return _0x3aca22(_0x3d6efe['error'][_0x7f50('0xf')]);}logger[_0x7f50('0xe')](_0x7f50('0x10'),_0x416eac,_0x3d6efe[_0x7f50('0xe')][_0x7f50('0xf')]);return _0x15a443(_0x3d6efe['error'][_0x7f50('0xf')]);}else{logger[_0x7f50('0x9')](_0x7f50('0x10'),_0x416eac,_0x7f50('0xa'));_0x15a443(_0x3d6efe[_0x7f50('0x11')][_0x7f50('0xf')]);}})['catch'](function(_0x557013){logger['error'](_0x7f50('0x10'),_0x416eac,_0x557013);_0x3aca22(_0x557013);});});}function respondWithResult(_0x576752,_0x5afa2b){_0x5afa2b=_0x5afa2b||0xc8;return function(_0x21407d){if(_0x21407d){return _0x576752[_0x7f50('0x12')](_0x5afa2b)[_0x7f50('0x13')](_0x21407d);}};}function respondWithFilteredResult(_0x3c7aa4,_0x803ce8){return function(_0x237a8a){if(_0x237a8a){var _0xd19962=typeof _0x803ce8['offset']==='undefined'&&typeof _0x803ce8[_0x7f50('0x14')]===_0x7f50('0x15');var _0x5dcd7c=_0x237a8a[_0x7f50('0x16')];var _0x4b62d8=_0xd19962?0x0:_0x803ce8[_0x7f50('0x17')];var _0x3617b0=_0xd19962?_0x237a8a[_0x7f50('0x16')]:_0x803ce8[_0x7f50('0x17')]+_0x803ce8['limit'];var _0x43eb51;if(_0x3617b0>=_0x5dcd7c){_0x3617b0=_0x5dcd7c;_0x43eb51=0xc8;}else{_0x43eb51=0xce;}_0x3c7aa4[_0x7f50('0x12')](_0x43eb51);return _0x3c7aa4[_0x7f50('0x18')](_0x7f50('0x19'),_0x4b62d8+'-'+_0x3617b0+'/'+_0x5dcd7c)[_0x7f50('0x13')](_0x237a8a);}return null;};}function saveUpdates(_0x521208){return function(_0x5a42d2){if(_0x5a42d2){return _0x5a42d2['update'](_0x521208)[_0x7f50('0x8')](function(_0xf0d02b){return _0xf0d02b;});}return null;};}function removeEntity(_0x223fe2){return function(_0x41887d){if(_0x41887d){return _0x41887d[_0x7f50('0x1a')]()[_0x7f50('0x8')](function(){_0x223fe2[_0x7f50('0x12')](0xcc)[_0x7f50('0x1b')]();});}};}function handleEntityNotFound(_0xe219b7){return function(_0x380b02){if(!_0x380b02){_0xe219b7[_0x7f50('0x1c')](0x194);}return _0x380b02;};}function handleError(_0x80a4ef,_0x1df061){_0x1df061=_0x1df061||0x1f4;return function(_0x1de369){logger[_0x7f50('0xe')](_0x1de369[_0x7f50('0x1d')]);if(_0x1de369[_0x7f50('0x1e')]){delete _0x1de369[_0x7f50('0x1e')];}_0x80a4ef[_0x7f50('0x12')](_0x1df061)[_0x7f50('0x1f')](_0x1de369);};}exports[_0x7f50('0x20')]=function(_0x36b64e,_0x3ae435){var _0x43051f={},_0xd41b81={},_0x2b9d81={'count':0x0,'rows':[]};var _0x31cb30=_[_0x7f50('0x21')](db[_0x7f50('0x22')][_0x7f50('0x23')],function(_0x3cb7bb){return{'name':_0x3cb7bb[_0x7f50('0x24')],'type':_0x3cb7bb[_0x7f50('0x25')][_0x7f50('0x26')]};});_0xd41b81['model']=_['map'](_0x31cb30,_0x7f50('0x1e'));_0xd41b81[_0x7f50('0x27')]=_['keys'](_0x36b64e[_0x7f50('0x27')]);_0xd41b81[_0x7f50('0x28')]=_['intersection'](_0xd41b81['model'],_0xd41b81[_0x7f50('0x27')]);_0x43051f['attributes']=_[_0x7f50('0x29')](_0xd41b81[_0x7f50('0x2a')],qs[_0x7f50('0x2b')](_0x36b64e[_0x7f50('0x27')][_0x7f50('0x2b')]));_0x43051f['attributes']=_0x43051f[_0x7f50('0x2c')][_0x7f50('0x2d')]?_0x43051f[_0x7f50('0x2c')]:_0xd41b81[_0x7f50('0x2a')];if(!_0x36b64e[_0x7f50('0x27')][_0x7f50('0x2e')](_0x7f50('0x2f'))){_0x43051f[_0x7f50('0x14')]=qs[_0x7f50('0x14')](_0x36b64e[_0x7f50('0x27')][_0x7f50('0x14')]);_0x43051f[_0x7f50('0x17')]=qs[_0x7f50('0x17')](_0x36b64e[_0x7f50('0x27')][_0x7f50('0x17')]);}_0x43051f['order']=qs[_0x7f50('0x30')](_0x36b64e[_0x7f50('0x27')][_0x7f50('0x30')]);_0x43051f[_0x7f50('0x31')]=qs[_0x7f50('0x28')](_[_0x7f50('0x32')](_0x36b64e[_0x7f50('0x27')],_0xd41b81[_0x7f50('0x28')]),_0x31cb30);if(_0x36b64e[_0x7f50('0x27')]['filter']){_0x43051f['where']=_['merge'](_0x43051f[_0x7f50('0x31')],{'$or':_[_0x7f50('0x21')](_0x31cb30,function(_0xd90d18){if(_0xd90d18[_0x7f50('0x25')]!==_0x7f50('0x33')){var _0x349d62={};_0x349d62[_0xd90d18[_0x7f50('0x1e')]]={'$like':'%'+_0x36b64e[_0x7f50('0x27')][_0x7f50('0x34')]+'%'};return _0x349d62;}})});}_0x43051f=_[_0x7f50('0x35')]({},_0x43051f,_0x36b64e[_0x7f50('0x36')]);var _0x4eca6a={'where':_0x43051f[_0x7f50('0x31')]};return db[_0x7f50('0x22')][_0x7f50('0x16')](_0x4eca6a)[_0x7f50('0x8')](function(_0x5e7576){_0x2b9d81[_0x7f50('0x16')]=_0x5e7576;if(_0x36b64e[_0x7f50('0x27')][_0x7f50('0x37')]){_0x43051f[_0x7f50('0x38')]=[{'all':!![]}];}return db['Network'][_0x7f50('0x39')](_0x43051f);})[_0x7f50('0x8')](function(_0x8b3ff7){_0x2b9d81[_0x7f50('0x3a')]=_0x8b3ff7;return _0x2b9d81;})[_0x7f50('0x8')](respondWithFilteredResult(_0x3ae435,_0x43051f))['catch'](handleError(_0x3ae435,null));};exports[_0x7f50('0x3b')]=function(_0x2c06e4,_0x6f3aa4){var _0x359555={'raw':!![],'where':{'id':_0x2c06e4['params']['id']}},_0x24daaa={};_0x24daaa[_0x7f50('0x2a')]=_[_0x7f50('0x3c')](db[_0x7f50('0x22')][_0x7f50('0x23')]);_0x24daaa[_0x7f50('0x27')]=_[_0x7f50('0x3c')](_0x2c06e4[_0x7f50('0x27')]);_0x24daaa[_0x7f50('0x28')]=_['intersection'](_0x24daaa[_0x7f50('0x2a')],_0x24daaa[_0x7f50('0x27')]);_0x359555[_0x7f50('0x2c')]=_[_0x7f50('0x29')](_0x24daaa[_0x7f50('0x2a')],qs[_0x7f50('0x2b')](_0x2c06e4[_0x7f50('0x27')]['fields']));_0x359555[_0x7f50('0x2c')]=_0x359555['attributes'][_0x7f50('0x2d')]?_0x359555[_0x7f50('0x2c')]:_0x24daaa[_0x7f50('0x2a')];if(_0x2c06e4[_0x7f50('0x27')][_0x7f50('0x37')]){_0x359555[_0x7f50('0x38')]=[{'all':!![]}];}_0x359555=_[_0x7f50('0x35')]({},_0x359555,_0x2c06e4[_0x7f50('0x36')]);return db[_0x7f50('0x22')][_0x7f50('0x3d')](_0x359555)[_0x7f50('0x8')](handleEntityNotFound(_0x6f3aa4,null))[_0x7f50('0x8')](respondWithResult(_0x6f3aa4,null))[_0x7f50('0x3e')](handleError(_0x6f3aa4,null));};exports[_0x7f50('0x3f')]=function(_0x54b288,_0x43486e){var _0x5dda74;return db['Network'][_0x7f50('0x3f')](_0x54b288[_0x7f50('0x40')],{'raw':!![]})[_0x7f50('0x8')](function(_0x2141e4){_0x5dda74=_0x2141e4;return db[_0x7f50('0x22')][_0x7f50('0x39')]({'where':{'type':_0x54b288[_0x7f50('0x40')][_0x7f50('0x25')]},'raw':!![]});})[_0x7f50('0x8')](function(_0x53eef0){if(_0x5dda74[_0x7f50('0x25')]['toUpperCase']()=='STUN'){var _0x5f0405=fs[_0x7f50('0x41')](path['join'](config[_0x7f50('0x42')],_0x7f50('0x43')),'utf8');var _0xe59a49=ejs[_0x7f50('0x44')](_0x5f0405,{'networks':_0x53eef0||[]});fs[_0x7f50('0x45')](_0x7f50('0x46'),_0xe59a49);return respondWithRpcPromise(_0x7f50('0x47'),'create',{'module':_0x7f50('0x48')});}else if(_0x5dda74[_0x7f50('0x25')][_0x7f50('0x49')]()==_0x7f50('0x4a')){var _0x58d518=fs['readFileSync'](path[_0x7f50('0x4b')](config[_0x7f50('0x42')],'server/files/templates/turn_multiple.ejs'),_0x7f50('0x4c'));var _0x397dbc=ejs[_0x7f50('0x44')](_0x58d518,{'networks':_0x53eef0||[]});fs[_0x7f50('0x45')]('/etc/asterisk/turn_xcally.conf',_0x397dbc);return respondWithRpcPromise(_0x7f50('0x47'),_0x7f50('0x3f'),{'module':_0x7f50('0x48')});}else{var _0x3a5437=fs[_0x7f50('0x41')](path[_0x7f50('0x4b')](config['root'],_0x7f50('0x4d')),_0x7f50('0x4c'));var _0x246acd=ejs[_0x7f50('0x44')](_0x3a5437,{'networks':_0x53eef0||[]});fs[_0x7f50('0x45')](util['format'](_0x7f50('0x4e'),_0x54b288[_0x7f50('0x40')][_0x7f50('0x25')]['toLowerCase']()),_0x246acd);return respondWithRpcPromise(_0x7f50('0x47'),_0x7f50('0x3f'),{'module':_0x7f50('0x4f')});}})[_0x7f50('0x8')](function(){return _0x5dda74;})[_0x7f50('0x8')](respondWithResult(_0x43486e,0xc9))[_0x7f50('0x3e')](handleError(_0x43486e,null));};exports[_0x7f50('0x50')]=function(_0x1abee7,_0x41496a){var _0xa70055;return db[_0x7f50('0x22')][_0x7f50('0x3d')]({'where':{'id':_0x1abee7[_0x7f50('0x51')]['id']}})[_0x7f50('0x8')](handleEntityNotFound(_0x41496a,null))[_0x7f50('0x8')](saveUpdates(_0x1abee7[_0x7f50('0x40')],null))['then'](function(_0x3cc4d4){if(_0x3cc4d4){_0xa70055=_0x3cc4d4;return db['Network'][_0x7f50('0x39')]({'where':{'type':_0xa70055[_0x7f50('0x25')]},'raw':!![]});}return null;})[_0x7f50('0x8')](function(_0x28ecff){if(_0xa70055['type']['toUpperCase']()==_0x7f50('0x52')){var _0x2a24b2=fs[_0x7f50('0x41')](path[_0x7f50('0x4b')](config[_0x7f50('0x42')],_0x7f50('0x43')),_0x7f50('0x4c'));var _0x1db964=ejs[_0x7f50('0x44')](_0x2a24b2,{'networks':_0x28ecff||[]});fs[_0x7f50('0x45')](_0x7f50('0x46'),_0x1db964);return respondWithRpcPromise(_0x7f50('0x47'),_0x7f50('0x50'),{'module':'res_stun_monitor.so'});}else if(_0xa70055[_0x7f50('0x25')][_0x7f50('0x49')]()=='TURN'){var _0x361b9b=fs[_0x7f50('0x41')](path[_0x7f50('0x4b')](config[_0x7f50('0x42')],_0x7f50('0x53')),'utf8');var _0x1f7eef=ejs['render'](_0x361b9b,{'networks':_0x28ecff||[]});fs[_0x7f50('0x45')](_0x7f50('0x54'),_0x1f7eef);return respondWithRpcPromise(_0x7f50('0x47'),'update',{'module':'res_stun_monitor.so'});}else{var _0x1ed09a=fs[_0x7f50('0x41')](path[_0x7f50('0x4b')](config[_0x7f50('0x42')],'server/files/templates/network.ejs'),_0x7f50('0x4c'));var _0x15a67d=ejs[_0x7f50('0x44')](_0x1ed09a,{'networks':_0x28ecff||[]});fs[_0x7f50('0x45')](util['format']('/etc/asterisk/sip_xcally_%s.conf',_0x1abee7[_0x7f50('0x40')]['type'][_0x7f50('0x55')]()),_0x15a67d);return respondWithRpcPromise(_0x7f50('0x47'),_0x7f50('0x50'),{'module':_0x7f50('0x4f')});}})[_0x7f50('0x8')](function(_0x472fa2){if(_0x472fa2){return _0xa70055;}return null;})[_0x7f50('0x8')](respondWithResult(_0x41496a,null))[_0x7f50('0x3e')](handleError(_0x41496a,null));};exports['destroy']=function(_0x304b53,_0x30ec79){var _0x1117a0;return db[_0x7f50('0x22')][_0x7f50('0x3d')]({'where':{'id':_0x304b53[_0x7f50('0x51')]['id']}})['then'](function(_0x26e80e){_0x1117a0=_0x26e80e;return _0x26e80e;})[_0x7f50('0x8')](handleEntityNotFound(_0x30ec79,null))['then'](removeEntity(_0x30ec79,null))[_0x7f50('0x8')](function(){if(_0x1117a0){return db[_0x7f50('0x22')][_0x7f50('0x39')]({'where':{'type':_0x1117a0['type']},'raw':!![]});}})[_0x7f50('0x8')](function(_0x4ba56e){if(_0x1117a0[_0x7f50('0x25')][_0x7f50('0x49')]()==_0x7f50('0x52')){var _0xb17fa5=fs[_0x7f50('0x41')](path['join'](config['root'],_0x7f50('0x43')),_0x7f50('0x4c'));var _0x1d1525=ejs[_0x7f50('0x44')](_0xb17fa5,{'networks':_0x4ba56e||[]});fs[_0x7f50('0x45')](_0x7f50('0x46'),_0x1d1525);return respondWithRpcPromise(_0x7f50('0x47'),_0x7f50('0x1a'),{'module':'res_stun_monitor.so'});}else if(_0x1117a0[_0x7f50('0x25')][_0x7f50('0x49')]()==_0x7f50('0x4a')){var _0x4c1424=fs[_0x7f50('0x41')](path['join'](config[_0x7f50('0x42')],_0x7f50('0x53')),_0x7f50('0x4c'));var _0xc6f6d9=ejs[_0x7f50('0x44')](_0x4c1424,{'networks':_0x4ba56e||[]});fs[_0x7f50('0x45')](_0x7f50('0x54'),_0xc6f6d9);return respondWithRpcPromise(_0x7f50('0x47'),'destroy',{'module':_0x7f50('0x48')});}else{var _0x24ddd7=fs[_0x7f50('0x41')](path[_0x7f50('0x4b')](config[_0x7f50('0x42')],_0x7f50('0x4d')),_0x7f50('0x4c'));var _0x37fcb1=ejs[_0x7f50('0x44')](_0x24ddd7,{'networks':_0x4ba56e||[]});fs['writeFileSync'](util[_0x7f50('0x56')](_0x7f50('0x4e'),_0x1117a0[_0x7f50('0x25')][_0x7f50('0x55')]()),_0x37fcb1);return respondWithRpcPromise(_0x7f50('0x47'),_0x7f50('0x1a'),{'module':_0x7f50('0x4f')});}})[_0x7f50('0x3e')](handleError(_0x30ec79,null));};
\ No newline at end of file