Built motion from commit 47436d59.|2.6.7
[motion2.git] / server / api / network / network.controller.js
index fb98dd5..16e7985 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xda20=['model','query','keys','filters','attributes','intersection','fields','hasOwnProperty','nolimit','limit','order','sort','where','filter','options','includeAll','include','rows','show','params','merge','create','sequelize','transaction','body','findAll','STUN','readFileSync','join','root','server/files/templates/stun_multiple.ejs','utf8','render','writeFileSync','/etc/asterisk/stun_xcally.conf','Reload','res_stun_monitor.so','toUpperCase','server/files/templates/turn_multiple.ejs','server/files/templates/network.ejs','format','/etc/asterisk/sip_xcally_%s.conf','toLowerCase','update','/etc/asterisk/turn_xcally.conf','chan_sip.so','destroy','find','TURN','html-pdf','rimraf','request-promise','bluebird','mustache','path','sox','ejs','lodash','squel','crypto','jsforce','desk.js','to-csv','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','jayson/promise','client','http','request','then','info','Network,\x20%s,\x20%s','debug','Network,\x20%s,\x20%s,\x20%s','request\x20sent','error','message','result','catch','sendStatus','status','end','count','offset','Content-Range','json','apply','reject','save','stack','name','send','index','map','Network','rawAttributes','type','key'];(function(_0x5b7428,_0xfb032){var _0x1bb14b=function(_0x192ccd){while(--_0x192ccd){_0x5b7428['push'](_0x5b7428['shift']());}};_0x1bb14b(++_0xfb032);}(_0xda20,0x1d9));var _0x0da2=function(_0x1c52a5,_0x58673f){_0x1c52a5=_0x1c52a5-0x0;var _0x34a8cc=_0xda20[_0x1c52a5];return _0x34a8cc;};'use strict';var pdf=require(_0x0da2('0x0'));var emlformat=require('eml-format');var rimraf=require(_0x0da2('0x1'));var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require(_0x0da2('0x2'));var moment=require('moment');var BPromise=require(_0x0da2('0x3'));var Mustache=require(_0x0da2('0x4'));var util=require('util');var path=require(_0x0da2('0x5'));var sox=require(_0x0da2('0x6'));var csv=require('to-csv');var ejs=require(_0x0da2('0x7'));var fs=require('fs');var _=require(_0x0da2('0x8'));var squel=require(_0x0da2('0x9'));var crypto=require(_0x0da2('0xa'));var jsforce=require(_0x0da2('0xb'));var deskjs=require(_0x0da2('0xc'));var toCsv=require(_0x0da2('0xd'));var querystring=require(_0x0da2('0xe'));var Papa=require(_0x0da2('0xf'));var Redis=require('ioredis');var authService=require(_0x0da2('0x10'));var qs=require(_0x0da2('0x11'));var as=require(_0x0da2('0x12'));var hardwareService=require(_0x0da2('0x13'));var logger=require('../../config/logger')('api');var utils=require(_0x0da2('0x14'));var config=require(_0x0da2('0x15'));var licenseUtil=require(_0x0da2('0x16'));var db=require(_0x0da2('0x17'))['db'];var jayson=require(_0x0da2('0x18'));var client=jayson[_0x0da2('0x19')][_0x0da2('0x1a')]({'port':0x232a});function respondWithRpcPromise(_0x4d2a3d,_0x7dfc07,_0x570d68,_0x5496f5){return new BPromise(function(_0x4cc28c,_0x2289c2){var _0x51bb68=_0x5496f5||client;return _0x51bb68[_0x0da2('0x1b')](_0x4d2a3d,_0x570d68)[_0x0da2('0x1c')](function(_0x5d0f4e){logger[_0x0da2('0x1d')](_0x0da2('0x1e'),_0x7dfc07,'request\x20sent');logger[_0x0da2('0x1f')](_0x0da2('0x20'),_0x7dfc07,_0x0da2('0x21'),JSON['stringify'](_0x5d0f4e));if(_0x5d0f4e[_0x0da2('0x22')]){if(_0x5d0f4e[_0x0da2('0x22')]['code']===0x1f4){logger['error'](_0x0da2('0x1e'),_0x7dfc07,_0x5d0f4e['error'][_0x0da2('0x23')]);return _0x2289c2(_0x5d0f4e['error']['message']);}logger['error']('Network,\x20%s,\x20%s',_0x7dfc07,_0x5d0f4e[_0x0da2('0x22')][_0x0da2('0x23')]);return _0x4cc28c(_0x5d0f4e[_0x0da2('0x22')]['message']);}else{logger['info']('Network,\x20%s,\x20%s',_0x7dfc07,_0x0da2('0x21'));_0x4cc28c(_0x5d0f4e[_0x0da2('0x24')][_0x0da2('0x23')]);}})[_0x0da2('0x25')](function(_0x262630){logger['error'](_0x0da2('0x1e'),_0x7dfc07,_0x262630);_0x2289c2(_0x262630);});});}function respondWithStatusCode(_0x113c40,_0x1c3ab0){_0x1c3ab0=_0x1c3ab0||0xcc;return function(_0x3c3dbc){if(_0x3c3dbc){return _0x113c40[_0x0da2('0x26')](_0x1c3ab0);}return _0x113c40[_0x0da2('0x27')](_0x1c3ab0)[_0x0da2('0x28')]();};}function respondWithResult(_0x7c4de3,_0x3604d3){_0x3604d3=_0x3604d3||0xc8;return function(_0x484543){if(_0x484543){return _0x7c4de3[_0x0da2('0x27')](_0x3604d3)['json'](_0x484543);}};}function respondWithFilteredResult(_0x40fc6a,_0x437090){return function(_0x2aa651){if(_0x2aa651){var _0x3c0fb0=_0x2aa651[_0x0da2('0x29')],_0x4b9333=_0x437090[_0x0da2('0x2a')],_0x1e9ac4=_0x437090[_0x0da2('0x2a')]+_0x437090['limit'],_0x2a931d;if(_0x1e9ac4>=_0x3c0fb0){_0x1e9ac4=_0x3c0fb0;_0x2a931d=0xc8;}else{_0x2a931d=0xce;}_0x40fc6a[_0x0da2('0x27')](_0x2a931d);return _0x40fc6a['set'](_0x0da2('0x2b'),_0x4b9333+'-'+_0x1e9ac4+'/'+_0x3c0fb0)[_0x0da2('0x2c')](_0x2aa651);}return null;};}function patchUpdates(_0x19058e){return function(_0x3a2625){try{jsonpatch[_0x0da2('0x2d')](_0x3a2625,_0x19058e,!![]);}catch(_0x103857){return BPromise[_0x0da2('0x2e')](_0x103857);}return _0x3a2625[_0x0da2('0x2f')]();};}function saveUpdates(_0x1f2b6f,_0x20d591){return function(_0x3981a5){if(_0x3981a5){return _0x3981a5['update'](_0x1f2b6f)['then'](function(_0x51a83e){return _0x51a83e;});}return null;};}function removeEntity(_0x94accb,_0x45d53d){return function(_0x54eda5){if(_0x54eda5){return _0x54eda5['destroy']()[_0x0da2('0x1c')](function(){_0x94accb[_0x0da2('0x27')](0xcc)[_0x0da2('0x28')]();});}};}function handleEntityNotFound(_0x1e6a75,_0x516e63){return function(_0x58b9ea){if(!_0x58b9ea){_0x1e6a75['sendStatus'](0x194);}return _0x58b9ea;};}function handleError(_0x281829,_0x5fccd){_0x5fccd=_0x5fccd||0x1f4;return function(_0x339d33){logger[_0x0da2('0x22')](_0x339d33[_0x0da2('0x30')]);if(_0x339d33[_0x0da2('0x31')]){delete _0x339d33[_0x0da2('0x31')];}_0x281829['status'](_0x5fccd)[_0x0da2('0x32')](_0x339d33);};}exports[_0x0da2('0x33')]=function(_0x41cd52,_0xbef5da){var _0x2cfddc={},_0x1b3c60={},_0x540c8f={'count':0x0,'rows':[]};var _0x408b21=_[_0x0da2('0x34')](db[_0x0da2('0x35')][_0x0da2('0x36')],function(_0x578299){return{'name':_0x578299['fieldName'],'type':_0x578299[_0x0da2('0x37')][_0x0da2('0x38')]};});_0x1b3c60[_0x0da2('0x39')]=_[_0x0da2('0x34')](_0x408b21,_0x0da2('0x31'));_0x1b3c60[_0x0da2('0x3a')]=_[_0x0da2('0x3b')](_0x41cd52[_0x0da2('0x3a')]);_0x1b3c60[_0x0da2('0x3c')]=_['intersection'](_0x1b3c60[_0x0da2('0x39')],_0x1b3c60[_0x0da2('0x3a')]);_0x2cfddc[_0x0da2('0x3d')]=_[_0x0da2('0x3e')](_0x1b3c60[_0x0da2('0x39')],qs[_0x0da2('0x3f')](_0x41cd52[_0x0da2('0x3a')][_0x0da2('0x3f')]));_0x2cfddc['attributes']=_0x2cfddc[_0x0da2('0x3d')]['length']?_0x2cfddc['attributes']:_0x1b3c60[_0x0da2('0x39')];if(!_0x41cd52['query'][_0x0da2('0x40')](_0x0da2('0x41'))){_0x2cfddc[_0x0da2('0x42')]=qs[_0x0da2('0x42')](_0x41cd52['query'][_0x0da2('0x42')]);_0x2cfddc[_0x0da2('0x2a')]=qs[_0x0da2('0x2a')](_0x41cd52[_0x0da2('0x3a')][_0x0da2('0x2a')]);}_0x2cfddc[_0x0da2('0x43')]=qs[_0x0da2('0x44')](_0x41cd52[_0x0da2('0x3a')]['sort']);_0x2cfddc['where']=qs[_0x0da2('0x3c')](_['pick'](_0x41cd52[_0x0da2('0x3a')],_0x1b3c60['filters']),_0x408b21);if(_0x41cd52[_0x0da2('0x3a')]['filter']){_0x2cfddc['where']=_['merge'](_0x2cfddc[_0x0da2('0x45')],{'$or':_[_0x0da2('0x34')](_0x408b21,function(_0x11ade3){if(_0x11ade3[_0x0da2('0x37')]!=='VIRTUAL'){var _0x10ffdc={};_0x10ffdc[_0x11ade3['name']]={'$like':'%'+_0x41cd52[_0x0da2('0x3a')][_0x0da2('0x46')]+'%'};return _0x10ffdc;}})});}_0x2cfddc=_['merge']({},_0x2cfddc,_0x41cd52[_0x0da2('0x47')]);var _0x2dd376={'where':_0x2cfddc[_0x0da2('0x45')]};return db[_0x0da2('0x35')]['count'](_0x2dd376)[_0x0da2('0x1c')](function(_0x3b0e28){_0x540c8f['count']=_0x3b0e28;if(_0x41cd52[_0x0da2('0x3a')][_0x0da2('0x48')]){_0x2cfddc[_0x0da2('0x49')]=[{'all':!![]}];}return db[_0x0da2('0x35')]['findAll'](_0x2cfddc);})[_0x0da2('0x1c')](function(_0x5265f2){_0x540c8f[_0x0da2('0x4a')]=_0x5265f2;return _0x540c8f;})[_0x0da2('0x1c')](respondWithFilteredResult(_0xbef5da,_0x2cfddc))[_0x0da2('0x25')](handleError(_0xbef5da,null));};exports[_0x0da2('0x4b')]=function(_0x2e36c6,_0x520804){var _0x37ace0={'raw':!![],'where':{'id':_0x2e36c6[_0x0da2('0x4c')]['id']}},_0xbdcb74={};_0xbdcb74[_0x0da2('0x39')]=_['keys'](db[_0x0da2('0x35')][_0x0da2('0x36')]);_0xbdcb74[_0x0da2('0x3a')]=_[_0x0da2('0x3b')](_0x2e36c6[_0x0da2('0x3a')]);_0xbdcb74['filters']=_[_0x0da2('0x3e')](_0xbdcb74[_0x0da2('0x39')],_0xbdcb74[_0x0da2('0x3a')]);_0x37ace0[_0x0da2('0x3d')]=_[_0x0da2('0x3e')](_0xbdcb74[_0x0da2('0x39')],qs[_0x0da2('0x3f')](_0x2e36c6['query'][_0x0da2('0x3f')]));_0x37ace0['attributes']=_0x37ace0['attributes']['length']?_0x37ace0[_0x0da2('0x3d')]:_0xbdcb74[_0x0da2('0x39')];if(_0x2e36c6[_0x0da2('0x3a')][_0x0da2('0x48')]){_0x37ace0['include']=[{'all':!![]}];}_0x37ace0=_[_0x0da2('0x4d')]({},_0x37ace0,_0x2e36c6['options']);return db['Network']['find'](_0x37ace0)[_0x0da2('0x1c')](handleEntityNotFound(_0x520804,null))[_0x0da2('0x1c')](respondWithResult(_0x520804,null))[_0x0da2('0x25')](handleError(_0x520804,null));};exports[_0x0da2('0x4e')]=function(_0x4efcc1,_0xe1000e,_0x42dcd9){var _0x3a0d6f;return db[_0x0da2('0x4f')][_0x0da2('0x50')](function(_0x1cf2ff){return db[_0x0da2('0x35')]['create'](_0x4efcc1[_0x0da2('0x51')],{'raw':!![]})[_0x0da2('0x1c')](function(_0x3e5425){_0x3a0d6f=_0x3e5425;return db[_0x0da2('0x35')][_0x0da2('0x52')]({'where':{'type':_0x4efcc1['body']['type']},'raw':!![]});})[_0x0da2('0x1c')](function(_0x34f672){if(_0x3a0d6f['type']['toUpperCase']()==_0x0da2('0x53')){var _0x2e6353=fs[_0x0da2('0x54')](path[_0x0da2('0x55')](config[_0x0da2('0x56')],_0x0da2('0x57')),_0x0da2('0x58'));var _0x3ee485=ejs[_0x0da2('0x59')](_0x2e6353,{'networks':_0x34f672||[]});fs[_0x0da2('0x5a')](_0x0da2('0x5b'),_0x3ee485);return respondWithRpcPromise(_0x0da2('0x5c'),_0x0da2('0x4e'),{'module':_0x0da2('0x5d')});}else if(_0x3a0d6f['type'][_0x0da2('0x5e')]()=='TURN'){var _0x47abf2=fs[_0x0da2('0x54')](path[_0x0da2('0x55')](config[_0x0da2('0x56')],_0x0da2('0x5f')),_0x0da2('0x58'));var _0x282352=ejs[_0x0da2('0x59')](_0x47abf2,{'networks':_0x34f672||[]});fs['writeFileSync']('/etc/asterisk/turn_xcally.conf',_0x282352);return respondWithRpcPromise(_0x0da2('0x5c'),'create',{'module':'res_stun_monitor.so'});}else{var _0x3dd02f=fs[_0x0da2('0x54')](path[_0x0da2('0x55')](config[_0x0da2('0x56')],_0x0da2('0x60')),_0x0da2('0x58'));var _0x571728=ejs[_0x0da2('0x59')](_0x3dd02f,{'networks':_0x34f672||[]});fs[_0x0da2('0x5a')](util[_0x0da2('0x61')](_0x0da2('0x62'),_0x4efcc1['body'][_0x0da2('0x37')][_0x0da2('0x63')]()),_0x571728);return respondWithRpcPromise('Reload',_0x0da2('0x4e'),{'module':'chan_sip.so'});}return null;})[_0x0da2('0x1c')](function(){return _0x3a0d6f;});})[_0x0da2('0x1c')](respondWithResult(_0xe1000e,0xc9))[_0x0da2('0x25')](handleError(_0xe1000e,null));};exports[_0x0da2('0x64')]=function(_0x31910d,_0x26dd55,_0x5c1840){var _0x4c8800;return db['sequelize'][_0x0da2('0x50')](function(_0x3313b2){return db[_0x0da2('0x35')]['find']({'where':{'id':_0x31910d['params']['id']}})[_0x0da2('0x1c')](handleEntityNotFound(_0x26dd55,null))['then'](saveUpdates(_0x31910d[_0x0da2('0x51')],null))[_0x0da2('0x1c')](function(_0x15c7a2){if(_0x15c7a2){_0x4c8800=_0x15c7a2;return db[_0x0da2('0x35')][_0x0da2('0x52')]({'where':{'type':_0x4c8800[_0x0da2('0x37')]},'raw':!![]});}return null;})[_0x0da2('0x1c')](function(_0x36d9de){if(_0x4c8800[_0x0da2('0x37')]['toUpperCase']()=='STUN'){var _0xb71616=fs[_0x0da2('0x54')](path[_0x0da2('0x55')](config[_0x0da2('0x56')],_0x0da2('0x57')),_0x0da2('0x58'));var _0x220d4d=ejs[_0x0da2('0x59')](_0xb71616,{'networks':_0x36d9de||[]});fs[_0x0da2('0x5a')](_0x0da2('0x5b'),_0x220d4d);return respondWithRpcPromise(_0x0da2('0x5c'),_0x0da2('0x64'),{'module':_0x0da2('0x5d')});}else if(_0x4c8800[_0x0da2('0x37')][_0x0da2('0x5e')]()=='TURN'){var _0x3a43e7=fs[_0x0da2('0x54')](path['join'](config[_0x0da2('0x56')],_0x0da2('0x5f')),_0x0da2('0x58'));var _0x161e5c=ejs['render'](_0x3a43e7,{'networks':_0x36d9de||[]});fs['writeFileSync'](_0x0da2('0x65'),_0x161e5c);return respondWithRpcPromise(_0x0da2('0x5c'),_0x0da2('0x64'),{'module':_0x0da2('0x5d')});}else{var _0x1a80a1=fs[_0x0da2('0x54')](path[_0x0da2('0x55')](config['root'],_0x0da2('0x60')),_0x0da2('0x58'));var _0x1806df=ejs[_0x0da2('0x59')](_0x1a80a1,{'networks':_0x36d9de||[]});fs[_0x0da2('0x5a')](util['format'](_0x0da2('0x62'),_0x31910d[_0x0da2('0x51')]['type'][_0x0da2('0x63')]()),_0x1806df);return respondWithRpcPromise(_0x0da2('0x5c'),_0x0da2('0x64'),{'module':_0x0da2('0x66')});}return null;})[_0x0da2('0x1c')](function(_0x3a6fa8){if(_0x3a6fa8){return _0x4c8800;}return null;});})[_0x0da2('0x1c')](respondWithResult(_0x26dd55,null))[_0x0da2('0x25')](handleError(_0x26dd55,null));};exports[_0x0da2('0x67')]=function(_0x382a95,_0x169f2b,_0x2e61b6){var _0x49524f;return db['Network'][_0x0da2('0x68')]({'where':{'id':_0x382a95[_0x0da2('0x4c')]['id']}})['then'](function(_0x1a7308){_0x49524f=_0x1a7308;return _0x1a7308;})[_0x0da2('0x1c')](handleEntityNotFound(_0x169f2b,null))[_0x0da2('0x1c')](removeEntity(_0x169f2b,null))[_0x0da2('0x1c')](function(){if(_0x49524f){return db[_0x0da2('0x35')][_0x0da2('0x52')]({'where':{'type':_0x49524f[_0x0da2('0x37')]},'raw':!![]});}})[_0x0da2('0x1c')](function(_0x4fb21e){if(_0x49524f[_0x0da2('0x37')][_0x0da2('0x5e')]()==_0x0da2('0x53')){var _0x33c191=fs[_0x0da2('0x54')](path[_0x0da2('0x55')](config[_0x0da2('0x56')],_0x0da2('0x57')),_0x0da2('0x58'));var _0x5cb3a8=ejs['render'](_0x33c191,{'networks':_0x4fb21e||[]});fs[_0x0da2('0x5a')]('/etc/asterisk/stun_xcally.conf',_0x5cb3a8);return respondWithRpcPromise('Reload',_0x0da2('0x67'),{'module':_0x0da2('0x5d')});}else if(_0x49524f[_0x0da2('0x37')][_0x0da2('0x5e')]()==_0x0da2('0x69')){var _0xb9a70b=fs[_0x0da2('0x54')](path[_0x0da2('0x55')](config[_0x0da2('0x56')],'server/files/templates/turn_multiple.ejs'),_0x0da2('0x58'));var _0x466258=ejs[_0x0da2('0x59')](_0xb9a70b,{'networks':_0x4fb21e||[]});fs['writeFileSync'](_0x0da2('0x65'),_0x466258);return respondWithRpcPromise(_0x0da2('0x5c'),_0x0da2('0x67'),{'module':_0x0da2('0x5d')});}else{var _0x3fa6a0=fs[_0x0da2('0x54')](path[_0x0da2('0x55')](config[_0x0da2('0x56')],_0x0da2('0x60')),_0x0da2('0x58'));var _0x15ac52=ejs['render'](_0x3fa6a0,{'networks':_0x4fb21e||[]});fs[_0x0da2('0x5a')](util[_0x0da2('0x61')]('/etc/asterisk/sip_xcally_%s.conf',_0x382a95[_0x0da2('0x51')]['type'][_0x0da2('0x63')]()),_0x15ac52);return respondWithRpcPromise(_0x0da2('0x5c'),_0x0da2('0x67'),{'module':_0x0da2('0x66')});}return null;})[_0x0da2('0x25')](handleError(_0x169f2b,null));};
\ No newline at end of file
+var _0x8eee=['status','set','Content-Range','update','destroy','sendStatus','stack','name','send','map','Network','rawAttributes','fieldName','type','key','model','query','keys','intersection','attributes','fields','hasOwnProperty','nolimit','order','sort','filters','filter','where','merge','includeAll','findAll','params','length','find','create','body','toUpperCase','STUN','readFileSync','join','root','server/files/templates/stun_multiple.ejs','utf8','render','/etc/asterisk/stun_xcally.conf','Reload','TURN','server/files/templates/turn_multiple.ejs','writeFileSync','/etc/asterisk/turn_xcally.conf','res_stun_monitor.so','/etc/asterisk/sip_xcally_%s.conf','toLowerCase','chan_sip.so','server/files/templates/network.ejs','format','util','path','ejs','lodash','../../components/parsers/qs','../../config/logger','api','../../config/environment','jayson/promise','client','http','request','then','info','Network,\x20%s,\x20%s','request\x20sent','Network,\x20%s,\x20%s,\x20%s','stringify','error','message','result','catch','json','offset','undefined','count','limit'];(function(_0x55dc51,_0x5dcc6b){var _0x113feb=function(_0x4be8ef){while(--_0x4be8ef){_0x55dc51['push'](_0x55dc51['shift']());}};_0x113feb(++_0x5dcc6b);}(_0x8eee,0x1d7));var _0xe8ee=function(_0x36909d,_0x2795f1){_0x36909d=_0x36909d-0x0;var _0x1fd29d=_0x8eee[_0x36909d];return _0x1fd29d;};'use strict';var util=require(_0xe8ee('0x0'));var path=require(_0xe8ee('0x1'));var ejs=require(_0xe8ee('0x2'));var fs=require('fs');var _=require(_0xe8ee('0x3'));var qs=require(_0xe8ee('0x4'));var logger=require(_0xe8ee('0x5'))(_0xe8ee('0x6'));var config=require(_0xe8ee('0x7'));var db=require('../../mysqldb')['db'];var jayson=require(_0xe8ee('0x8'));var client=jayson[_0xe8ee('0x9')][_0xe8ee('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x3a950f,_0x12fca7,_0x37acec,_0x116c8e){return new Promise(function(_0x4a073d,_0x4dcd76){var _0x2c8352=_0x116c8e||client;return _0x2c8352[_0xe8ee('0xb')](_0x3a950f,_0x37acec)[_0xe8ee('0xc')](function(_0x5951d7){logger[_0xe8ee('0xd')](_0xe8ee('0xe'),_0x12fca7,_0xe8ee('0xf'));logger['debug'](_0xe8ee('0x10'),_0x12fca7,_0xe8ee('0xf'),JSON[_0xe8ee('0x11')](_0x5951d7));if(_0x5951d7[_0xe8ee('0x12')]){if(_0x5951d7[_0xe8ee('0x12')]['code']===0x1f4){logger[_0xe8ee('0x12')]('Network,\x20%s,\x20%s',_0x12fca7,_0x5951d7[_0xe8ee('0x12')][_0xe8ee('0x13')]);return _0x4dcd76(_0x5951d7['error'][_0xe8ee('0x13')]);}logger[_0xe8ee('0x12')](_0xe8ee('0xe'),_0x12fca7,_0x5951d7[_0xe8ee('0x12')]['message']);return _0x4a073d(_0x5951d7[_0xe8ee('0x12')][_0xe8ee('0x13')]);}else{logger[_0xe8ee('0xd')](_0xe8ee('0xe'),_0x12fca7,'request\x20sent');_0x4a073d(_0x5951d7[_0xe8ee('0x14')][_0xe8ee('0x13')]);}})[_0xe8ee('0x15')](function(_0x42bea9){logger[_0xe8ee('0x12')](_0xe8ee('0xe'),_0x12fca7,_0x42bea9);_0x4dcd76(_0x42bea9);});});}function respondWithResult(_0x490664,_0x322374){_0x322374=_0x322374||0xc8;return function(_0x1f21de){if(_0x1f21de){return _0x490664['status'](_0x322374)[_0xe8ee('0x16')](_0x1f21de);}};}function respondWithFilteredResult(_0x122833,_0x13b5a2){return function(_0x2d2c26){if(_0x2d2c26){var _0x3fcff4=typeof _0x13b5a2[_0xe8ee('0x17')]==='undefined'&&typeof _0x13b5a2['limit']===_0xe8ee('0x18');var _0x1a5dbc=_0x2d2c26[_0xe8ee('0x19')];var _0x231dde=_0x3fcff4?0x0:_0x13b5a2[_0xe8ee('0x17')];var _0x485ee4=_0x3fcff4?_0x2d2c26[_0xe8ee('0x19')]:_0x13b5a2[_0xe8ee('0x17')]+_0x13b5a2[_0xe8ee('0x1a')];var _0x24864d;if(_0x485ee4>=_0x1a5dbc){_0x485ee4=_0x1a5dbc;_0x24864d=0xc8;}else{_0x24864d=0xce;}_0x122833[_0xe8ee('0x1b')](_0x24864d);return _0x122833[_0xe8ee('0x1c')](_0xe8ee('0x1d'),_0x231dde+'-'+_0x485ee4+'/'+_0x1a5dbc)['json'](_0x2d2c26);}return null;};}function saveUpdates(_0x45abdf){return function(_0x3c87ad){if(_0x3c87ad){return _0x3c87ad[_0xe8ee('0x1e')](_0x45abdf)['then'](function(_0x454760){return _0x454760;});}return null;};}function removeEntity(_0xe5697e){return function(_0xdf54f8){if(_0xdf54f8){return _0xdf54f8[_0xe8ee('0x1f')]()[_0xe8ee('0xc')](function(){_0xe5697e[_0xe8ee('0x1b')](0xcc)['end']();});}};}function handleEntityNotFound(_0x416832){return function(_0x1150ee){if(!_0x1150ee){_0x416832[_0xe8ee('0x20')](0x194);}return _0x1150ee;};}function handleError(_0x275025,_0x267240){_0x267240=_0x267240||0x1f4;return function(_0x4cfc9f){logger['error'](_0x4cfc9f[_0xe8ee('0x21')]);if(_0x4cfc9f[_0xe8ee('0x22')]){delete _0x4cfc9f[_0xe8ee('0x22')];}_0x275025[_0xe8ee('0x1b')](_0x267240)[_0xe8ee('0x23')](_0x4cfc9f);};}exports['index']=function(_0x111e5b,_0x1e1ab4){var _0x1048d0={},_0x1a46b1={},_0x34b5b6={'count':0x0,'rows':[]};var _0x4f2563=_[_0xe8ee('0x24')](db[_0xe8ee('0x25')][_0xe8ee('0x26')],function(_0x42ebd6){return{'name':_0x42ebd6[_0xe8ee('0x27')],'type':_0x42ebd6[_0xe8ee('0x28')][_0xe8ee('0x29')]};});_0x1a46b1[_0xe8ee('0x2a')]=_[_0xe8ee('0x24')](_0x4f2563,_0xe8ee('0x22'));_0x1a46b1[_0xe8ee('0x2b')]=_[_0xe8ee('0x2c')](_0x111e5b[_0xe8ee('0x2b')]);_0x1a46b1['filters']=_[_0xe8ee('0x2d')](_0x1a46b1[_0xe8ee('0x2a')],_0x1a46b1[_0xe8ee('0x2b')]);_0x1048d0[_0xe8ee('0x2e')]=_[_0xe8ee('0x2d')](_0x1a46b1[_0xe8ee('0x2a')],qs[_0xe8ee('0x2f')](_0x111e5b['query'][_0xe8ee('0x2f')]));_0x1048d0[_0xe8ee('0x2e')]=_0x1048d0['attributes']['length']?_0x1048d0[_0xe8ee('0x2e')]:_0x1a46b1[_0xe8ee('0x2a')];if(!_0x111e5b['query'][_0xe8ee('0x30')](_0xe8ee('0x31'))){_0x1048d0[_0xe8ee('0x1a')]=qs[_0xe8ee('0x1a')](_0x111e5b[_0xe8ee('0x2b')][_0xe8ee('0x1a')]);_0x1048d0[_0xe8ee('0x17')]=qs['offset'](_0x111e5b[_0xe8ee('0x2b')][_0xe8ee('0x17')]);}_0x1048d0[_0xe8ee('0x32')]=qs[_0xe8ee('0x33')](_0x111e5b[_0xe8ee('0x2b')][_0xe8ee('0x33')]);_0x1048d0['where']=qs['filters'](_['pick'](_0x111e5b[_0xe8ee('0x2b')],_0x1a46b1[_0xe8ee('0x34')]),_0x4f2563);if(_0x111e5b[_0xe8ee('0x2b')][_0xe8ee('0x35')]){_0x1048d0[_0xe8ee('0x36')]=_['merge'](_0x1048d0['where'],{'$or':_['map'](_0x4f2563,function(_0x195c78){if(_0x195c78['type']!=='VIRTUAL'){var _0x147406={};_0x147406[_0x195c78[_0xe8ee('0x22')]]={'$like':'%'+_0x111e5b['query'][_0xe8ee('0x35')]+'%'};return _0x147406;}})});}_0x1048d0=_[_0xe8ee('0x37')]({},_0x1048d0,_0x111e5b['options']);var _0x48686c={'where':_0x1048d0[_0xe8ee('0x36')]};return db[_0xe8ee('0x25')][_0xe8ee('0x19')](_0x48686c)[_0xe8ee('0xc')](function(_0xe37a6d){_0x34b5b6[_0xe8ee('0x19')]=_0xe37a6d;if(_0x111e5b['query'][_0xe8ee('0x38')]){_0x1048d0['include']=[{'all':!![]}];}return db[_0xe8ee('0x25')][_0xe8ee('0x39')](_0x1048d0);})[_0xe8ee('0xc')](function(_0x187433){_0x34b5b6['rows']=_0x187433;return _0x34b5b6;})[_0xe8ee('0xc')](respondWithFilteredResult(_0x1e1ab4,_0x1048d0))[_0xe8ee('0x15')](handleError(_0x1e1ab4,null));};exports['show']=function(_0xea4bc9,_0x371edf){var _0x1d6e1e={'raw':!![],'where':{'id':_0xea4bc9[_0xe8ee('0x3a')]['id']}},_0x23d7f2={};_0x23d7f2[_0xe8ee('0x2a')]=_[_0xe8ee('0x2c')](db[_0xe8ee('0x25')]['rawAttributes']);_0x23d7f2[_0xe8ee('0x2b')]=_[_0xe8ee('0x2c')](_0xea4bc9[_0xe8ee('0x2b')]);_0x23d7f2[_0xe8ee('0x34')]=_['intersection'](_0x23d7f2[_0xe8ee('0x2a')],_0x23d7f2[_0xe8ee('0x2b')]);_0x1d6e1e['attributes']=_[_0xe8ee('0x2d')](_0x23d7f2[_0xe8ee('0x2a')],qs[_0xe8ee('0x2f')](_0xea4bc9['query'][_0xe8ee('0x2f')]));_0x1d6e1e[_0xe8ee('0x2e')]=_0x1d6e1e[_0xe8ee('0x2e')][_0xe8ee('0x3b')]?_0x1d6e1e[_0xe8ee('0x2e')]:_0x23d7f2[_0xe8ee('0x2a')];if(_0xea4bc9[_0xe8ee('0x2b')][_0xe8ee('0x38')]){_0x1d6e1e['include']=[{'all':!![]}];}_0x1d6e1e=_[_0xe8ee('0x37')]({},_0x1d6e1e,_0xea4bc9['options']);return db[_0xe8ee('0x25')][_0xe8ee('0x3c')](_0x1d6e1e)[_0xe8ee('0xc')](handleEntityNotFound(_0x371edf,null))['then'](respondWithResult(_0x371edf,null))[_0xe8ee('0x15')](handleError(_0x371edf,null));};exports[_0xe8ee('0x3d')]=function(_0x233ccc,_0x310416){var _0x2b57ea;return db[_0xe8ee('0x25')][_0xe8ee('0x3d')](_0x233ccc[_0xe8ee('0x3e')],{'raw':!![]})['then'](function(_0x4eb553){_0x2b57ea=_0x4eb553;return db['Network'][_0xe8ee('0x39')]({'where':{'type':_0x233ccc[_0xe8ee('0x3e')][_0xe8ee('0x28')]},'raw':!![]});})[_0xe8ee('0xc')](function(_0x9a56f5){if(_0x2b57ea['type'][_0xe8ee('0x3f')]()==_0xe8ee('0x40')){var _0x270fb4=fs[_0xe8ee('0x41')](path[_0xe8ee('0x42')](config[_0xe8ee('0x43')],_0xe8ee('0x44')),_0xe8ee('0x45'));var _0x52acf0=ejs[_0xe8ee('0x46')](_0x270fb4,{'networks':_0x9a56f5||[]});fs['writeFileSync'](_0xe8ee('0x47'),_0x52acf0);return respondWithRpcPromise(_0xe8ee('0x48'),_0xe8ee('0x3d'),{'module':'res_stun_monitor.so'});}else if(_0x2b57ea[_0xe8ee('0x28')][_0xe8ee('0x3f')]()==_0xe8ee('0x49')){var _0x5830e0=fs['readFileSync'](path[_0xe8ee('0x42')](config[_0xe8ee('0x43')],_0xe8ee('0x4a')),'utf8');var _0x18c6a1=ejs[_0xe8ee('0x46')](_0x5830e0,{'networks':_0x9a56f5||[]});fs[_0xe8ee('0x4b')](_0xe8ee('0x4c'),_0x18c6a1);return respondWithRpcPromise('Reload',_0xe8ee('0x3d'),{'module':_0xe8ee('0x4d')});}else{var _0xd9fab8=fs[_0xe8ee('0x41')](path[_0xe8ee('0x42')](config[_0xe8ee('0x43')],'server/files/templates/network.ejs'),_0xe8ee('0x45'));var _0x2d10ac=ejs['render'](_0xd9fab8,{'networks':_0x9a56f5||[]});fs[_0xe8ee('0x4b')](util['format'](_0xe8ee('0x4e'),_0x233ccc[_0xe8ee('0x3e')][_0xe8ee('0x28')][_0xe8ee('0x4f')]()),_0x2d10ac);return respondWithRpcPromise(_0xe8ee('0x48'),_0xe8ee('0x3d'),{'module':_0xe8ee('0x50')});}})[_0xe8ee('0xc')](function(){return _0x2b57ea;})[_0xe8ee('0xc')](respondWithResult(_0x310416,0xc9))[_0xe8ee('0x15')](handleError(_0x310416,null));};exports[_0xe8ee('0x1e')]=function(_0x2ea0b5,_0x3dabf2){var _0x53b896;return db[_0xe8ee('0x25')]['find']({'where':{'id':_0x2ea0b5[_0xe8ee('0x3a')]['id']}})[_0xe8ee('0xc')](handleEntityNotFound(_0x3dabf2,null))[_0xe8ee('0xc')](saveUpdates(_0x2ea0b5[_0xe8ee('0x3e')],null))[_0xe8ee('0xc')](function(_0x2e2807){if(_0x2e2807){_0x53b896=_0x2e2807;return db['Network'][_0xe8ee('0x39')]({'where':{'type':_0x53b896[_0xe8ee('0x28')]},'raw':!![]});}return null;})[_0xe8ee('0xc')](function(_0x3e011d){if(_0x53b896[_0xe8ee('0x28')][_0xe8ee('0x3f')]()==_0xe8ee('0x40')){var _0x4ebeb4=fs[_0xe8ee('0x41')](path[_0xe8ee('0x42')](config[_0xe8ee('0x43')],'server/files/templates/stun_multiple.ejs'),'utf8');var _0x3f6f78=ejs[_0xe8ee('0x46')](_0x4ebeb4,{'networks':_0x3e011d||[]});fs[_0xe8ee('0x4b')](_0xe8ee('0x47'),_0x3f6f78);return respondWithRpcPromise(_0xe8ee('0x48'),_0xe8ee('0x1e'),{'module':_0xe8ee('0x4d')});}else if(_0x53b896[_0xe8ee('0x28')][_0xe8ee('0x3f')]()==_0xe8ee('0x49')){var _0x528847=fs[_0xe8ee('0x41')](path['join'](config[_0xe8ee('0x43')],_0xe8ee('0x4a')),_0xe8ee('0x45'));var _0x54700f=ejs[_0xe8ee('0x46')](_0x528847,{'networks':_0x3e011d||[]});fs[_0xe8ee('0x4b')]('/etc/asterisk/turn_xcally.conf',_0x54700f);return respondWithRpcPromise(_0xe8ee('0x48'),_0xe8ee('0x1e'),{'module':_0xe8ee('0x4d')});}else{var _0x223a9a=fs[_0xe8ee('0x41')](path[_0xe8ee('0x42')](config[_0xe8ee('0x43')],_0xe8ee('0x51')),_0xe8ee('0x45'));var _0xf0c361=ejs[_0xe8ee('0x46')](_0x223a9a,{'networks':_0x3e011d||[]});fs['writeFileSync'](util[_0xe8ee('0x52')](_0xe8ee('0x4e'),_0x2ea0b5[_0xe8ee('0x3e')][_0xe8ee('0x28')][_0xe8ee('0x4f')]()),_0xf0c361);return respondWithRpcPromise(_0xe8ee('0x48'),_0xe8ee('0x1e'),{'module':'chan_sip.so'});}})[_0xe8ee('0xc')](function(_0x573cb3){if(_0x573cb3){return _0x53b896;}return null;})[_0xe8ee('0xc')](respondWithResult(_0x3dabf2,null))['catch'](handleError(_0x3dabf2,null));};exports[_0xe8ee('0x1f')]=function(_0x59fe37,_0x1000ff){var _0x8e2892;return db[_0xe8ee('0x25')][_0xe8ee('0x3c')]({'where':{'id':_0x59fe37['params']['id']}})['then'](function(_0x3bc256){_0x8e2892=_0x3bc256;return _0x3bc256;})[_0xe8ee('0xc')](handleEntityNotFound(_0x1000ff,null))[_0xe8ee('0xc')](removeEntity(_0x1000ff,null))['then'](function(){if(_0x8e2892){return db[_0xe8ee('0x25')]['findAll']({'where':{'type':_0x8e2892['type']},'raw':!![]});}})[_0xe8ee('0xc')](function(_0x1539e2){if(_0x8e2892[_0xe8ee('0x28')][_0xe8ee('0x3f')]()==_0xe8ee('0x40')){var _0x57691a=fs[_0xe8ee('0x41')](path[_0xe8ee('0x42')](config['root'],_0xe8ee('0x44')),_0xe8ee('0x45'));var _0x554535=ejs[_0xe8ee('0x46')](_0x57691a,{'networks':_0x1539e2||[]});fs['writeFileSync'](_0xe8ee('0x47'),_0x554535);return respondWithRpcPromise(_0xe8ee('0x48'),'destroy',{'module':'res_stun_monitor.so'});}else if(_0x8e2892[_0xe8ee('0x28')]['toUpperCase']()==_0xe8ee('0x49')){var _0x53d2b7=fs[_0xe8ee('0x41')](path[_0xe8ee('0x42')](config[_0xe8ee('0x43')],_0xe8ee('0x4a')),_0xe8ee('0x45'));var _0x5768ec=ejs['render'](_0x53d2b7,{'networks':_0x1539e2||[]});fs[_0xe8ee('0x4b')](_0xe8ee('0x4c'),_0x5768ec);return respondWithRpcPromise('Reload',_0xe8ee('0x1f'),{'module':_0xe8ee('0x4d')});}else{var _0x55626c=fs[_0xe8ee('0x41')](path['join'](config[_0xe8ee('0x43')],_0xe8ee('0x51')),'utf8');var _0x49734a=ejs['render'](_0x55626c,{'networks':_0x1539e2||[]});fs[_0xe8ee('0x4b')](util[_0xe8ee('0x52')](_0xe8ee('0x4e'),_0x8e2892[_0xe8ee('0x28')][_0xe8ee('0x4f')]()),_0x49734a);return respondWithRpcPromise(_0xe8ee('0x48'),_0xe8ee('0x1f'),{'module':_0xe8ee('0x50')});}})[_0xe8ee('0x15')](handleError(_0x1000ff,null));};
\ No newline at end of file