HEX
Server: Apache/2.2.34 (Unix) mod_fastcgi/mod_fastcgi-SNAP-0910052141
System: Linux Kou-Etsu-Dou 4.4.59+ #25556 SMP PREEMPT Thu Mar 4 18:03:46 CST 2021 x86_64
User: hosam (1026)
PHP: 7.2.29
Disabled: NONE
Upload Files
File: /volume1/@appstore/ProxyServer/app/proxyserver.js
/* Copyright (c) 2018 Synology Inc. All rights reserved. */

Ext.define("SYNO.SDS.ProxyServer.Instance",{extend:"SYNO.SDS.AppInstance",appWindowName:"SYNO.SDS.ProxyServer.ProxyServerMainWindow"});Ext.define("SYNO.SDS.ProxyServer.ProxyServerMainWindow",{extend:"SYNO.SDS.PageListAppWindow",width:990,height:560,activePage:"SYNO.SDS.ProxyServer.GeneralSettingPanel",constructor:function(a){var b=[{iconCls:"icon-setting",text:SYNO.SDS.ProxyServer._V("proxyserver","proxyserver_general_setting"),fn:"SYNO.SDS.ProxyServer.GeneralSettingPanel",help:"proxy_server_general_setting.html"},{iconCls:"icon-cache",text:SYNO.SDS.ProxyServer._V("proxyserver","cache_setting"),fn:"SYNO.SDS.ProxyServer.CachePanel",help:"proxy_server_cache.html"},{iconCls:"icon-access",text:SYNO.SDS.ProxyServer._V("proxyserver","access_setting"),fn:"SYNO.SDS.ProxyServer.AccessPanel",help:"proxy_server_access.html"},{iconCls:"icon-authentication",text:SYNO.SDS.ProxyServer._V("proxyserver","authentication_setting"),fn:"SYNO.SDS.ProxyServer.AuthenticationPanel",help:"proxy_server_authentication.html"},{iconCls:"icon-transparent",text:SYNO.SDS.ProxyServer._V("proxyserver","deployment_setting"),fn:"SYNO.SDS.ProxyServer.TransparentProxyPanel",help:"proxy_server_transparent.html"}];var c={cls:"syno-app-proxyserver",width:990,height:560,minWidth:990,minHeight:560,listItems:b};Ext.apply(c,a);this.callParent([c])}});SYNO.SDS.ProxyServer.AccessRecord=Ext.data.Record.create([{name:"permission_type",allowBlank:false},{name:"access_type",allowBlank:false},{name:"access_argument",allowBlank:false}]);Ext.define("SYNO.SDS.ProxyServer.AccessDialog",{extend:"SYNO.SDS.ModalWindow",constructor:function(a){this.owner=a.owner;if("edit"==a.mode){this.oriRecord=a.ori_record}var b=this.fillConfig(a);this.callParent([b])},fillConfig:function(a){this.formPanel=this.createFormPanel(a);this.form=this.formPanel.getForm();var b={title:SYNO.SDS.ProxyServer._V("proxyserver","proxy_access_edit"),resizable:false,height:SYNO.SDS.ProxyServer.DIALOG_HEIGHT,width:SYNO.SDS.ProxyServer.DIALOG_WIDTH,items:[this.formPanel],buttons:[{xtype:"syno_button",btnStyle:"blue",text:SYNO.SDS.ProxyServer._V("common","apply"),handler:this.onUpdateAccessGrid,scope:this},{xtype:"syno_button",text:SYNO.SDS.ProxyServer._V("common","cancel"),handler:this.onCancel,scope:this}]};Ext.apply(b,a);return b},createFormPanel:function(){var a={width:"570",height:"400",trackResetOnLoad:true,layout:"form",labelWidth:SYNO.SDS.ProxyServer.TEXTLABEL_WIDTH,items:[{layout:"hbox",border:false,allowBlank:false,fieldLabel:SYNO.SDS.ProxyServer._V("proxyserver","permission_type"),items:[{xtype:"syno_radio",name:"permission_type",boxLabel:SYNO.SDS.ProxyServer._V("proxyserver","permission_allow"),inputValue:"allow",width:100},{xtype:"syno_displayfield",width:5},{xtype:"syno_radio",name:"permission_type",boxLabel:SYNO.SDS.ProxyServer._V("proxyserver","permission_deny"),inputValue:"deny",width:100}]},{xtype:"syno_combobox",fieldLabel:SYNO.SDS.ProxyServer._V("proxyserver","access_type"),displayField:"display",valueField:"value",name:"access_type",allowBlank:false,store:[["src",SYNO.SDS.ProxyServer._V("proxyserver","src")],["srcdomain",SYNO.SDS.ProxyServer._V("proxyserver","srcdomain")],["dst",SYNO.SDS.ProxyServer._V("proxyserver","dst")],["dstdomain",SYNO.SDS.ProxyServer._V("proxyserver","dstdomain")]]},{xtype:"syno_textfield",fieldLabel:SYNO.SDS.ProxyServer._V("proxyserver","access_argument"),name:"access_argument",allowBlank:false,allowDecimals:false,vtype:"synoproxyserveraccess",maxlength:SYNO.SDS.ProxyServer.TXT_RECORD_MAX_LENGTH,width:SYNO.SDS.ProxyServer.TEXTFIELD_WIDTH-60}]};return new SYNO.ux.FormPanel(a)},onCancel:function(){if(this.form.isDirty()){this.getMsgBox().confirm(this.title,SYNO.SDS.ProxyServer._V("common","confirm_lostchange"),function(a){if("yes"===a){this.close()}},this);return}this.close()},isIPv4:function(b,a){if(1>a||32<a){return false}if(!/^([1-9][0-9]{0,1}|1[013-9][0-9]|12[0-689]|2[01][0-9]|22[0-3])([.]([1-9]{0,1}[0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){2}[.]([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/.test(b)){return false}return true},isIPv6:function(b,a){if(1>a||128<a){return false}if(!/^((([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4})|(([0-9a-fA-F]{1,4}:){1,7}:)|(([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4})|(([0-9a-fA-F]{1,4}:){1,5}:([0-9a-fA-F]{1,4}:){0,1}[0-9a-fA-F]{1,4})|(([0-9a-fA-F]{1,4}:){1,4}:([0-9a-fA-F]{1,4}:){0,2}[0-9a-fA-F]{1,4})|(([0-9a-fA-F]{1,4}:){1,3}:([0-9a-fA-F]{1,4}:){0,3}[0-9a-fA-F]{1,4})|(([0-9a-fA-F]{1,4}:){1,2}:([0-9a-fA-F]{1,4}:){0,4}[0-9a-fA-F]{1,4})|([0-9a-fA-F]{1,4}::([0-9a-fA-F]{1,4}:){0,5}[0-9a-fA-F]{1,4})|(::([0-9a-fA-F]{1,4}:){0,6}[0-9a-fA-F]{1,4}))$/.test(b)){return false}return true},validateAccessArguments:function(){var d=this.form.getValues();var b=d.access_argument.split(" ");if(d.access_type==="src"||d.access_type==="dst"){for(var c=0;c<b.length;c++){if(b[c]===""){continue}var a=b[c].split("/");if(!this.isIPv4(a[0],parseInt(a[1],10))&&!this.isIPv6(a[0],parseInt(a[1],10))){this.form.findField("access_argument").markInvalid(SYNO.SDS.ProxyServer._V("proxyserver","wrong_ip_address"));return false}}}return true},getRecordFromForm:function(){var d=this.form.getValues();var a=d.access_argument;if(d.access_type==="srcdomain"||d.access_type==="dstdomain"){a="";var c=d.access_argument.split(" ");for(var b=0;b<c.length;b++){if(c[b]===""){continue}if("."!==c[b].charAt(0)){a=a+" ."+c[b]}else{a=a+" "+c[b]}}a=a.trim()}var e=new SYNO.SDS.ProxyServer.AccessRecord({permission_type:d.permission_type,access_type:d.access_type,access_argument:a});return e},onUpdateAccessGrid:function(){if(!this.form.isValid()||!this.validateAccessArguments()){this.setStatusError({text:SYNO.SDS.ProxyServer._V("common","forminvalid"),clear:true});return}var b=this.gridAccess.getStore();var a=this.getRecordFromForm();if("create"==this.mode){b.add(a)}else{if("edit"==this.mode){this.oriRecord.set("permission_type",a.get("permission_type"));this.oriRecord.set("access_type",a.get("access_type"));this.oriRecord.set("access_argument",a.get("access_argument"))}}this.close()},onOpen:function(){this.setStatusBusy();this.gridAccess=this.owner.getActivePage();if("create"==this.mode){this.setTitle(SYNO.SDS.ProxyServer._V("proxyserver","create_access"));this.form.setValues({permission_type:"deny"})}else{if("edit"==this.mode){this.setTitle(SYNO.SDS.ProxyServer._V("proxyserver","edit_access"));var a=this.gridAccess.getSelectionModel().getSelected();this.form.setValues(a.data)}}this.clearStatusBusy();this.callParent(arguments)},getAccessTypeStore:function(){var a=new SYNO.SDS.ProxyServer.AccessTypeStore();return a}});Ext.define("SYNO.SDS.ProxyServer.AccessPanel",{extend:"SYNO.ux.GridPanel",constructor:function(a){this.owner=a.appWin;var b=this.fillConfig(a);this.callParent([b])},fillConfig:function(a){this.gridStore=this.createGridStore();this.toolBar=new Ext.Toolbar({defaultType:"syno_button",items:this.createToolBar()});this.createBtn=this.toolBar.getComponent("btnCreate");this.editBtn=this.toolBar.getComponent("btnEdit");this.deleteBtn=this.toolBar.getComponent("btnDelete");this.saveBtn=this.toolBar.getComponent("btnSave");this.upBtn=this.toolBar.getComponent("btnUp");this.downBtn=this.toolBar.getComponent("btnDown");this.isDeleted=false;var b={itemId:"access_setting",border:false,trackResetOnLoad:true,ds:this.gridStore,tbar:this.toolBar,columns:[{id:"permission_type",header:SYNO.SDS.ProxyServer._V("proxyserver","permission_type"),dataIndex:"permission_type",width:150,align:"center"},{id:"access_type",header:SYNO.SDS.ProxyServer._V("proxyserver","access_type"),dataIndex:"access_type",width:150,align:"center",renderer:function(c){if(c==="src"){return SYNO.SDS.ProxyServer._V("proxyserver","src")}else{if(c==="srcdomain"){return SYNO.SDS.ProxyServer._V("proxyserver","srcdomain")}else{if(c==="dst"){return SYNO.SDS.ProxyServer._V("proxyserver","dst")}else{if(c==="dstdomain"){return SYNO.SDS.ProxyServer._V("proxyserver","dstdomain")}else{return c}}}}}},{id:"access_argument",header:SYNO.SDS.ProxyServer._V("proxyserver","access_argument"),dataIndex:"access_argument",width:150,align:"center"}],enableDragDrop:true,autoExpandColumn:"access_argument",ddGroup:"AccessDD",selModel:new Ext.grid.RowSelectionModel({singleSelect:false,listeners:{selectionchange:{fn:this.onChangeBtnStatus,scope:this}}}),listeners:{rowdblclick:function(){this.openAccessDialog("edit")},scope:this}};Ext.apply(b,a);return b},createToolBar:function(){return[{text:SYNO.SDS.ProxyServer._V("common","create"),itemId:"btnCreate",scope:this,handler:function(b,a){this.openAccessDialog("create")}},{text:SYNO.SDS.ProxyServer._V("common","alt_edit"),itemId:"btnEdit",scope:this,disabled:true,handler:function(b,a){this.openAccessDialog("edit")}},{text:SYNO.SDS.ProxyServer._V("common","delete"),itemId:"btnDelete",scope:this,disabled:true,handler:function(){var a=this.getSelectionModel().getSelections();var c=this.gridStore;var b=0;for(b=0;b<a.length;b++){if("Authentication"!=a[b].data.access_type){this.isDeleted=true;c.remove(a[b])}}}},{text:SYNO.SDS.ProxyServer._V("common","save"),itemId:"btnSave",scope:this,disabled:_S("demo_mode"),tooltip:_S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):"",handler:this.onSaveAccess},{text:SYNO.SDS.ProxyServer._V("common","up"),itemId:"btnUp",scope:this,disabled:true,handler:function(){this.onMoveRow(true)}},{text:SYNO.SDS.ProxyServer._V("common","down"),itemId:"btnDown",scope:this,disabled:true,handler:function(){this.onMoveRow(false)}}]},createGridStore:function(){var a=new Ext.data.Store({pruneModifiedRecords:true,autoLoad:false,proxy:new Ext.data.HttpProxy({url:SYNO.SDS.ProxyServer.CGI_PATH,method:"GET"}),reader:new Ext.data.JsonReader({root:"rules",fields:["permission_type","access_type","access_argument"]}),baseParams:{action:"access_load"}});return a},onPageActivate:function(){this.gridStore.load({params:{action:"access_load"},scope:this});this.onChangeBtnStatus()},onPageDeactivate:function(){if(this.isDirty()){return false}this.onChangeBtnStatus()},initEvents:function(){this.callParent(arguments);this.mon(this.getSelectionModel(),"selectionchange",this.onChangeBtnStatus,this);this.mon(this.gridStore,"update",this.onChangeBtnStatus,this);this.mon(this.gridStore,"load",this.onChangeBtnStatus,this);this.mon(this.gridStore,"add",this.onChangeBtnStatus,this);this.mon(this,"afterlayout",function(){var a;a=new Ext.dd.DropTarget(this.getView().mainBody,{ddGroup:"AccessDD",scope:this,notifyDrop:function(b,d,c){return this.scope.mvAccess(b.getDragData(d).rowIndex,c.selections,c.grid.getStore())}})},this,{single:true})},onChangeBtnStatus:function(){var a=this.getSelectionModel().getCount();if(this.isDirty()){if(!_S("demo_mode")){this.saveBtn.enable()}}else{this.saveBtn.disable()}if(0<a){this.deleteBtn.enable()}else{this.deleteBtn.disable()}if(1==a){this.editBtn.enable();this.upBtn.enable();this.downBtn.enable()}else{this.editBtn.disable();this.upBtn.disable();this.downBtn.disable()}},openAccessDialog:function(c){var a=this.getSelectionModel().getSelections();var d;if("edit"==c){d={owner:this.owner,mode:c,ori_record:a[0]}}else{d={owner:this.owner,mode:c}}var b=new SYNO.SDS.ProxyServer.AccessDialog(d);b.open()},onSaveAccess:function(){this.owner.setStatusBusy({text:SYNO.SDS.ProxyServer._V("common","saving")});var b=this.gridStore.getRange();var a=[];b.each(function(d){a.push(d.data)},this);var c={};c.action="access_apply";c.rules=a;this.owner.addAjaxTask({single:true,autoJsonDecode:true,url:SYNO.SDS.ProxyServer.CGI_PATH,params:Ext.encode(c),method:"POST",scope:this,success:function(d,e){this.owner.clearStatusBusy();if(d.success){this.gridStore.reload();this.isDeleted=false;this.owner.setStatusOK()}else{if(d.errinfo){this.owner.getMsgBox().alert(this.title,SYNO.SDS.ProxyServer._V(d.errinfo.sec,d.errinfo.key))}else{this.owner.getMsgBox().alert(this.title,SYNO.SDS.ProxyServer._V("error","error_unknown"))}}},failure:function(d,e){this.clearStatusBusy();this.owner.getMsgBox().alert(this.title,SYNO.SDS.ProxyServer._V("error","error_unknown"))}}).start()},isDirty:function(){if(0<this.gridStore.getModifiedRecords().length||this.isDeleted===true){return true}else{return false}},onMoveRow:function(d){var c=this.gridStore;var a=this.getSelectionModel().getSelected();var b=c.indexOf(a);if(d){b=b-1}else{b=b+1}if(b<0||b>c.getCount()-1){return}c.remove(a);c.insert(b,a);this.getSelectionModel().selectRecords([a])},mvAccess:function(b,c,d){if(undefined===b){return false}for(var a=0;a<c.length;a++){d.remove(c[a])}if(b>=d.getCount()){d.add(c)}else{d.insert(b,c)}return true}});Ext.define("SYNO.SDS.ProxyServer.AuthenticationPanel",{extend:"SYNO.SDS.Utils.FormPanel",constructor:function(a){this.owner=a.appWin;this.module=a.module;var b=this.fillConfig(a);this.callParent([b]);this.on("afterlayout",function(d,e){var c;c=new SYNO.ux.Utils.EnableCheckGroup(d.getForm(),"auth_enable",["auth_word"])})},fillConfig:function(a){var b={title:SYNO.SDS.ProxyServer._V("proxyserver","proxy_auth_title"),trackResetOnLoad:true,width:570,layout:"form",labelWidth:SYNO.SDS.ProxyServer.TEXTLABEL_WIDTH+100,items:[{xtype:"syno_fieldset",title:SYNO.SDS.ProxyServer._V("proxyserver","proxy_auth_title"),autoHeight:true,items:[{xtype:"syno_checkbox",name:"auth_enable",boxLabel:SYNO.SDS.ProxyServer._V("proxyserver","auth_enable"),width:SYNO.SDS.ProxyServer.TEXTFIELD_WIDTH},{xtype:"syno_displayfield",value:SYNO.SDS.ProxyServer._V("proxyserver","auth_expression"),indent:1},{fieldLabel:SYNO.SDS.ProxyServer._V("proxyserver","welcome_message"),xtype:"syno_textfield",name:"auth_word",allowBlank:false,maxlength:SYNO.SDS.ProxyServer.TXT_RECORD_MAX_LENGTH,width:SYNO.SDS.ProxyServer.TEXTFIELD_WIDTH,indent:1}]}],buttons:[{xtype:"syno_button",btnStyle:"blue",text:SYNO.SDS.ProxyServer._V("common","commit"),scope:this,disabled:_S("demo_mode"),tooltip:_S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):"",handler:this.onApply},{xtype:"syno_button",text:SYNO.SDS.ProxyServer._V("common","reset"),handler:this.onReset,scope:this}]};Ext.apply(b,a);return b},onPageActivate:function(){this.loadForm()},loadForm:function(){this.setStatusBusy();this.owner.addAjaxTask({params:{action:"authentication_load"},single:true,autoJsonDecode:true,url:SYNO.SDS.ProxyServer.CGI_PATH,method:"GET",scope:this,success:function(a,b){this.clearStatusBusy();if(a.success&&a.item){this.OriSetting=a.item;this.getForm().setValues(this.OriSetting)}else{this.owner.getMsgBox().alert(this.title,SYNO.SDS.ProxyServer._V("common","error_system"))}},failure:function(a,b){this.clearStatusBusy();this.owner.getMsgBox().alert(this.title,SYNO.SDS.ProxyServer._V("common","error_system"))}}).start()},onApply:function(){if(!this.checkDirty()){this.setStatusError({text:SYNO.SDS.ProxyServer._V("error","nochange_subject"),clear:true});return}if(!this.getForm().isValid()){this.setStatusError({text:SYNO.SDS.ProxyServer._V("common","forminvalid"),clear:true});return}this.applyForm()},checkDirty:function(){if(this.getForm().isDirty()){return true}return false},applyForm:function(){this.setStatusBusy({text:SYNO.SDS.ProxyServer._V("common","saving")});var a=this.getForm().getValues();this.owner.addAjaxTask({single:true,autoJsonDecode:true,url:SYNO.SDS.ProxyServer.CGI_PATH,params:Ext.encode(Ext.apply(a,{action:"authentication_apply"})),method:"POST",scope:this,success:function(b,c){this.clearStatusBusy();if(b.success){this.setStatusOK();this.OriSetting=this.getForm().getValues();this.getForm().setValues(this.OriSetting)}else{if(b.errinfo){this.owner.getMsgBox().alert(this.title,SYNO.SDS.ProxyServer._V(b.errinfo.sec,b.errinfo.key))}else{this.owner.getMsgBox().alert(this.title,SYNO.SDS.ProxyServer._V("error","error_unknown"))}}},failure:function(b,c){this.clearStatusBusy();this.owner.getMsgBox().alert(this.title,SYNO.SDS.ProxyServer._V("error","error_unknown"))}}).start()},onReset:function(){this.getForm().reset()},onPageDeactivate:function(){if(this.checkDirty()){this.owner.getMsgBox().confirm(this.title,SYNO.SDS.ProxyServer._V("common","confirm_lostchange"),function(a){if("yes"===a){return true}},this);return false}}});Ext.define("SYNO.SDS.ProxyServer.CachePanel",{extend:"SYNO.SDS.Utils.FormPanel",constructor:function(a){this.owner=a.appWin;this.module=a.module;this.freesize=0;var b=this.fillConfig(a);this.callParent([b])},fillConfig:function(a){this.diskCacheField=this.createDiskCacheField();this.memoryCacheField=this.createMemoryCacheField();this.title=SYNO.SDS.ProxyServer._V("proxyserver","cache_setting");var b={itemId:"panel_cache",border:false,trackResetOnLoad:true,items:[this.diskCacheField,this.memoryCacheField],buttons:[{xtype:"syno_button",btnStyle:"blue",text:SYNO.SDS.ProxyServer._V("common","commit"),disabled:_S("demo_mode"),tooltip:_S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):"",handler:this.onSave,scope:this},{xtype:"syno_button",text:SYNO.SDS.ProxyServer._V("common","reset"),handler:this.onReset,scope:this}]};Ext.apply(b,a);return b},createMemoryCacheField:function(){var a={title:SYNO.SDS.ProxyServer._V("proxyserver","memory_cache_option"),width:"570",height:"400",layout:"form",labelWidth:SYNO.SDS.ProxyServer.TEXTLABEL_WIDTH,items:[{xtype:"syno_compositefield",items:[{fieldLabel:SYNO.SDS.ProxyServer._V("proxyserver","cache_mem_size"),xtype:"syno_numberfield",name:"cache_mem",allowBlank:false,allowDecimals:false,vtype:"digit",width:SYNO.SDS.ProxyServer.TEXTFIELD_WIDTH,maxValue:4095,minValue:0},{xtype:"syno_displayfield",value:"MB"}]},{xtype:"syno_compositefield",items:[{fieldLabel:SYNO.SDS.ProxyServer._V("proxyserver","max_obj_mem"),xtype:"syno_numberfield",name:"maximum_object_size_in_memory",allowBlank:false,allowDecimals:false,vtype:"digit",maxValue:2048,minValue:0,width:SYNO.SDS.ProxyServer.TEXTFIELD_WIDTH},{xtype:"syno_displayfield",value:"KB"}]}]};return new SYNO.ux.FieldSet(a)},createDiskCacheField:function(){var a={title:SYNO.SDS.ProxyServer._V("proxyserver","disk_cache_option"),width:"570",height:"400",layout:"form",labelWidth:SYNO.SDS.ProxyServer.TEXTLABEL_WIDTH,items:[{xtype:"syno_compositefield",fieldLabel:SYNO.SDS.ProxyServer._V("proxyserver","cachedir_title"),items:[{xtype:"syno_combobox",name:"cache_dir_path",allowBlank:false,displayField:"display_volume",valueField:"value_volume",width:SYNO.SDS.ProxyServer.TEXTFIELD_WIDTH},{xtype:"syno_displayfield",width:5},{xtype:"syno_textfield",name:"cache_dir_size",allowBlank:false,allowDecimals:false,vtype:"digit",maxValue:500,minValue:1,width:SYNO.SDS.ProxyServer.TEXTFIELD_WIDTH-150},{xtype:"syno_displayfield",value:"GB"}]},{xtype:"syno_button",text:SYNO.SDS.ProxyServer._V("proxyserver","clean_disk_cache"),handler:this.onCleanCache,disabled:_S("demo_mode"),tooltip:_S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):"",scope:this},{xtype:"syno_compositefield",items:[{fieldLabel:SYNO.SDS.ProxyServer._V("proxyserver","min_obj_disk"),xtype:"syno_numberfield",name:"minimum_object_size",allowBlank:false,allowDecimals:false,vtype:"digit",maxValue:2048,minValue:0,width:SYNO.SDS.ProxyServer.TEXTFIELD_WIDTH},{xtype:"syno_displayfield",value:"KB"}]},{xtype:"syno_compositefield",items:[{fieldLabel:SYNO.SDS.ProxyServer._V("proxyserver","max_obj_disk"),xtype:"syno_numberfield",name:"maximum_object_size",allowBlank:false,allowDecimals:false,vtype:"digit",maxValue:2000000,minValue:8,width:SYNO.SDS.ProxyServer.TEXTFIELD_WIDTH},{xtype:"syno_displayfield",value:"KB"}]},{xtype:"syno_compositefield",items:[{fieldLabel:SYNO.SDS.ProxyServer._V("proxyserver","cache_swap_low"),xtype:"syno_numberfield",name:"cache_swap_low",allowBlank:false,allowDecimals:false,vtype:"digit",maxValue:100,minValue:0,width:SYNO.SDS.ProxyServer.TEXTFIELD_WIDTH},{xtype:"syno_displayfield",value:"%"}]},{xtype:"syno_compositefield",items:[{fieldLabel:SYNO.SDS.ProxyServer._V("proxyserver","cache_swap_high"),xtype:"syno_numberfield",name:"cache_swap_high",allowBlank:false,allowDecimals:false,vtype:"digit",maxValue:100,minValue:0,width:SYNO.SDS.ProxyServer.TEXTFIELD_WIDTH},{xtype:"syno_displayfield",value:"%"}]}]};return new SYNO.ux.FieldSet(a)},onPageActivate:function(){this.loadForm()},createVolumeList:function(d){this.volumeList=[];for(var a=0;a<d.size();a++){var b=d[a].mount_point.replace("/v","V");this.freesize=Math.floor(d[a].freesize/1024/1024/1024);b=b.concat(" (Available: ");b=b.concat(this.freesize.toString());b=b.concat("GB)");var c=d[a].id;this.volumeList.push([b,c])}this.getForm().findField("cache_dir_path").store=new Ext.data.ArrayStore({fields:["display_volume","value_volume"],data:this.volumeList})},loadForm:function(){this.setStatusBusy();this.owner.addAjaxTask({single:true,autoJsonDecode:true,url:SYNO.SDS.ProxyServer.CGI_PATH,params:{action:"cache_conf_load"},method:"GET",scope:this,success:function(a,b){this.clearStatusBusy();if(a.success){a.item.cache_dir_size=Math.floor(parseInt(a.item.cache_dir_size,10)/1024);this.createVolumeList(a.item.volume_list);this.getForm().setValues(a.item)}else{if(a.errinfo){this.owner.getMsgBox().alert(this.title,SYNO.SDS.ProxyServer._V(a.errinfo.sec,a.errinfo.key))}else{this.owner.getMsgBox().alert(this.title,SYNO.SDS.ProxyServer._V("error","error_unknown"))}}},failure:function(a,b){this.clearStatusBusy();this.owner.getMsgBox().alert(this.title,SYNO.SDS.ProxyServer._V("error","error_unknown"))}}).start()},onSave:function(){if(!this.getForm().isDirty()){this.setStatusError({text:SYNO.SDS.ProxyServer._V("error","nochange_subject"),clear:true});return}if(!this.getForm().isValid()||!this.isMaxMinValid()||!this.checkVolumeFreesize()){this.setStatusError({text:SYNO.SDS.ProxyServer._V("common","forminvalid"),clear:true});return}this.applyForm()},checkVolumeFreesize:function(a){if(this.getForm().findField("cache_dir_size").getValue()>=this.freesize){this.getForm().findField("cache_dir_size").markInvalid(SYNO.SDS.ProxyServer._V("proxyserver","error_exceed_freesize"));return false}return true},isMaxMinValid:function(){var a=this.getForm().getValues();if(a.minimum_object_size>=a.maximum_object_size){this.getForm().findField("maximum_object_size").markInvalid(SYNO.SDS.ProxyServer._V("proxyserver","error_min_exceed_max_obj"));return false}if(a.cache_swap_low>=a.cache_swap_high){this.getForm().findField("cache_swap_high").markInvalid(SYNO.SDS.ProxyServer._V("proxyserver","error_min_exceed_max_swap"));return false}if(a.maximum_object_size_in_memory/1024>=a.cache_mem){this.getForm().findField("cache_mem").markInvalid(SYNO.SDS.ProxyServer._V("proxyserver","error_min_exceed_mem_cache"));return false}if(a.maximum_object_size/1024/1024>=a.cache_dir_size){this.getForm().findField("cache_dir_size").markInvalid(SYNO.SDS.ProxyServer._V("proxyserver","error_min_exceed_cache_dir"));return false}return true},applyForm:function(){this.setStatusBusy({text:SYNO.SDS.ProxyServer._V("common","saving")});this.tmpSetting=this.getForm().getValues();this.owner.addAjaxTask({single:true,autoJsonDecode:true,url:SYNO.SDS.ProxyServer.CGI_PATH,params:Ext.encode(Ext.apply(this.tmpSetting,{action:"cache_conf_apply"})),method:"POST",scope:this,success:function(a,b){this.clearStatusBusy();if(a.success){this.getForm().setValues(this.tmpSetting);this.setStatusOK()}else{if(a.errinfo){this.owner.getMsgBox().alert(this.title,SYNO.SDS.ProxyServer._V(a.errinfo.sec,a.errinfo.key))}else{this.owner.getMsgBox().alert(this.title,SYNO.SDS.ProxyServer._V("error","error_unknown"))}}},failure:function(a,b){this.clearStatusBusy();this.owner.getMsgBox().alert(this.title,SYNO.SDS.ProxyServer._V("error","error_unknown"))}}).start()},onReset:function(){this.getForm().reset()},onPageDeactivate:function(){if(this.getForm().isDirty()){return false}},onCleanCache:function(){this.owner.getMsgBox().confirm("",SYNO.SDS.ProxyServer._V("proxyserver","confirm_clean_cache"),function(a){if("yes"===a){this.cleanCache()}},this)},cleanCache:function(){this.setStatusBusy({text:SYNO.SDS.ProxyServer._V("proxyserver","cleaning_cache")});this.owner.addAjaxTask({single:true,autoJsonDecode:true,url:SYNO.SDS.ProxyServer.CGI_PATH,params:{action:"cache_clean"},method:"GET",scope:this,success:function(a,b){this.clearStatusBusy();if(a.success){this.setStatusOK()}else{if(a.errinfo){this.owner.getMsgBox().alert(this.settingField.title,SYNO.SDS.ProxyServer._V(a.errinfo.sec,a.errinfo.key))}else{this.owner.getMsgBox().alert(this.settingField.title,SYNO.SDS.ProxyServer._V("error","error_unknown"))}}},failure:function(a,b){this.clearStatusBusy();this.owner.getMsgBox().alert(this.settingField.title,SYNO.SDS.ProxyServer._V("error","error_unknown"))}}).start()}});Ext.define("SYNO.SDS.ProxyServer.GeneralSettingPanel",{extend:"SYNO.SDS.Utils.FormPanel",constructor:function(a){this.owner=a.appWin;this.module=a.module;var b=this.fillConfig(a);this.callParent([b]);this.on("afterlayout",function(d,e){var c;c=new SYNO.ux.Utils.EnableCheckGroup(d.getForm(),"log_enable",["log_transfer_enable"]);var f;f=new SYNO.ux.Utils.EnableCheckGroup(d.getForm(),"log_transfer_enable",["log_transfer_protocol","log_transfer_host","log_transfer_port"]);this.mon(this.getForm().findField("log_enable"),"check",this.onChangeLogEnable,this)})},fillConfig:function(a){this.settingField=this.createSettingFiled();var b={itemId:"panel_general_setting",border:false,trackResetOnLoad:true,items:[this.settingField],buttons:[{xtype:"syno_button",btnStyle:"blue",text:SYNO.SDS.ProxyServer._V("common","commit"),disabled:_S("demo_mode"),tooltip:_S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):"",handler:this.onSave,scope:this},{xtype:"syno_button",text:SYNO.SDS.ProxyServer._V("common","reset"),handler:this.onReset,scope:this}]};Ext.apply(b,a);return b},createSettingFiled:function(){var a={title:SYNO.SDS.ProxyServer._V("proxyserver","proxyserver_general_setting"),width:"570",height:"400",labelWidth:SYNO.SDS.ProxyServer.TEXTLABEL_WIDTH,items:[{fieldLabel:SYNO.SDS.ProxyServer._V("proxyserver","proxy_manager_email"),xtype:"syno_textfield",name:"cache_mgr",allowBlank:false,allowDecimals:false,vtype:"email",maxlength:SYNO.SDS.ProxyServer.TXT_RECORD_MAX_LENGTH,width:SYNO.SDS.ProxyServer.TEXTFIELD_WIDTH},{fieldLabel:SYNO.SDS.ProxyServer._V("proxyserver","proxy_port"),xtype:"syno_numberfield",name:"http_port",allowBlank:false,allowDecimals:false,vtype:"port",width:SYNO.SDS.ProxyServer.TEXTFIELD_WIDTH,validator:function(b){if(SYNO.SDS.Utils.isReservedPort("",b,b)){return SYNO.SDS.ProxyServer._V("service","error_dl_port_in_used")}else{return true}}},{xtype:"syno_checkbox",name:"cache_enable",boxLabel:SYNO.SDS.ProxyServer._V("proxyserver","cache_enable"),width:SYNO.SDS.ProxyServer.TEXTFIELD_WIDTH},{xtype:"syno_checkbox",name:"log_enable",boxLabel:SYNO.SDS.ProxyServer._V("proxyserver","log_enable"),width:SYNO.SDS.ProxyServer.TEXTFIELD_WIDTH},{xtype:"syno_checkbox",name:"log_transfer_enable",boxLabel:SYNO.SDS.ProxyServer._V("proxyserver","log_transfer_enable"),width:SYNO.SDS.ProxyServer.TEXTFIELD_WIDTH,indent:1},{xtype:"syno_combobox",name:"log_transfer_protocol",fieldLabel:SYNO.SDS.ProxyServer._V("proxyserver","log_protocol"),store:[["tcp","TCP"],["udp","UDP"]],editable:false,forceSelection:true,allowBlank:false,value:"udp",indent:1},{fieldLabel:SYNO.SDS.ProxyServer._V("proxyserver","log_host"),xtype:"syno_textfield",name:"log_transfer_host",allowBlank:false,allowDecimals:false,vtype:"iporhostname",maxlength:SYNO.SDS.ProxyServer.TXT_RECORD_MAX_LENGTH,indent:1},{fieldLabel:SYNO.SDS.ProxyServer._V("proxyserver","log_port"),xtype:"syno_textfield",name:"log_transfer_port",allowBlank:false,allowDecimals:false,vtype:"port",maxlength:SYNO.SDS.ProxyServer.TXT_RECORD_MAX_LENGTH,indent:1},{xtype:"syno_button",text:SYNO.SDS.ProxyServer._V("proxyserver","export_log"),itemId:"proxyserver_log_export",disabled:true,tooltip:_S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):"",handler:this.onExportLog,scope:this,indent:1},{xtype:"syno_displayfield",height:"10"},{xtype:"syno_button",text:SYNO.SDS.ProxyServer._V("proxyserver","proxy_reset_default"),disabled:_S("demo_mode"),tooltip:_S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):"",handler:this.resetDefault,scope:this}]};return new SYNO.ux.FieldSet(a)},onPageActivate:function(){this.loadForm()},loadForm:function(){this.setStatusBusy();this.owner.addAjaxTask({single:true,autoJsonDecode:true,url:SYNO.SDS.ProxyServer.CGI_PATH,params:{action:"general_setting_load"},method:"GET",scope:this,success:function(a,b){this.clearStatusBusy();if(a.success){this.OriSetting=a.item;this.getForm().setValues(this.OriSetting)}else{if(a.errinfo){this.owner.getMsgBox().alert(this.settingField.title,SYNO.SDS.ProxyServer._V(a.errinfo.sec,a.errinfo.key))}else{this.owner.getMsgBox().alert(this.settingField.title,SYNO.SDS.ProxyServer._V("error","error_unknown"))}}},failure:function(a,b){this.clearStatusBusy();this.owner.getMsgBox().alert(this.settingField.title,SYNO.SDS.ProxyServer._V("error","error_unknown"))}}).start()},onSave:function(){if(!this.checkDirty()){this.setStatusError({text:SYNO.SDS.ProxyServer._V("error","nochange_subject"),clear:true});return}if(!this.getForm().isValid()){this.setStatusError({text:SYNO.SDS.ProxyServer._V("common","forminvalid"),clear:true});return}this.applyForm()},checkDirty:function(){if(this.getForm().isDirty()){return true}return false},applyForm:function(){this.setStatusBusy({text:SYNO.SDS.ProxyServer._V("common","saving")});this.tmpSetting=this.getForm().getValues();this.owner.addAjaxTask({single:true,autoJsonDecode:true,url:SYNO.SDS.ProxyServer.CGI_PATH,params:Ext.encode(Ext.apply(this.tmpSetting,{action:"general_setting_apply"})),method:"POST",scope:this,success:function(a,b){this.clearStatusBusy();if(a.success){this.setStatusOK();this.getForm().setValues(this.tmpSetting)}else{if(a.errinfo){this.owner.getMsgBox().alert(this.settingField.title,SYNO.SDS.ProxyServer._V(a.errinfo.sec,a.errinfo.key))}else{this.owner.getMsgBox().alert(this.settingField.title,SYNO.SDS.ProxyServer._V("error","error_unknown"))}}},failure:function(a,b){this.clearStatusBusy();this.owner.getMsgBox().alert(this.settingField.title,SYNO.SDS.ProxyServer._V("error","error_unknown"))}}).start()},onReset:function(){this.getForm().reset()},onPageDeactivate:function(){if(this.checkDirty()){return false}},onChangeLogEnable:function(b,c,a){if(c){if(!_S("demo_mode")){this.settingField.getComponent("proxyserver_log_export").enable()}}else{this.settingField.getComponent("proxyserver_log_export").disable()}},onExportLog:function(){var a=document.getElementById("syno-download-frame");var b=Ext.urlAppend(SYNO.SDS.ProxyServer.CGI_PATH+"?action=log_export");if(!a){a=Ext.DomHelper.append(document.body,{tag:"iframe",id:"syno-download-frame",frameBorder:0,width:0,height:0,css:"display:none;visibility:hidden;height:1px;",src:b})}else{a.src=b}},resetDefault:function(){this.setStatusBusy({text:SYNO.SDS.ProxyServer._V("proxyserver","resetting_to_default")});this.owner.addAjaxTask({single:true,autoJsonDecode:true,url:SYNO.SDS.ProxyServer.CGI_PATH,params:{action:"default_setting_reset"},method:"GET",scope:this,success:function(a,b){this.clearStatusBusy();if(a.success){this.setStatusOK();this.loadForm()}else{if(a.errinfo){this.owner.getMsgBox().alert(this.settingField.title,SYNO.SDS.ProxyServer._V(a.errinfo.sec,a.errinfo.key))}else{this.owner.getMsgBox().alert(this.settingField.title,SYNO.SDS.ProxyServer._V("error","error_unknown"))}}},failure:function(a,b){this.clearStatusBusy();this.owner.getMsgBox().alert(this.settingField.title,SYNO.SDS.ProxyServer._V("error","error_unknown"))}}).start()}});Ext.ns("SYNO.SDS.ProxyServer");SYNO.SDS.ProxyServer.CGI_PATH="webman/3rdparty/ProxyServer/proxyserver.cgi";SYNO.SDS.ProxyServer.APP_WIDTH=990;SYNO.SDS.ProxyServer.APP_HEIGHT=560;SYNO.SDS.ProxyServer.CARD_WIDTH=797;SYNO.SDS.ProxyServer.LIST_WIDTH=220;SYNO.SDS.ProxyServer.DEFAULT_HEIGHT=548;SYNO.SDS.ProxyServer.GRID_DATA_WIDTH=759;SYNO.SDS.ProxyServer.GRID_DATA_HEIGHT=474;SYNO.SDS.ProxyServer.TEXTFIELD_WIDTH=260;SYNO.SDS.ProxyServer.RECD_TEXTFIELD_WIDTH=300;SYNO.SDS.ProxyServer.TEXTFIELD_WIDTH_SHORT=130;SYNO.SDS.ProxyServer.TOOLBAR_HEIGHT=31;SYNO.SDS.ProxyServer.GRID_HEIGHT=500;SYNO.SDS.ProxyServer.DIALOG_WIDTH=520;SYNO.SDS.ProxyServer.DIALOG_HEIGHT=350;SYNO.SDS.ProxyServer.STATUS_HEIGHT=600;SYNO.SDS.ProxyServer.FORM_HEIGHT=600;SYNO.SDS.ProxyServer.FORM_WIDTH=425;SYNO.SDS.ProxyServer.BUTTON_WIDTH=100;SYNO.SDS.ProxyServer.TEXTLABEL_WIDTH=250;SYNO.SDS.ProxyServer.TEXTLABEL_LONG_WIDTH=450;SYNO.SDS.ProxyServer.TAB_PAENL_WIDTH=575;SYNO.SDS.ProxyServer.LABEL_WIDTH=200;SYNO.SDS.ProxyServer.FORM_PADDING=15;SYNO.SDS.ProxyServer.RESOURCE_RECORD_WIDTH=640;SYNO.SDS.ProxyServer.TXT_RECORD_MAX_LENGTH=255;SYNO.SDS.ProxyServer.NOSUCH_PACKAGE=4545;SYNO.SDS.ProxyServer._V=function(b,a){if("proxyserver"===b){return _TT("SYNO.SDS.ProxyServer.Instance",b,a)}else{return _T(b,a)}};Ext.form.VTypes.synoproxyserveraccessText=SYNO.SDS.ProxyServer._V("proxyserver","bad_access_args");Ext.form.VTypes.synoproxyserveraccessMask=/[\-\.\ :\/a-zA-Z0-9]/;Ext.form.VTypes.synoproxyserveraccessVal=/^[.a-zA-Z0-9][\-\.\ :\/a-zA-Z0-9]{0,254}$/;Ext.form.VTypes.synoproxyserveraccess=function(a){if(!Ext.form.VTypes.synoproxyserveraccessVal.test(a)){return false}return true};Ext.define("SYNO.SDS.ProxyServer.TransparentProxyPanel",{extend:"SYNO.SDS.Utils.FormPanel",constructor:function(a){this.owner=a.appWin;this.module=a.module;var b=this.fillConfig(a);this.callParent([b]);this.on("afterlayout",function(d,e){var c;c=new SYNO.ux.Utils.EnableCheckGroup(d.getForm(),"wpad_enable",["wpad_interface"])})},fillConfig:function(a){this.WPADField=this.createWPADField();var b=[this.WPADField];if("synology_bromolow_rc18015xs+"!==_D("unique")){this.wirelessField=this.createWirelessField();b.push(this.wirelessField)}var c={border:false,trackResetOnLoad:true,items:b,buttons:[{xtype:"syno_button",btnStyle:"blue",text:SYNO.SDS.ProxyServer._V("common","commit"),handler:this.onSave,disabled:_S("demo_mode"),tooltip:_S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):"",scope:this},{xtype:"syno_button",text:SYNO.SDS.ProxyServer._V("common","reset"),handler:this.onReset,scope:this}]};Ext.apply(c,a);return c},needWebStationAlert:function(){this.owner.getMsgBox().confirm("",SYNO.SDS.ProxyServer._V("proxyserver","start_web_station_warning"),function(a){if("no"===a){return}SYNO.SDS.AppLaunch("SYNO.SDS.PkgManApp.Instance",Ext.apply({},this.owner.findAppWindow().openConfig))},this)},WpadCheckHandler:function(c,b,a){if(!c){this.getForm().findField("wpad_enable").setValue(false);if(SYNO.SDS.ProxyServer.NOSUCH_PACKAGE===b.code){this.needWebStationAlert()}else{this.owner.getMsgBox().alert(this.title,SYNO.SDS.ProxyServer._V("error","error_unknown"))}this.clearStatusBusy();return}if("running"!==b.additional.status){this.getForm().findField("wpad_enable").reset();this.needWebStationAlert()}this.clearStatusBusy()},WPADDHCPServerCheckHandler:function(c,b,a){if(!c){return}if(this.getForm().findField("wpad_enable").getValue()&&!b.enable){this.owner.getMsgBox().confirm("",SYNO.SDS.ProxyServer._V("proxyserver","wpad_dhcp_enable_description"),function(d){if("yes"===d){SYNO.SDS.AppLaunch("SYNO.SDS.AdminCenter.Application",Ext.apply({fn:"SYNO.SDS.AdminCenter.DHCPServer.Main"},this.owner.findAppWindow().openConfig))}},this)}return},createWPADField:function(){var a={title:SYNO.SDS.ProxyServer._V("proxyserver","wpad_setting"),width:"570",height:"400",layout:"form",labelWidth:SYNO.SDS.ProxyServer.TEXTLABEL_WIDTH,items:[{xtype:"syno_checkbox",name:"wpad_enable",boxLabel:SYNO.SDS.ProxyServer._V("proxyserver","enable_wpad"),width:SYNO.SDS.ProxyServer.TEXTLABEL_LONG_WIDTH,listeners:{check:{scope:this,fn:function(c,b){if(!b){return}this.setStatusBusy();this.sendWebAPI({api:"SYNO.Core.Package",method:"get",version:1,params:{id:"WebStation",additional:["status"]},callback:this.WpadCheckHandler,scope:this})}}}},{xtype:"syno_displayfield",value:SYNO.SDS.ProxyServer._V("proxyserver","wpad_description")},{fieldLabel:SYNO.SDS.ProxyServer._V("proxyserver","wpad_interface"),xtype:"syno_combobox",name:"wpad_interface",allowBlank:false,displayField:"display_ifname",valueField:"ifname",width:SYNO.SDS.ProxyServer.TEXTFIELD_WIDTH},{xtype:"syno_displayfield",fieldLabel:SYNO.SDS.ProxyServer._V("proxyserver","wpad_interface_url"),name:"wpad_interface_url",cls:"selectabletext",readOnly:true}]};return new SYNO.ux.FieldSet(a)},createWirelessField:function(){var a={title:SYNO.SDS.ProxyServer._V("proxyserver","wireless_setting"),width:"570",height:"400",layout:"form",labelWidth:SYNO.SDS.ProxyServer.TEXTLABEL_WIDTH,items:[{xtype:"syno_checkbox",name:"transparent_proxy_enable",boxLabel:SYNO.SDS.ProxyServer._V("proxyserver","enable_wireless"),width:SYNO.SDS.ProxyServer.TEXTLABEL_LONG_WIDTH},{xtype:"syno_displayfield",value:SYNO.SDS.ProxyServer._V("proxyserver","wireless_description")}]};return new SYNO.ux.FieldSet(a)},getBridgeParams:function(){var a={api:"SYNO.Core.Network.LocalBridge",method:"list",params:{bridge_type:["local_bridge","guest_bridge"]},version:1};return a},getInterfacesParams:function(){var a={api:"SYNO.Core.Network.Interface",method:"list",version:1};return a},onPageActivate:function(){this.setStatusBusy();var a=[];a.push(this.getInterfacesParams());if("synology_bromolow_rc18015xs+"!==_D("unique")){a.push(this.getBridgeParams());this.getForm().findField("transparent_proxy_enable").disable()}this.sendWebAPI({params:{},compound:{stopwhenerror:true,params:a},callback:this.callbackHandler,scope:this})},callbackHandler:function(c,b,a){if(c||!b.has_fail){Ext.each(b.result,function(e,d){if(e.api=="SYNO.Core.Network.LocalBridge"&&e.success&&0!==e.data.length){Ext.each(e.data,function(g,f){if(g.status=="enabled"&&g.nat){this.getForm().findField("transparent_proxy_enable").enable()}},this)}else{if(e.api=="SYNO.Core.Network.Interface"&&e.success){this.interface_list=[];Ext.each(e.data,function(g,f){if(g.status==="connected"&&(g.type==="bond"||g.type==="lan"||g.type==="wan"||g.type==="ovseth"||g.type==="ovsbond")){var h=SYNO.SDS.Utils.Network.idToString.apply(this,[g.ifname,g.type]);this.interface_list.push([h,g.ifname])}},this);this.getForm().findField("wpad_interface").store=new Ext.data.ArrayStore({fields:["display_ifname","ifname"],data:this.interface_list})}}},this)}this.loadForm()},loadForm:function(){this.owner.addAjaxTask({single:true,autoJsonDecode:true,url:SYNO.SDS.ProxyServer.CGI_PATH,params:{action:"transparent_proxy_load"},method:"GET",scope:this,success:function(a,b){this.clearStatusBusy();if(a.success){this.getForm().setValues(a.item);if(Ext.isEmpty(a.item.wpad_interface)&&0<this.interface_list.length){this.getForm().findField("wpad_interface").setValue(this.interface_list[0][1])}}else{if(a.errinfo){this.owner.getMsgBox().alert(this.settingField.title,SYNO.SDS.ProxyServer._V(a.errinfo.sec,a.errinfo.key))}else{this.owner.getMsgBox().alert(this.settingField.title,SYNO.SDS.ProxyServer._V("error","error_unknown"))}}},failure:function(a,b){this.clearStatusBusy();this.owner.getMsgBox().alert(this.settingField.title,SYNO.SDS.ProxyServer._V("error","error_unknown"))}}).start()},onSave:function(){if(!this.checkDirty()){this.setStatusError({text:SYNO.SDS.ProxyServer._V("error","nochange_subject"),clear:true});return}if(!this.getForm().isValid()){this.setStatusError({text:SYNO.SDS.ProxyServer._V("common","forminvalid"),clear:true});return}this.sendWebAPI({api:"SYNO.Core.Network.DHCPServer",method:"get",params:{ifname:this.getForm().findField("wpad_interface").getValue()},version:1,callback:this.WPADDHCPServerCheckHandler,scope:this});this.applyForm()},checkDirty:function(){if(this.getForm().isDirty()){return true}return false},applyForm:function(){this.setStatusBusy({text:SYNO.SDS.ProxyServer._V("common","saving")});this.tmpSetting=this.getForm().getValues();this.owner.addAjaxTask({single:true,autoJsonDecode:true,url:SYNO.SDS.ProxyServer.CGI_PATH,params:Ext.encode(Ext.apply(this.tmpSetting,{action:"transparent_proxy_apply"})),method:"POST",scope:this,success:function(a,b){this.clearStatusBusy();if(a.success){this.setStatusOK();this.loadForm()}else{if(a.errinfo){this.owner.getMsgBox().alert(this.settingField.title,SYNO.SDS.ProxyServer._V(a.errinfo.sec,a.errinfo.key))}else{this.owner.getMsgBox().alert(this.settingField.title,SYNO.SDS.ProxyServer._V("error","error_unknown"))}}},failure:function(a,b){this.clearStatusBusy();this.owner.getMsgBox().alert(this.settingField.title,SYNO.SDS.ProxyServer._V("error","error_unknown"))}}).start()},onReset:function(){this.getForm().reset()},onPageDeactivate:function(){if(this.checkDirty()){return false}}});