1import{d as z,y as L,bo as O,E as k,o as I,c as F,b as c,w as l,F as R,a4 as D,u as m,g as T,t as r,bS as J,q as d,f as Y,av as G,n as H,aa as K,bR as Q,bl as b,V as W,J as X,_ as Z}from"./core-Cu1dlvv4.js";import{u as ee,h as ne,a as v,v as te,f as oe,M as ae}from"./index-mGgJqOFQ.js";import{u as se}from"./useAutoModal-CaK8mTFj.js";const le=z({__name:"ToolFirewall",async setup(pe){let g,B;const{t:o}=L(),P=se(),{protocols:p,upnpEnabled:f}=([g,B]=O(()=>b.fetch({uri:"firewall?raw"}).then(e=>({protocols:X({tcp:Object.entries(e.tcp).map(([n,t])=>({port:parseInt(n),...t})),udp:Object.entries(e.udp).map(([n,t])=>({port:parseInt(n),...t}))}),upnpEnabled:k(e.router_forwarding_upnp)}))),g=await g,B(),g),$=k(""),S=[{key:"port",label:o("port")},{key:"open",label:o("open")},{key:"upnp",label:o("upnp")},{key:"comment",label:o("words.comment")}],_=k({action:"open",port:0,protocol:"tcp",upnp:!1,comment:""}),V={action:{component:"SelectItem",label:o("action"),rules:{required:v},cProps:{id:"input-action",choices:[{value:"open",text:o("open")},{value:"close",text:o("close")}]}},port:{component:"InputItem",label:o("port"),rules:{number:v,integer:te,between:ae(0,65535)},cProps:{id:"input-port",placeholder:"0",type:"number"}},protocol:{component:"SelectItem",label:o("protocol"),rules:{required:v},cProps:{id:"input-protocol",choices:[{value:"tcp",text:o("tcp")},{value:"udp",text:o("udp")}]}},upnp:{component:"CheckboxItem",label:o("upnp"),rules:{required:v},cProps:{id:"upnp",labels:{true:"enabled",false:"disabled"}}},comment:{component:"InputItem",label:o("words.comment"),rules:{string:v},cProps:{id:"comment",placeholder:"",type:"text"}}},{v:q}=ee(_,V);async function x({action:e,port:n,protocol:t,upnp:a,comment:i}){if(!await P(o("confirm_firewall_"+e,{port:n,protocol:t})))return!1;const h=a?"&upnp":"";return b.put({uri:`firewall/${t}/${e}/${n}?comment=${i}${h}`,showModal:!1}).then(()=>!0)}async function M(){const e=f.value?"disable":"enable";await P(o("confirm_upnp_"+e))&&b.put({uri:"firewall/upnp/"+e}).then(()=>{b.refetch()}).catch(t=>{if(!(t instanceof W))throw t;$.value=t.message})}function U(e,n,t,a){const{open:i,upnp:u}=p[e][n];(t==="open"||a)&&(p[e][n].open=a),(t==="upnp"||!a)&&(p[e][n].upnp=a),x({action:t==="upnp"||a?"open":"close",protocol:e,...p[e][n]}).then(y=>{y||(p[e][n].open=i,p[e][n].upnp=u)})}function A(){x(_.value).then(e=>{e&&b.refetch()})}function N(e,n){const{open:t,upnp:a,port:i,comment:u}=p[e][n];_.value={action:t?"open":"close",port:i,protocol:e,upnp:a,comment:u},document.querySelector("#comment").focus()}function j(e){const n={port:"col-1 pe-3",open:"col-1",upnp:"col-1",comment:""};e.class=n[e.key]+" align-bottom"}return(e,n)=>{const t=G,a=Y,i=J,u=ne,h=oe,y=Q;return I(),F("div",null,[c(u,{title:e.$t("ports"),icon:"shield"},{default:l(()=>[(I(!0),F(R,null,D(m(p),(C,w)=>(I(),F("div",{key:w},[T("h5",null,r(e.$t(w)),1),c(i,{fields:S,items:C,small:"",striped:"",responsive:"","field-column-class":j},{"cell(port)":l(s=>[d(r(s.value),1)]),"cell()":l(s=>[c(t,{"model-value":s.value,switch:"","onUpdate:modelValue":E=>U(w,s.index,s.field.key,E)},{default:l(()=>[T("span",{class:H("btn btn-xs btn-"+(s.value?"danger":"success"))},r(e.$t(s.value?"close":"open")),3)]),_:2},1032,["model-value","onUpdate:modelValue"])]),"cell(comment)":l(s=>[d(r(s.value)+" ",1),c(a,{size:"xs",class:"me-2 float-end",onClick:E=>N(w,s.index)},{default:l(()=>[d(r(e.$t("words.edit")),1)]),_:2},1032,["onClick"])]),_:2},1032,["items"])]))),128))]),_:1},8,["title"]),c(h,{modelValue:_.value,"onUpdate:modelValue":n[0]||(n[0]=C=>_.value=C),fields:V,icon:"cogs",title:e.$t("operations"),validations:m(q),onSubmit:K(A,["prevent"])},null,8,["modelValue","title","validations"]),c(u,{title:e.$t("upnp"),icon:"exchange","body-text-variant":m(f)?"success":"danger"},{buttons:l(()=>[c(a,{variant:m(f)?"danger":"success",onClick:M},{default:l(()=>[d(r(e.$t(m(f)?"disable":"enable")),1)]),_:1},8,["variant"])]),default:l(()=>
1[d(r(e.$t(m(f)?"upnp_enabled":"upnp_disabled"))+" ",1),c(y,{state:$.value!==""?!1:null},{default:l(()=>[d(r($.value),1)]),_:1},8,["state"])]),_:1},8,["title","body-text-variant"])])}}}),ue=Z(le,[["__scopeId","data-v-1d600040"]]);export{ue as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.