← Back
Editing: add-port-rule.js
import{c as e,r as a,U as l,k as t,p as o,q as s,M as r,A as d,e as i,x as p,v as u,a_ as n,F as c,C as m,P as f,a9 as b,aj as y,S as g,a7 as _,ai as h}from"./base-lib.js?v=VERSION_NUMBER";import{u as w,jz as v,K as V,ag as P,k as D,W as k,j,e as U}from"./utils-lib.js?v=VERSION_NUMBER";import{_ as I}from"./index117.js?v=VERSION_NUMBER";import{w as S,v as A}from"./firewall.js?v=VERSION_NUMBER";import{a as T,g as x}from"./useMethod6.js?v=VERSION_NUMBER";import"./__commonjsHelpers__.js?v=VERSION_NUMBER";import"./validator.js?v=VERSION_NUMBER";import"./index104.js?v=VERSION_NUMBER";import"./column.js?v=VERSION_NUMBER";import"./useStore5.js?v=VERSION_NUMBER";const C=U(e({__name:"add-port-rule",props:{compData:{default:()=>{}}},setup(e,{expose:U}){const C=e,{payment:N}=w(),{authType:q}=N.value,O=a(!1),E=a(),F=l(C.compData.isEdit),J={title:"指定域名-功能介绍",ps:"系统防火墙将会放行/阻止设置域名所解析的A/AAAA记录",source:106,desc:["放行/阻止域名解析记录"],tabImgs:[{title:"防火墙禁止端口",imgSrc:"https://www.bt.cn/Public/new/plugin/introduce/firewall/specify_domain_1.png"},{title:"域名解析已生效",imgSrc:"https://www.bt.cn/Public/new/plugin/introduce/firewall/specify_domain_2.png"},{title:"设置效果",imgSrc:"https://www.bt.cn/Public/new/plugin/introduce/firewall/specify_domain_3.png"}]},M=t({protocol:"tcp",port:"",choose:"all",types:"accept",brief:"",address:"",domain:"",chain:"INPUT"}),R=[{content:"支持添加多个端口,如:80,88"},{content:"支持添加多个端口范围,如:80,88,90-99,110-120"},{content:"默认配置下防火墙无法管理Docker容器端口"},{content:"此操作将重载防火墙,未持久化的 iptables 规则会清空,请先备份保存!"}],z=[{title:"入站(默认)",key:"INPUT"},{title:"出站",key:"OUTPUT"}],H="请输入指定IP,多个IP请用,隔开或换行。例如192.168.1.1,192.168.1.2",K=[{label:"TCP",value:"tcp"},{label:"UDP",value:"udp"},{label:"TCP/UDP",value:"all"}],W=[{title:"所有IP",key:"all"},{title:"指定IP",key:"point"}],B=[{title:"放行",key:"accept"},{title:"禁止",key:"drop"}],G={port:[{validator:v,trigger:["blur"],required:!0}],address:[{trigger:["blur","change"],required:!0,message:"请输入指定IP"}],domain:[{trigger:["blur","change"],required:!0,message:"请输入指定域名"}]},L=e=>{try{const a=/[^0-9,-]/g;M.port=e.replace(a,"")}catch(a){}},Q=e=>{if(E.value.clearValidate(),"ltd"!==q&&"domain"===e)return M.choose="all",void(O.value=!0);M.choose=e};return o((()=>{var e,a;if(M.port=(null==(e=C.compData)?void 0:e.port)||"",C.compData.isEdit){const e="all"===(null==(a=C.compData)?void 0:a.Address);Object.assign(M,{protocol:C.compData.Protocol,port:C.compData.Port,types:C.compData.Strategy,brief:C.compData.brief,chain:C.compData.Chain,address:e?"":C.compData.Address,domain:C.compData.domain}),M.choose=e?"all":""===C.compData.domain?"point":"domain"}})),U({onConfirm:async e=>{await E.value.validate();const a=await(()=>{const e={...M,operation:"add",strategy:M.types};if("all"===e.choose&&delete e.address,e.brief||(e.brief=""),F.value&&(e.id=C.compData.id),F.value){const a={...C.compData};return a.noNps&&delete a.noNps,{old_data:JSON.stringify(a),new_data:JSON.stringify(e)}}return e})(),l="domain"===M.choose;await V({loading:"正在提交,请稍后...",message:!0,request:F.value?S(a,l):A(a,l),success:a=>{a.status&&e()}}),C.compData.refreshFn(),await T(),x(),F.value}}),(e,a)=>{const l=P,t=b,o=D,w=h,v=y,V=g,U=k,S=I,A=j,T=_;return s(),r(T,{ref_key:"editPortRulesRef",ref:E,rules:G,model:p(M),class:"p-[2rem] addfrom"},{default:d((()=>[i(t,{label:"协议"},{default:d((()=>[i(l,{modelValue:p(M).protocol,"onUpdate:modelValue":a[0]||(a[0]=e=>p(M).protocol=e),class:"!w-[24rem]",options:K},null,8,["modelValue"])])),_:1}),i(t,{label:"端口",prop:"port"},{default:d((()=>[i(o,{modelValue:p(M).port,"onUpdate:modelValue":a[1]||(a[1]=e=>p(M).port=e),width:"24rem",placeholder:"请输入端口",disabled:p(F),onInput:L},null,8,["modelValue","disabled"])])),_:1}),i(t,{label:"来源"},{default:d((()=>[i(v,{modelValue:p(M).choose,"onUpdate:modelValue":a[2]||(a[2]=e=>p(M).choose=e),onChange:Q,class:"!w-[24rem]"},{default:d((()=>[(s(),u(c,null,n(W,((e,a)=>i(w,{key:a,label:e.title,value:e.key},null,8,["label","value"]))),64))])),_:1},8,["modelValue"])])),_:1}),"point"===p(M).choose?(s(),r(t,{key:0,label:"指定IP",prop:"address"},{default:d((()=>[i(o,{type:"textarea",rows:3,width:"24rem",modelValue:p(M).address,"onUpdate:modelValue":a[3]||(a[3]=e=>p(M).address=e),placeholder:H,clearable:""},null,8,["modelValue","placeholder"])])),_:1})):m("",!0),i(t,{label:"策略"},{default:d((()=>[i(v,{modelValue:p(M).types,"onUpdate:modelValue":a[4]||(a[4]=e=>p(M).types=e),class:"!w-[24rem]"},{default:d((()=>[(s(),u(c,null,n(B,((e,a)=>i(w,{key:a,label:e.title,value:e.key},null,8,["label","value"]))),64))])),_:1},8,["modelValue"])])),_:1}),i(t,{label:"方向"},{default:d((()=>[i(v,{modelValue:p(M).chain,"onUpdate:modelValue":a[5]||(a[5]=e=>p(M).chain=e),class:"!w-[24rem]"},{default:d((()=>[(s(),u(c,null,n(z,(e=>i(w,{key:e.key,label:e.title,value:e.key},null,8,["label","value"]))),64))])),_:1},8,["modelValue"])])),_:1}),i(t,{label:"备注"},{default:d((()=>[i(V,{modelValue:p(M).brief,"onUpdate:modelValue":a[6]||(a[6]=e=>p(M).brief=e),class:"!w-[24rem] special-input",clearable:"",placeholder:"请填写备注,可为空"},null,8,["modelValue"])])),_:1}),i(U,{options:R,listStyle:"disc",class:"pl-[6rem] pt-[1.2rem]"}),i(A,{title:"指定域名-功能介绍",area:60,modelValue:p(O),"onUpdate:modelValue":a[7]||(a[7]=e=>f(O)?O.value=e:null)},{default:d((()=>[i(S,{data:J,class:"p-4rem"})])),_:1},8,["modelValue"])])),_:1},8,["model"])}}}),[["__scopeId","data-v-247d5224"]]);export{C as default};
Save File
Cancel