Built motion from commit ecb45b58.|2.6.31
[motion2.git] / server / api / network / network.controller.js
index b3f2708..8de074c 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x81f6=['then','info','request\x20sent','debug','Network,\x20%s,\x20%s,\x20%s','stringify','error','code','message','Network,\x20%s,\x20%s','result','catch','status','json','undefined','limit','count','offset','set','Content-Range','update','destroy','end','sendStatus','stack','name','index','Network','rawAttributes','type','key','model','keys','query','attributes','fields','length','hasOwnProperty','nolimit','order','sort','filters','pick','filter','where','merge','map','VIRTUAL','options','includeAll','include','show','params','intersection','find','create','body','findAll','STUN','readFileSync','root','server/files/templates/stun_multiple.ejs','utf8','render','writeFileSync','Reload','res_stun_monitor.so','toUpperCase','TURN','join','server/files/templates/turn_multiple.ejs','/etc/asterisk/turn_xcally.conf','server/files/templates/network.ejs','format','toLowerCase','chan_sip.so','/etc/asterisk/sip_xcally_%s.conf','/etc/asterisk/stun_xcally.conf','path','ejs','lodash','../../config/logger','../../config/environment','http','request'];(function(_0x75a1f,_0x39d58c){var _0x43add9=function(_0x594a1c){while(--_0x594a1c){_0x75a1f['push'](_0x75a1f['shift']());}};_0x43add9(++_0x39d58c);}(_0x81f6,0x14d));var _0x681f=function(_0x291d2e,_0x5d43e3){_0x291d2e=_0x291d2e-0x0;var _0x53a151=_0x81f6[_0x291d2e];return _0x53a151;};'use strict';var util=require('util');var path=require(_0x681f('0x0'));var ejs=require(_0x681f('0x1'));var fs=require('fs');var _=require(_0x681f('0x2'));var qs=require('../../components/parsers/qs');var logger=require(_0x681f('0x3'))('api');var config=require(_0x681f('0x4'));var db=require('../../mysqldb')['db'];var jayson=require('jayson/promise');var client=jayson['client'][_0x681f('0x5')]({'port':0x232a});function respondWithRpcPromise(_0x92e6af,_0x22c092,_0xe9f202,_0x4899c3){return new Promise(function(_0x2c0344,_0x27613b){var _0x51450b=_0x4899c3||client;return _0x51450b[_0x681f('0x6')](_0x92e6af,_0xe9f202)[_0x681f('0x7')](function(_0x46b096){logger[_0x681f('0x8')]('Network,\x20%s,\x20%s',_0x22c092,_0x681f('0x9'));logger[_0x681f('0xa')](_0x681f('0xb'),_0x22c092,_0x681f('0x9'),JSON[_0x681f('0xc')](_0x46b096));if(_0x46b096[_0x681f('0xd')]){if(_0x46b096['error'][_0x681f('0xe')]===0x1f4){logger['error']('Network,\x20%s,\x20%s',_0x22c092,_0x46b096[_0x681f('0xd')][_0x681f('0xf')]);return _0x27613b(_0x46b096['error'][_0x681f('0xf')]);}logger[_0x681f('0xd')]('Network,\x20%s,\x20%s',_0x22c092,_0x46b096['error'][_0x681f('0xf')]);return _0x2c0344(_0x46b096[_0x681f('0xd')][_0x681f('0xf')]);}else{logger[_0x681f('0x8')](_0x681f('0x10'),_0x22c092,'request\x20sent');_0x2c0344(_0x46b096[_0x681f('0x11')][_0x681f('0xf')]);}})[_0x681f('0x12')](function(_0x6254b5){logger[_0x681f('0xd')](_0x681f('0x10'),_0x22c092,_0x6254b5);_0x27613b(_0x6254b5);});});}function respondWithResult(_0x1082dd,_0x18e347){_0x18e347=_0x18e347||0xc8;return function(_0x2f3339){if(_0x2f3339){return _0x1082dd[_0x681f('0x13')](_0x18e347)[_0x681f('0x14')](_0x2f3339);}};}function respondWithFilteredResult(_0x3101e0,_0x225564){return function(_0x1f0604){if(_0x1f0604){var _0x4133ca=typeof _0x225564['offset']===_0x681f('0x15')&&typeof _0x225564[_0x681f('0x16')]===_0x681f('0x15');var _0x5cfd5c=_0x1f0604[_0x681f('0x17')];var _0x493d72=_0x4133ca?0x0:_0x225564[_0x681f('0x18')];var _0x372519=_0x4133ca?_0x1f0604['count']:_0x225564[_0x681f('0x18')]+_0x225564[_0x681f('0x16')];var _0x21e9af;if(_0x372519>=_0x5cfd5c){_0x372519=_0x5cfd5c;_0x21e9af=0xc8;}else{_0x21e9af=0xce;}_0x3101e0['status'](_0x21e9af);return _0x3101e0[_0x681f('0x19')](_0x681f('0x1a'),_0x493d72+'-'+_0x372519+'/'+_0x5cfd5c)[_0x681f('0x14')](_0x1f0604);}return null;};}function saveUpdates(_0x4331b0){return function(_0x6a7771){if(_0x6a7771){return _0x6a7771[_0x681f('0x1b')](_0x4331b0)[_0x681f('0x7')](function(_0x1b3140){return _0x1b3140;});}return null;};}function removeEntity(_0x1dc512){return function(_0x5c4d8c){if(_0x5c4d8c){return _0x5c4d8c[_0x681f('0x1c')]()[_0x681f('0x7')](function(){_0x1dc512[_0x681f('0x13')](0xcc)[_0x681f('0x1d')]();});}};}function handleEntityNotFound(_0x477957){return function(_0x9e87f9){if(!_0x9e87f9){_0x477957[_0x681f('0x1e')](0x194);}return _0x9e87f9;};}function handleError(_0x2f7508,_0x57ad27){_0x57ad27=_0x57ad27||0x1f4;return function(_0x1089c1){logger[_0x681f('0xd')](_0x1089c1[_0x681f('0x1f')]);if(_0x1089c1[_0x681f('0x20')]){delete _0x1089c1['name'];}_0x2f7508[_0x681f('0x13')](_0x57ad27)['send'](_0x1089c1);};}exports[_0x681f('0x21')]=function(_0x466a0f,_0x1118f9){var _0x478d7b={},_0x44e9eb={},_0x2ed9bc={'count':0x0,'rows':[]};var _0x4f620b=_['map'](db[_0x681f('0x22')][_0x681f('0x23')],function(_0x28ddcb){return{'name':_0x28ddcb['fieldName'],'type':_0x28ddcb[_0x681f('0x24')][_0x681f('0x25')]};});_0x44e9eb[_0x681f('0x26')]=_['map'](_0x4f620b,'name');_0x44e9eb['query']=_[_0x681f('0x27')](_0x466a0f[_0x681f('0x28')]);_0x44e9eb['filters']=_['intersection'](_0x44e9eb['model'],_0x44e9eb[_0x681f('0x28')]);_0x478d7b[_0x681f('0x29')]=_['intersection'](_0x44e9eb[_0x681f('0x26')],qs[_0x681f('0x2a')](_0x466a0f[_0x681f('0x28')]['fields']));_0x478d7b[_0x681f('0x29')]=_0x478d7b[_0x681f('0x29')][_0x681f('0x2b')]?_0x478d7b[_0x681f('0x29')]:_0x44e9eb['model'];if(!_0x466a0f[_0x681f('0x28')][_0x681f('0x2c')](_0x681f('0x2d'))){_0x478d7b[_0x681f('0x16')]=qs['limit'](_0x466a0f[_0x681f('0x28')][_0x681f('0x16')]);_0x478d7b[_0x681f('0x18')]=qs[_0x681f('0x18')](_0x466a0f['query'][_0x681f('0x18')]);}_0x478d7b[_0x681f('0x2e')]=qs[_0x681f('0x2f')](_0x466a0f[_0x681f('0x28')][_0x681f('0x2f')]);_0x478d7b['where']=qs[_0x681f('0x30')](_[_0x681f('0x31')](_0x466a0f[_0x681f('0x28')],_0x44e9eb[_0x681f('0x30')]),_0x4f620b);if(_0x466a0f[_0x681f('0x28')][_0x681f('0x32')]){_0x478d7b[_0x681f('0x33')]=_[_0x681f('0x34')](_0x478d7b[_0x681f('0x33')],{'$or':_[_0x681f('0x35')](_0x4f620b,function(_0x505438){if(_0x505438[_0x681f('0x24')]!==_0x681f('0x36')){var _0x17e697={};_0x17e697[_0x505438['name']]={'$like':'%'+_0x466a0f[_0x681f('0x28')][_0x681f('0x32')]+'%'};return _0x17e697;}})});}_0x478d7b=_[_0x681f('0x34')]({},_0x478d7b,_0x466a0f[_0x681f('0x37')]);var _0x12c028={'where':_0x478d7b[_0x681f('0x33')]};return db[_0x681f('0x22')][_0x681f('0x17')](_0x12c028)['then'](function(_0x5a6afc){_0x2ed9bc[_0x681f('0x17')]=_0x5a6afc;if(_0x466a0f[_0x681f('0x28')][_0x681f('0x38')]){_0x478d7b[_0x681f('0x39')]=[{'all':!![]}];}return db[_0x681f('0x22')]['findAll'](_0x478d7b);})[_0x681f('0x7')](function(_0x37fd24){_0x2ed9bc['rows']=_0x37fd24;return _0x2ed9bc;})[_0x681f('0x7')](respondWithFilteredResult(_0x1118f9,_0x478d7b))[_0x681f('0x12')](handleError(_0x1118f9,null));};exports[_0x681f('0x3a')]=function(_0x2a7450,_0x4e3724){var _0x303332={'raw':!![],'where':{'id':_0x2a7450[_0x681f('0x3b')]['id']}},_0x52e5d0={};_0x52e5d0[_0x681f('0x26')]=_[_0x681f('0x27')](db[_0x681f('0x22')][_0x681f('0x23')]);_0x52e5d0[_0x681f('0x28')]=_[_0x681f('0x27')](_0x2a7450['query']);_0x52e5d0[_0x681f('0x30')]=_['intersection'](_0x52e5d0['model'],_0x52e5d0[_0x681f('0x28')]);_0x303332['attributes']=_[_0x681f('0x3c')](_0x52e5d0[_0x681f('0x26')],qs[_0x681f('0x2a')](_0x2a7450['query'][_0x681f('0x2a')]));_0x303332[_0x681f('0x29')]=_0x303332[_0x681f('0x29')][_0x681f('0x2b')]?_0x303332['attributes']:_0x52e5d0[_0x681f('0x26')];if(_0x2a7450['query'][_0x681f('0x38')]){_0x303332[_0x681f('0x39')]=[{'all':!![]}];}_0x303332=_[_0x681f('0x34')]({},_0x303332,_0x2a7450['options']);return db[_0x681f('0x22')][_0x681f('0x3d')](_0x303332)[_0x681f('0x7')](handleEntityNotFound(_0x4e3724,null))[_0x681f('0x7')](respondWithResult(_0x4e3724,null))[_0x681f('0x12')](handleError(_0x4e3724,null));};exports[_0x681f('0x3e')]=function(_0x562511,_0x4d918e){var _0x672c12;return db['Network'][_0x681f('0x3e')](_0x562511[_0x681f('0x3f')],{'raw':!![]})[_0x681f('0x7')](function(_0x289ef4){_0x672c12=_0x289ef4;return db['Network'][_0x681f('0x40')]({'where':{'type':_0x562511[_0x681f('0x3f')][_0x681f('0x24')]},'raw':!![]});})[_0x681f('0x7')](function(_0x5b5430){if(_0x672c12[_0x681f('0x24')]['toUpperCase']()==_0x681f('0x41')){var _0x4c1537=fs[_0x681f('0x42')](path['join'](config[_0x681f('0x43')],_0x681f('0x44')),_0x681f('0x45'));var _0x1941e0=ejs[_0x681f('0x46')](_0x4c1537,{'networks':_0x5b5430||[]});fs[_0x681f('0x47')]('/etc/asterisk/stun_xcally.conf',_0x1941e0);return respondWithRpcPromise(_0x681f('0x48'),_0x681f('0x3e'),{'module':_0x681f('0x49')});}else if(_0x672c12['type'][_0x681f('0x4a')]()==_0x681f('0x4b')){var _0x1c25e6=fs[_0x681f('0x42')](path[_0x681f('0x4c')](config['root'],_0x681f('0x4d')),_0x681f('0x45'));var _0x169707=ejs[_0x681f('0x46')](_0x1c25e6,{'networks':_0x5b5430||[]});fs[_0x681f('0x47')](_0x681f('0x4e'),_0x169707);return respondWithRpcPromise(_0x681f('0x48'),_0x681f('0x3e'),{'module':_0x681f('0x49')});}else{var _0x2c07ae=fs[_0x681f('0x42')](path[_0x681f('0x4c')](config[_0x681f('0x43')],_0x681f('0x4f')),'utf8');var _0x4cc326=ejs[_0x681f('0x46')](_0x2c07ae,{'networks':_0x5b5430||[]});fs[_0x681f('0x47')](util[_0x681f('0x50')]('/etc/asterisk/sip_xcally_%s.conf',_0x562511['body'][_0x681f('0x24')][_0x681f('0x51')]()),_0x4cc326);return respondWithRpcPromise(_0x681f('0x48'),_0x681f('0x3e'),{'module':_0x681f('0x52')});}})[_0x681f('0x7')](function(){return _0x672c12;})[_0x681f('0x7')](respondWithResult(_0x4d918e,0xc9))[_0x681f('0x12')](handleError(_0x4d918e,null));};exports[_0x681f('0x1b')]=function(_0x23c2a4,_0x437627){var _0x3c777b;return db['Network'][_0x681f('0x3d')]({'where':{'id':_0x23c2a4[_0x681f('0x3b')]['id']}})[_0x681f('0x7')](handleEntityNotFound(_0x437627,null))[_0x681f('0x7')](saveUpdates(_0x23c2a4[_0x681f('0x3f')],null))['then'](function(_0x1e15de){if(_0x1e15de){_0x3c777b=_0x1e15de;return db['Network'][_0x681f('0x40')]({'where':{'type':_0x3c777b[_0x681f('0x24')]},'raw':!![]});}return null;})[_0x681f('0x7')](function(_0x1be4b5){if(_0x3c777b[_0x681f('0x24')][_0x681f('0x4a')]()==_0x681f('0x41')){var _0x2582e4=fs[_0x681f('0x42')](path[_0x681f('0x4c')](config[_0x681f('0x43')],_0x681f('0x44')),_0x681f('0x45'));var _0x48ebda=ejs[_0x681f('0x46')](_0x2582e4,{'networks':_0x1be4b5||[]});fs[_0x681f('0x47')]('/etc/asterisk/stun_xcally.conf',_0x48ebda);return respondWithRpcPromise(_0x681f('0x48'),_0x681f('0x1b'),{'module':_0x681f('0x49')});}else if(_0x3c777b[_0x681f('0x24')]['toUpperCase']()==_0x681f('0x4b')){var _0x110abb=fs[_0x681f('0x42')](path[_0x681f('0x4c')](config[_0x681f('0x43')],'server/files/templates/turn_multiple.ejs'),_0x681f('0x45'));var _0x3ae735=ejs[_0x681f('0x46')](_0x110abb,{'networks':_0x1be4b5||[]});fs[_0x681f('0x47')]('/etc/asterisk/turn_xcally.conf',_0x3ae735);return respondWithRpcPromise(_0x681f('0x48'),'update',{'module':_0x681f('0x49')});}else{var _0x493c72=fs[_0x681f('0x42')](path[_0x681f('0x4c')](config[_0x681f('0x43')],'server/files/templates/network.ejs'),_0x681f('0x45'));var _0x4d4dc2=ejs['render'](_0x493c72,{'networks':_0x1be4b5||[]});fs['writeFileSync'](util[_0x681f('0x50')](_0x681f('0x53'),_0x23c2a4[_0x681f('0x3f')]['type'][_0x681f('0x51')]()),_0x4d4dc2);return respondWithRpcPromise(_0x681f('0x48'),_0x681f('0x1b'),{'module':_0x681f('0x52')});}})[_0x681f('0x7')](function(_0x398d9b){if(_0x398d9b){return _0x3c777b;}return null;})[_0x681f('0x7')](respondWithResult(_0x437627,null))[_0x681f('0x12')](handleError(_0x437627,null));};exports['destroy']=function(_0xf5b7f6,_0x1c3088){var _0x48e37e;return db['Network']['find']({'where':{'id':_0xf5b7f6[_0x681f('0x3b')]['id']}})[_0x681f('0x7')](function(_0x42d5ec){_0x48e37e=_0x42d5ec;return _0x42d5ec;})[_0x681f('0x7')](handleEntityNotFound(_0x1c3088,null))[_0x681f('0x7')](removeEntity(_0x1c3088,null))[_0x681f('0x7')](function(){if(_0x48e37e){return db[_0x681f('0x22')][_0x681f('0x40')]({'where':{'type':_0x48e37e['type']},'raw':!![]});}})[_0x681f('0x7')](function(_0x1c0d0d){if(_0x48e37e[_0x681f('0x24')]['toUpperCase']()==_0x681f('0x41')){var _0x173085=fs[_0x681f('0x42')](path[_0x681f('0x4c')](config[_0x681f('0x43')],_0x681f('0x44')),_0x681f('0x45'));var _0x22f0f=ejs['render'](_0x173085,{'networks':_0x1c0d0d||[]});fs[_0x681f('0x47')](_0x681f('0x54'),_0x22f0f);return respondWithRpcPromise(_0x681f('0x48'),_0x681f('0x1c'),{'module':'res_stun_monitor.so'});}else if(_0x48e37e['type'][_0x681f('0x4a')]()==_0x681f('0x4b')){var _0x1976ff=fs[_0x681f('0x42')](path[_0x681f('0x4c')](config[_0x681f('0x43')],'server/files/templates/turn_multiple.ejs'),_0x681f('0x45'));var _0x41e193=ejs['render'](_0x1976ff,{'networks':_0x1c0d0d||[]});fs['writeFileSync'](_0x681f('0x4e'),_0x41e193);return respondWithRpcPromise('Reload',_0x681f('0x1c'),{'module':_0x681f('0x49')});}else{var _0x54a29a=fs[_0x681f('0x42')](path[_0x681f('0x4c')](config['root'],_0x681f('0x4f')),_0x681f('0x45'));var _0x1b3247=ejs[_0x681f('0x46')](_0x54a29a,{'networks':_0x1c0d0d||[]});fs[_0x681f('0x47')](util[_0x681f('0x50')](_0x681f('0x53'),_0x48e37e[_0x681f('0x24')][_0x681f('0x51')]()),_0x1b3247);return respondWithRpcPromise(_0x681f('0x48'),_0x681f('0x1c'),{'module':'chan_sip.so'});}})[_0x681f('0x12')](handleError(_0x1c3088,null));};
\ No newline at end of file
+var _0x348f=['filters','intersection','model','attributes','length','hasOwnProperty','nolimit','limit','order','sort','where','pick','filter','merge','VIRTUAL','Network','includeAll','include','findAll','rows','catch','show','params','options','find','create','body','toUpperCase','STUN','readFileSync','join','utf8','render','writeFileSync','/etc/asterisk/stun_xcally.conf','res_stun_monitor.so','TURN','server/files/templates/turn_multiple.ejs','Reload','root','toLowerCase','chan_sip.so','server/files/templates/stun_multiple.ejs','/etc/asterisk/turn_xcally.conf','server/files/templates/network.ejs','format','util','path','ejs','lodash','../../components/parsers/qs','../../config/logger','api','../../config/environment','../../mysqldb','client','http','request','Network,\x20%s,\x20%s','request\x20sent','Network,\x20%s,\x20%s,\x20%s','stringify','error','code','message','info','result','status','json','offset','undefined','count','Content-Range','update','then','destroy','end','sendStatus','stack','name','index','map','rawAttributes','fieldName','type','key','query','keys'];(function(_0x4b2251,_0x393f10){var _0x5d22fb=function(_0x10992c){while(--_0x10992c){_0x4b2251['push'](_0x4b2251['shift']());}};_0x5d22fb(++_0x393f10);}(_0x348f,0x18e));var _0xf348=function(_0x1aa90e,_0x84a9a0){_0x1aa90e=_0x1aa90e-0x0;var _0x2a34cc=_0x348f[_0x1aa90e];return _0x2a34cc;};'use strict';var util=require(_0xf348('0x0'));var path=require(_0xf348('0x1'));var ejs=require(_0xf348('0x2'));var fs=require('fs');var _=require(_0xf348('0x3'));var qs=require(_0xf348('0x4'));var logger=require(_0xf348('0x5'))(_0xf348('0x6'));var config=require(_0xf348('0x7'));var db=require(_0xf348('0x8'))['db'];var jayson=require('jayson/promise');var client=jayson[_0xf348('0x9')][_0xf348('0xa')]({'port':0x232a});function respondWithRpcPromise(_0xaf58c2,_0x465b0c,_0x13e6ae,_0x3b5779){return new Promise(function(_0x3656f7,_0x4bba7f){var _0x38638a=_0x3b5779||client;return _0x38638a[_0xf348('0xb')](_0xaf58c2,_0x13e6ae)['then'](function(_0x4a69ce){logger['info'](_0xf348('0xc'),_0x465b0c,_0xf348('0xd'));logger['debug'](_0xf348('0xe'),_0x465b0c,'request\x20sent',JSON[_0xf348('0xf')](_0x4a69ce));if(_0x4a69ce[_0xf348('0x10')]){if(_0x4a69ce[_0xf348('0x10')][_0xf348('0x11')]===0x1f4){logger[_0xf348('0x10')](_0xf348('0xc'),_0x465b0c,_0x4a69ce[_0xf348('0x10')][_0xf348('0x12')]);return _0x4bba7f(_0x4a69ce[_0xf348('0x10')][_0xf348('0x12')]);}logger[_0xf348('0x10')]('Network,\x20%s,\x20%s',_0x465b0c,_0x4a69ce[_0xf348('0x10')][_0xf348('0x12')]);return _0x3656f7(_0x4a69ce[_0xf348('0x10')][_0xf348('0x12')]);}else{logger[_0xf348('0x13')](_0xf348('0xc'),_0x465b0c,_0xf348('0xd'));_0x3656f7(_0x4a69ce[_0xf348('0x14')][_0xf348('0x12')]);}})['catch'](function(_0x328b00){logger['error'](_0xf348('0xc'),_0x465b0c,_0x328b00);_0x4bba7f(_0x328b00);});});}function respondWithResult(_0x1c1432,_0x3b89fd){_0x3b89fd=_0x3b89fd||0xc8;return function(_0x1c47a4){if(_0x1c47a4){return _0x1c1432[_0xf348('0x15')](_0x3b89fd)[_0xf348('0x16')](_0x1c47a4);}};}function respondWithFilteredResult(_0x25d3f3,_0x2c2d15){return function(_0x2f7990){if(_0x2f7990){var _0x122bd3=typeof _0x2c2d15[_0xf348('0x17')]===_0xf348('0x18')&&typeof _0x2c2d15['limit']===_0xf348('0x18');var _0x339909=_0x2f7990[_0xf348('0x19')];var _0x2aa333=_0x122bd3?0x0:_0x2c2d15['offset'];var _0x420abc=_0x122bd3?_0x2f7990[_0xf348('0x19')]:_0x2c2d15[_0xf348('0x17')]+_0x2c2d15['limit'];var _0x5582dc;if(_0x420abc>=_0x339909){_0x420abc=_0x339909;_0x5582dc=0xc8;}else{_0x5582dc=0xce;}_0x25d3f3['status'](_0x5582dc);return _0x25d3f3['set'](_0xf348('0x1a'),_0x2aa333+'-'+_0x420abc+'/'+_0x339909)[_0xf348('0x16')](_0x2f7990);}return null;};}function saveUpdates(_0x479eda){return function(_0x2ada4d){if(_0x2ada4d){return _0x2ada4d[_0xf348('0x1b')](_0x479eda)[_0xf348('0x1c')](function(_0x155db9){return _0x155db9;});}return null;};}function removeEntity(_0x2a01d5){return function(_0x30226a){if(_0x30226a){return _0x30226a[_0xf348('0x1d')]()[_0xf348('0x1c')](function(){_0x2a01d5['status'](0xcc)[_0xf348('0x1e')]();});}};}function handleEntityNotFound(_0x176cf1){return function(_0x35db53){if(!_0x35db53){_0x176cf1[_0xf348('0x1f')](0x194);}return _0x35db53;};}function handleError(_0x39fd49,_0x5d3e61){_0x5d3e61=_0x5d3e61||0x1f4;return function(_0x530095){logger[_0xf348('0x10')](_0x530095[_0xf348('0x20')]);if(_0x530095[_0xf348('0x21')]){delete _0x530095[_0xf348('0x21')];}_0x39fd49['status'](_0x5d3e61)['send'](_0x530095);};}exports[_0xf348('0x22')]=function(_0x5a6270,_0xc0f3ef){var _0x31a627={},_0x1925d6={},_0x217159={'count':0x0,'rows':[]};var _0x37a5e3=_[_0xf348('0x23')](db['Network'][_0xf348('0x24')],function(_0x2d6767){return{'name':_0x2d6767[_0xf348('0x25')],'type':_0x2d6767[_0xf348('0x26')][_0xf348('0x27')]};});_0x1925d6['model']=_[_0xf348('0x23')](_0x37a5e3,_0xf348('0x21'));_0x1925d6[_0xf348('0x28')]=_[_0xf348('0x29')](_0x5a6270[_0xf348('0x28')]);_0x1925d6[_0xf348('0x2a')]=_[_0xf348('0x2b')](_0x1925d6['model'],_0x1925d6['query']);_0x31a627['attributes']=_[_0xf348('0x2b')](_0x1925d6[_0xf348('0x2c')],qs['fields'](_0x5a6270[_0xf348('0x28')]['fields']));_0x31a627[_0xf348('0x2d')]=_0x31a627['attributes'][_0xf348('0x2e')]?_0x31a627[_0xf348('0x2d')]:_0x1925d6[_0xf348('0x2c')];if(!_0x5a6270['query'][_0xf348('0x2f')](_0xf348('0x30'))){_0x31a627[_0xf348('0x31')]=qs[_0xf348('0x31')](_0x5a6270[_0xf348('0x28')][_0xf348('0x31')]);_0x31a627['offset']=qs[_0xf348('0x17')](_0x5a6270[_0xf348('0x28')][_0xf348('0x17')]);}_0x31a627[_0xf348('0x32')]=qs[_0xf348('0x33')](_0x5a6270[_0xf348('0x28')]['sort']);_0x31a627[_0xf348('0x34')]=qs['filters'](_[_0xf348('0x35')](_0x5a6270[_0xf348('0x28')],_0x1925d6[_0xf348('0x2a')]),_0x37a5e3);if(_0x5a6270['query'][_0xf348('0x36')]){_0x31a627[_0xf348('0x34')]=_[_0xf348('0x37')](_0x31a627[_0xf348('0x34')],{'$or':_['map'](_0x37a5e3,function(_0x341827){if(_0x341827['type']!==_0xf348('0x38')){var _0x2bce96={};_0x2bce96[_0x341827[_0xf348('0x21')]]={'$like':'%'+_0x5a6270[_0xf348('0x28')][_0xf348('0x36')]+'%'};return _0x2bce96;}})});}_0x31a627=_[_0xf348('0x37')]({},_0x31a627,_0x5a6270['options']);var _0x474b7b={'where':_0x31a627[_0xf348('0x34')]};return db[_0xf348('0x39')][_0xf348('0x19')](_0x474b7b)[_0xf348('0x1c')](function(_0x58cfab){_0x217159[_0xf348('0x19')]=_0x58cfab;if(_0x5a6270[_0xf348('0x28')][_0xf348('0x3a')]){_0x31a627[_0xf348('0x3b')]=[{'all':!![]}];}return db[_0xf348('0x39')][_0xf348('0x3c')](_0x31a627);})['then'](function(_0x4963c2){_0x217159[_0xf348('0x3d')]=_0x4963c2;return _0x217159;})[_0xf348('0x1c')](respondWithFilteredResult(_0xc0f3ef,_0x31a627))[_0xf348('0x3e')](handleError(_0xc0f3ef,null));};exports[_0xf348('0x3f')]=function(_0x4d9367,_0x39bc1f){var _0x442098={'raw':!![],'where':{'id':_0x4d9367[_0xf348('0x40')]['id']}},_0x4fb719={};_0x4fb719[_0xf348('0x2c')]=_[_0xf348('0x29')](db[_0xf348('0x39')][_0xf348('0x24')]);_0x4fb719[_0xf348('0x28')]=_[_0xf348('0x29')](_0x4d9367[_0xf348('0x28')]);_0x4fb719[_0xf348('0x2a')]=_[_0xf348('0x2b')](_0x4fb719[_0xf348('0x2c')],_0x4fb719[_0xf348('0x28')]);_0x442098[_0xf348('0x2d')]=_['intersection'](_0x4fb719[_0xf348('0x2c')],qs['fields'](_0x4d9367[_0xf348('0x28')]['fields']));_0x442098[_0xf348('0x2d')]=_0x442098[_0xf348('0x2d')][_0xf348('0x2e')]?_0x442098[_0xf348('0x2d')]:_0x4fb719[_0xf348('0x2c')];if(_0x4d9367[_0xf348('0x28')][_0xf348('0x3a')]){_0x442098[_0xf348('0x3b')]=[{'all':!![]}];}_0x442098=_[_0xf348('0x37')]({},_0x442098,_0x4d9367[_0xf348('0x41')]);return db[_0xf348('0x39')][_0xf348('0x42')](_0x442098)[_0xf348('0x1c')](handleEntityNotFound(_0x39bc1f,null))[_0xf348('0x1c')](respondWithResult(_0x39bc1f,null))[_0xf348('0x3e')](handleError(_0x39bc1f,null));};exports[_0xf348('0x43')]=function(_0x2959de,_0x153db0){var _0x521bdb;return db[_0xf348('0x39')][_0xf348('0x43')](_0x2959de['body'],{'raw':!![]})[_0xf348('0x1c')](function(_0x3be3c2){_0x521bdb=_0x3be3c2;return db[_0xf348('0x39')][_0xf348('0x3c')]({'where':{'type':_0x2959de[_0xf348('0x44')][_0xf348('0x26')]},'raw':!![]});})['then'](function(_0x53c756){if(_0x521bdb[_0xf348('0x26')][_0xf348('0x45')]()==_0xf348('0x46')){var _0x40a398=fs[_0xf348('0x47')](path[_0xf348('0x48')](config['root'],'server/files/templates/stun_multiple.ejs'),_0xf348('0x49'));var _0x5d092c=ejs[_0xf348('0x4a')](_0x40a398,{'networks':_0x53c756||[]});fs[_0xf348('0x4b')](_0xf348('0x4c'),_0x5d092c);return respondWithRpcPromise('Reload',_0xf348('0x43'),{'module':_0xf348('0x4d')});}else if(_0x521bdb[_0xf348('0x26')]['toUpperCase']()==_0xf348('0x4e')){var _0x25ffed=fs[_0xf348('0x47')](path[_0xf348('0x48')](config['root'],_0xf348('0x4f')),_0xf348('0x49'));var _0x5ac5f4=ejs[_0xf348('0x4a')](_0x25ffed,{'networks':_0x53c756||[]});fs[_0xf348('0x4b')]('/etc/asterisk/turn_xcally.conf',_0x5ac5f4);return respondWithRpcPromise(_0xf348('0x50'),_0xf348('0x43'),{'module':_0xf348('0x4d')});}else{var _0x12f53b=fs['readFileSync'](path[_0xf348('0x48')](config[_0xf348('0x51')],'server/files/templates/network.ejs'),'utf8');var _0x4331c1=ejs[_0xf348('0x4a')](_0x12f53b,{'networks':_0x53c756||[]});fs[_0xf348('0x4b')](util['format']('/etc/asterisk/sip_xcally_%s.conf',_0x2959de[_0xf348('0x44')]['type'][_0xf348('0x52')]()),_0x4331c1);return respondWithRpcPromise(_0xf348('0x50'),_0xf348('0x43'),{'module':_0xf348('0x53')});}})[_0xf348('0x1c')](function(){return _0x521bdb;})['then'](respondWithResult(_0x153db0,0xc9))[_0xf348('0x3e')](handleError(_0x153db0,null));};exports['update']=function(_0x41d552,_0x12ab73){var _0x19527e;return db[_0xf348('0x39')][_0xf348('0x42')]({'where':{'id':_0x41d552[_0xf348('0x40')]['id']}})['then'](handleEntityNotFound(_0x12ab73,null))[_0xf348('0x1c')](saveUpdates(_0x41d552[_0xf348('0x44')],null))[_0xf348('0x1c')](function(_0x56651d){if(_0x56651d){_0x19527e=_0x56651d;return db[_0xf348('0x39')][_0xf348('0x3c')]({'where':{'type':_0x19527e[_0xf348('0x26')]},'raw':!![]});}return null;})['then'](function(_0x2b6330){if(_0x19527e[_0xf348('0x26')]['toUpperCase']()==_0xf348('0x46')){var _0x167af6=fs[_0xf348('0x47')](path[_0xf348('0x48')](config[_0xf348('0x51')],_0xf348('0x54')),_0xf348('0x49'));var _0x418ec3=ejs[_0xf348('0x4a')](_0x167af6,{'networks':_0x2b6330||[]});fs['writeFileSync'](_0xf348('0x4c'),_0x418ec3);return respondWithRpcPromise(_0xf348('0x50'),_0xf348('0x1b'),{'module':_0xf348('0x4d')});}else if(_0x19527e['type'][_0xf348('0x45')]()==_0xf348('0x4e')){var _0xb67ac9=fs[_0xf348('0x47')](path[_0xf348('0x48')](config[_0xf348('0x51')],_0xf348('0x4f')),_0xf348('0x49'));var _0x3c83d5=ejs['render'](_0xb67ac9,{'networks':_0x2b6330||[]});fs[_0xf348('0x4b')](_0xf348('0x55'),_0x3c83d5);return respondWithRpcPromise(_0xf348('0x50'),'update',{'module':'res_stun_monitor.so'});}else{var _0x3710b5=fs[_0xf348('0x47')](path['join'](config[_0xf348('0x51')],_0xf348('0x56')),'utf8');var _0x18519e=ejs[_0xf348('0x4a')](_0x3710b5,{'networks':_0x2b6330||[]});fs[_0xf348('0x4b')](util[_0xf348('0x57')]('/etc/asterisk/sip_xcally_%s.conf',_0x41d552[_0xf348('0x44')][_0xf348('0x26')]['toLowerCase']()),_0x18519e);return respondWithRpcPromise(_0xf348('0x50'),_0xf348('0x1b'),{'module':_0xf348('0x53')});}})['then'](function(_0x48ffaf){if(_0x48ffaf){return _0x19527e;}return null;})[_0xf348('0x1c')](respondWithResult(_0x12ab73,null))[_0xf348('0x3e')](handleError(_0x12ab73,null));};exports[_0xf348('0x1d')]=function(_0x3a7251,_0x36d171){var _0x37933d;return db[_0xf348('0x39')][_0xf348('0x42')]({'where':{'id':_0x3a7251[_0xf348('0x40')]['id']}})[_0xf348('0x1c')](function(_0x138dcb){_0x37933d=_0x138dcb;return _0x138dcb;})['then'](handleEntityNotFound(_0x36d171,null))['then'](removeEntity(_0x36d171,null))[_0xf348('0x1c')](function(){if(_0x37933d){return db[_0xf348('0x39')][_0xf348('0x3c')]({'where':{'type':_0x37933d['type']},'raw':!![]});}})[_0xf348('0x1c')](function(_0x25adbf){if(_0x37933d[_0xf348('0x26')]['toUpperCase']()==_0xf348('0x46')){var _0x4329d3=fs[_0xf348('0x47')](path['join'](config['root'],_0xf348('0x54')),_0xf348('0x49'));var _0x4f80f6=ejs[_0xf348('0x4a')](_0x4329d3,{'networks':_0x25adbf||[]});fs[_0xf348('0x4b')]('/etc/asterisk/stun_xcally.conf',_0x4f80f6);return respondWithRpcPromise('Reload',_0xf348('0x1d'),{'module':_0xf348('0x4d')});}else if(_0x37933d[_0xf348('0x26')][_0xf348('0x45')]()=='TURN'){var _0x56b265=fs[_0xf348('0x47')](path[_0xf348('0x48')](config[_0xf348('0x51')],'server/files/templates/turn_multiple.ejs'),'utf8');var _0x4396e1=ejs[_0xf348('0x4a')](_0x56b265,{'networks':_0x25adbf||[]});fs['writeFileSync'](_0xf348('0x55'),_0x4396e1);return respondWithRpcPromise('Reload',_0xf348('0x1d'),{'module':_0xf348('0x4d')});}else{var _0x509240=fs[_0xf348('0x47')](path[_0xf348('0x48')](config[_0xf348('0x51')],_0xf348('0x56')),_0xf348('0x49'));var _0x1aedb8=ejs[_0xf348('0x4a')](_0x509240,{'networks':_0x25adbf||[]});fs[_0xf348('0x4b')](util[_0xf348('0x57')]('/etc/asterisk/sip_xcally_%s.conf',_0x37933d[_0xf348('0x26')]['toLowerCase']()),_0x1aedb8);return respondWithRpcPromise('Reload',_0xf348('0x1d'),{'module':_0xf348('0x53')});}})[_0xf348('0x3e')](handleError(_0x36d171,null));};
\ No newline at end of file