import{P as t,aK as a,p as e,b as l,K as o,aj as s,Q as r}from"./utils-lib.js?v=1761009159";import{proxyTcpAction as i}from"./site.js?v=1761009159";import{r as n,o as p,e as c,C as u,F as m,c as d,g as _,q as b,a6 as g,v as y,N as v,y as w}from"./base-lib.js?v=1761009159";import{a as h,u as f}from"./column.js?v=1761009159";import{u as D}from"./useStore4.js?v=1761009159";import{i as x,b as j,g as P}from"./form-item.js?v=1761009159";import{j as k}from"./useController12.js?v=1761009159";const E=l();D();const C=n({}),L=n("proxy"),T=async()=>{try{const t=await i({handle:"port",listen_port:C.value.listen_port,protocol:C.value.protocol});if(!t.status)return void E.error(t.msg);C.value={...t.data,listen_port:String(t.data.listen_port).replace(" udp","")}}catch(t){a(t)}},O='一行一条配置，请以;结尾，例如：\nproxy_set_header Cookie "cookie_name=cookie_value";\nallow 192.168.1.0/24;\naccess_log /www/wwwlogs/xxx.log;',q=p({config:""}),z=[{content:"注意：一行一条配置，请以;结尾"},{content:()=>c(m,null,[u("案例："),c("br",null,null),u("重定向请求：return 301 /new-page;"),c("br",null,null),u("重写URL：rewrite ^/blog/(.*)$ /$1 break;"),c("br",null,null),u("文件上传限制：client_max_body_size 10M;"),c("br",null,null),u("处理特定http方法："),c("br",null,null),u("limit_except POST "),"{",u(" "),c("br",null,null),u("    allow 192.168.1.0/24;"),c("br",null,null),u("    deny all;"),c("br",null,null),"}",c("br",null,null),u("限制请求速率：limit_rate 100k;"),c("br",null,null)])},{content:"保存配置前请核对配置是否正确，错误的配置可能会导致反向代理无法正常访问"}],A=async e=>{try{let a={handle:"update",protocol:C.value.protocol,listen_port:C.value.listen_port,proxy_pass:C.value.proxy_pass,custom:q.config?q.config:" "};(await t({loading:"正在保存，请稍后...",request:i(a),message:!0})).status&&e()}catch(l){a(l)}},N=()=>{q.config=C.value.custom||""};n(),n();const S=p({loading:!1,type:"black",white:[],black:[]}),W=async a=>{const l=!!Array.isArray(a);await e({title:"".concat(l?"批量删除":"删除").concat("ipWhiteList"===L.value?"白":"黑","名单"),content:"".concat(l?"批量删除选中的ip，是否继续操作？":"删除".concat("ipWhiteList"===L.value?"白":"黑","名单【").concat(a.ip,"】，是否继续操作？"))});let o={listen_port:C.value.listen_port,protocol:C.value.protocol,handle:"ipWhiteList"===L.value?"delete_allow":"delete_deny",...l?{ip:a.map(t=>t.ip).join(" ")}:{ip:a.ip}};"ipWhiteList"===L.value?(o.allow=o.ip,delete o.ip):(o.deny=o.ip,delete o.ip);(await t({loading:"正在删除，请稍后...",request:i(o),message:!0})).status&&T()};n([h({key:"ip"}),{label:"IP",prop:"ip",minWidth:120},f([{title:"删除",onClick:t=>{W(t)}}])]);const U=n({types:S.type,address:""});n();const I=n(""),R=d({name:"AddProxyTcp",props:{compData:{type:Object,default:()=>({})}},setup(t,{expose:a}){var e,l,s,r;const{BtForm:i,submit:n}=o({data:{isEdit:t.compData.isEdit||!1,ps:(null==(e=t.compData.row)?void 0:e.ps)||"",listen_port:(null==(l=t.compData.row)?void 0:l.listen_port)||"",protocol:(null==(s=t.compData.row)?void 0:s.protocol)||"tcp",proxy_pass:(null==(r=t.compData.row)?void 0:r.proxy_pass)||""},options:a=>_(()=>[x("协议","protocol",[{label:"TCP",value:"tcp"},{label:"UDP",value:"udp"},{label:"TCP/UDP",value:"tcp/udp"}],{attrs:{disabled:t.compData.isEdit}}),j("代理端口","listen_port",{attrs:{placeholder:"请输入代理端口，例如：8764",width:"27rem",disabled:t.compData.isEdit},rules:[{required:!0,message:"请输入代理端口",trigger:"blur"},{trigger:["blur"],validator:(t,a,e)=>{const l=Number(a);Number.isNaN(l)||l<0||l>65535?e(new Error("请输入正确的端口")):e()}}]}),j("代理地址","proxy_pass",{attrs:{placeholder:"请输入代理地址，例如：192.168.100.20:22",width:"27rem"},rules:[{required:!0,message:"请输入代理地址",trigger:"blur"}]}),j("备注","ps",{attrs:{placeholder:"请输入备注",width:"27rem"}}),...t.compData.isEdit?[P("保存",{attrs:{type:"primary",class:"!ml-[10rem]",onClick:()=>{n()}}})]:[]]),submit:k});return a({onConfirm:async t=>{await n()&&t("close")}}),()=>c(i,{class:"p-[2rem]"},null)}}),B=d({__name:"setting",props:{compData:{type:Object,default:()=>({})}},setup(e){const l=e,{BtTabs:o}=s({type:"left-bg-card",value:L,options:[{label:"TCP/UDP代理",name:"proxy",lazy:!0,render:()=>c(R,{compData:{isEdit:!0,row:l.compData.row}},null)},{label:"自定义配置",name:"custom",lazy:!0,render:()=>r(()=>import("./setting-custom.js?v=1761009159"),__vite__mapDeps([]),import.meta.url)},{label:"日志",name:"siteLogs",lazy:!0,render:()=>r(()=>import("./setting-log.js?v=1761009159"),__vite__mapDeps([]),import.meta.url)}]});b(()=>{C.value=l.compData.row});const n=e=>{"siteLogs"!==e?T():(async()=>{try{const a=await t({request:i({handle:"log",listen_port:C.value.listen_port,protocol:C.value.protocol}),loading:"正在获取日志内容,请稍后..."});a.status&&(I.value=a.data.data||"暂无日志内容")}catch(e){a(e)}})()};return g(()=>{I.value="",L.value="proxy",C.value={},q.config="",S.white=[],S.black=[],U.value.address=""}),(t,a)=>(y(),v(w(o),{onChange:n}))}}),F=Object.freeze(Object.defineProperty({__proto__:null,default:B},Symbol.toStringTag,{value:"Module"}));export{O as a,z as b,q as c,N as i,I as l,A as o,C as r,F as s};
function __vite__mapDeps(indexes) {
  if (!__vite__mapDeps.viteFileDeps) {
    __vite__mapDeps.viteFileDeps = []
  }
  return indexes.map((i) => __vite__mapDeps.viteFileDeps[i])
}
