import{c as a,r as e,q as l,v as s,N as t,B as d,e as o,y as i,z as r,x as m,D as p,ab as u,ak as n,al as c,a9 as f}from"./base-lib.js?v=1761009159";import{P as b,k as y}from"./utils-lib.js?v=1761009159";import{g as D}from"./useStore5.js?v=1761009159";import{g as _,a as g}from"./useMethod6.js?v=1761009159";import{A as h,B as v}from"./firewall.js?v=1761009159";import"./__commonjsHelpers__.js?v=1761009159";import"./column.js?v=1761009159";import"./index106.js?v=1761009159";import"./validator.js?v=1761009159";const I={class:"pl-[4.4rem] pt-[2.4rem] leading-8 text-small list-disc"},P={key:0},V=a({__name:"add-ip-rules",props:{compData:{default:()=>{}}},setup(a,{expose:V}){const j=a,{refs:{firewallInfo:w}}=D(),x=e({types:"accept",brief:"",address:"",id:"",chain:"INPUT",family:"ipv4",zone:"public"}),U=e(),N={address:[{trigger:["blur","change"],required:!0,message:"请输入指定IP"}]},z=a=>{"INPUT"===a&&(x.value.zone="public")};return l(()=>{j.compData.isEdit&&Object.assign(x.value,{types:j.compData.Strategy,brief:j.compData.brief,chain:j.compData.Chain,address:j.compData.Address,domain:j.compData.domain,id:j.compData.id||"",zone:j.compData.Zone||"public"})}),V({onConfirm:async a=>{await U.value.validate();const e={...x.value,operation:"add",strategy:x.value.types};j.compData.isEdit||delete e.id,await b({loading:"正在设置IP规则，请稍后...",request:j.compData.isEdit?h({new_data:JSON.stringify(e),old_data:JSON.stringify(j.compData)}):v(e),message:!0,success:()=>{j.compData.refreshFn(),_(),g(),a()}})}}),(a,e)=>{const l=y,b=u,D=n,_=c,g=f;return s(),t(g,{ref_key:"editIpRulesRef",ref:U,rules:N,disabled:a.formDisabled,model:i(x),class:"p-[2rem] addfrom"},{default:d(()=>[o(b,{label:"IP",prop:"address"},{default:d(()=>[o(l,{type:"textarea",modelValue:i(x).address,"onUpdate:modelValue":e[0]||(e[0]=a=>i(x).address=a),width:"24rem",resize:"none",rows:4,placeholder:"请输入IP地址",disabled:!!j.compData.selectOptions,clearable:""},null,8,["modelValue","disabled"])]),_:1}),o(b,{label:"策略"},{default:d(()=>[o(_,{modelValue:i(x).types,"onUpdate:modelValue":e[1]||(e[1]=a=>i(x).types=a),class:"!w-[24rem]"},{default:d(()=>[o(D,{label:"放行",value:"accept"}),o(D,{label:"禁止",value:"drop"})]),_:1},8,["modelValue"])]),_:1}),o(b,{label:"方向"},{default:d(()=>[o(_,{modelValue:i(x).chain,"onUpdate:modelValue":e[2]||(e[2]=a=>i(x).chain=a),class:"!w-[24rem]",onChange:z},{default:d(()=>[o(D,{label:"入站(默认)",value:"INPUT"}),o(D,{label:"出站",value:"OUTPUT"})]),_:1},8,["modelValue"])]),_:1}),o(b,{label:"备注"},{default:d(()=>[o(l,{modelValue:i(x).brief,"onUpdate:modelValue":e[3]||(e[3]=a=>i(x).brief=a),width:"24rem",placeholder:"可为空",clearable:""},null,8,["modelValue"])]),_:1}),r("ul",I,[e[4]||(e[4]=r("li",null,'支持添加IP：如果添加多个IP请用","隔开',-1)),e[5]||(e[5]=r("li",null,"支持添加IP段,如：192.168.0.0/24",-1)),e[6]||(e[6]=r("li",null,"支持添加IP范围,格式如：192.168.1.xx-192.168.1.xx，暂不支持跨网段范围",-1)),"firewalld"===i(w).type?(s(),m("li",P,"区域：非专业人士请勿修改，建议使用public")):p("",!0),e[7]||(e[7]=r("li",null,"此操作将重载防火墙，未持久化的 iptables 规则会清空，请先备份保存！",-1))])]),_:1},8,["disabled","model"])}}});export{V as default};
