1import{o as Z,B as ee,h as l,e as a,w as C,M as r,g as x,Y as u,U as b,S as R,k as te,l as c,F as $,H as j,Q as ae,G as i,c as Y,D as d}from"./vendor-vue-B6E5vuob.js";import{c as m}from"./index-C6bK0kAJ.js";import"./vendor-i18n-M7zS2_Aq.js";const se={class:"space-y-4"},oe={class:"border border-gray-800 bg-gray-900 p-4"},le={class:"flex items-center justify-between flex-wrap gap-2"},re={class:"flex items-center gap-3"},de={key:0,class:"text-[10px] tracking-widest text-red-500 uppercase"},ne={class:"text-[10px] tracking-widest text-gray-600 uppercase"},pe={class:"border border-gray-800 bg-gray-900"},ie={class:"p-3 space-y-2 text-[12px]"},ue={class:"flex flex-wrap items-center gap-2"},ce={class:"text-gray-500"},ye={class:"flex flex-wrap items-center gap-2"},xe={key:0,class:"text-gray-500"},be={class:"text-gray-500"},ve=["disabled"],ge={key:0,class:"text-[10px] text-emerald-300 bg-black border border-gray-800 p-2 overflow-auto"},me={class:"border border-gray-800 bg-gray-900"},fe={class:"p-3 space-y-3"},_e={class:"flex items-center gap-2 flex-wrap"},he={class:"font-mono text-gray-500"},ke={key:0,class:"text-[10px] tracking-wider uppercase px-1 border border-cyan-800 text-cyan-400"},we={class:"text-gray-300"},Ve={key:1,class:"text-gray-600"},Ce={key:2,class:"text-gray-600"},Ue={key:3,class:"text-gray-600"},Te=["onClick","disabled"],Pe={key:0,class:"flex items-center gap-2 mt-1.5 flex-wrap"},Ae=["onUpdate:modelValue"],Le=["onUpdate:modelValue","placeholder"],Me=["onClick","disabled"],De=["onClick","disabled"],Se={key:1,class:"text-[11px] text-gray-500 mt-1"},$e={key:0,class:"text-[11px] text-gray-600 italic"},je={class:"border border-gray-800 bg-gray-900"},Ne={class:"px-4 py-2 border-b border-gray-800 flex items-center justify-between flex-wrap gap-2"},Be={class:"p-3 space-y-3 text-[12px]"},Ie={class:"flex items-center gap-3 flex-wrap"},Ee={class:"flex items-center gap-1.5 text-gray-300"},Oe={class:"text-[11px] text-gray-600"},Re={class:"text-[11px] text-gray-600 leading-relaxed"},Ye={class:"text-gray-400"},Fe={class:"space-y-2"},Ge={class:"text-gray-500"},ze=["onUpdate:modelValue"],He={class:"text-gray-500"},Qe=["onUpdate:modelValue"],qe={class:"text-gray-500"},Je=["onUpdate:modelValue"],Ke=["value","onInput"],We=["onUpdate:modelValue"],Xe=["onClick"],Ze={key:0,class:"text-[11px] text-gray-600 italic"},et={class:"flex items-center gap-2 flex-wrap pt-1"},tt=["placeholder"],at=["disabled"],st={class:"text-[11px] text-gray-500"},ot={key:0,class:"border border-gray-800 bg-gray-900"},lt={class:"p-3 space-y-1"},rt={class:"font-mono"},ut=Z({__name:"Mitigation",setup(dt){const A=i([]),f=i("");async function U(){var e;const t=await m.ddosList();t.ok&&(A.value=((e=t.data)==null?void 0:e.rules)??[])}ee(()=>{U(),N()});const p=i({action:"drop",ttl_secs:3600,proto:""}),L=i(""),F=i(""),y=i(!1);async function G(){y.value=!0,f.value="";try{const t=await m.ddosCreate(p.value);t.ok&&t.data?(L.value=t.data.nft,F.value=t.data.rule.id,await U(),f.value="è稿已çæ,确认åä¸å"):f.value=t.error||"çæå¤±è´¥"}catch(t){f.value=t instanceof Error?t.message:String(t)}finally{y.value=!1}}const _=i({}),h=i({}),k=i({});async function z(t){const e=(_.value[t.id]||"").split(",").map(o=>o.trim()).filter(Boolean);y.value=!0;try{const o=await m.ddosApply(t.id,h.value[t.id]||"",e);if(o.ok&&o.data){const s=o.data.applied.join(", "),g=Object.keys(o.data.failed||{}).join(", ");k.value[t.id]=`åºç¨: ${s||"æ "}${g?" · 失败: "+g:""}`,h.value[t.id]="",await U()}else k.value[t.id]=o.error||"失败"}catch(o){k.value[t.id]=o instanceof Error?o.message:String(o)}finally{y.value=!1}}async function H(t){y.value=!0;try{await m.ddosRevoke(t.id),await U()}finally{y.value=!1}}function Q(t){var e;h.value[t.id]="APPLY DDOS "+t.id,!_.value[t.id]&&((e=t.applied_pops)!=null&&e.length)&&(_.value[t.id]=t.applied_pops.join(","))}const v=i({enabled:!1,thresholds:[]}),M=i(!1),T=i(!1),D=i(900),S=i(""),w=i(""),P=i("");async function N(){const t=await m.ddosAutoGet();t.ok&&t.data&&(v.value={enabled:t.data.policy.enabled,thresholds:t.data.policy.thresholds??[]},M.value=t.data.env_armed,T.value=t.data.apply_armed,D.value=t.data.ttl_cap,S.value=t.data.confirm)}function q(){var t;((t=v.value).thresholds??(t.thresholds=[])).push({note:"",min_pps:2e5,max_rate_p
1ps:5e4,ttl_secs:D.value,target_pops:[]})}function J(t){var e;(e=v.value.thresholds)==null||e.splice(t,1)}function K(t){return(t.target_pops||[]).join(",")}function W(t,e){t.target_pops=e.split(",").map(o=>o.trim()).filter(Boolean)}async function X(){y.value=!0,w.value="";try{const t=await m.ddosAutoSet(v.value,P.value);t.ok&&t.data?(T.value=t.data.apply_armed,P.value="",w.value="å·²ä¿å",await N()):w.value=t.error||"ä¿å失败"}catch(t){w.value=t instanceof Error?t.message:String(t)}finally{y.value=!1}}function B(t){if(t.status!=="active"||!t.expires_at)return"";const e=t.expires_at-Math.floor(Date.now()/1e3);if(e<=0)return"å°æ";const o=Math.floor(e/60);return o>=60?`${Math.floor(o/60)}h${o%60}m`:`${o}m`}function I(t){const e=[];return t.src&&e.push("src "+t.src),t.dst&&e.push("dst "+t.dst),t.proto&&e.push(t.proto),t.dst_port&&e.push("dport "+t.dst_port),e.push("â "+(t.action==="rate"?`â¤${t.rate_pps}pps`:"drop")),e.join(" ")}const E=t=>t==="active"?"text-red-400":t==="draft"?"text-amber-400":"text-gray-500",V=Y(()=>A.value.filter(t=>t.status==="active"||t.status==="draft")),O=Y(()=>A.value.filter(t=>t.status!=="active"&&t.status!=="draft").slice(0,20));return(t,e)=>{var o;return d(),l("div",se,[a("div",oe,[a("div",le,[a("div",re,[a("span",{class:C(["w-1.5 h-1.5",V.value.length?"bg-red-500 animate-pulse":"bg-emerald-500"])},null,2),e[9]||(e[9]=a("h1",{class:"text-sm tracking-[0.2em] uppercase text-gray-200"},"ç¼è§£ · Mitigation",-1)),V.value.length?(d(),l("span",de,r(V.value.length)+" active",1)):x("",!0)]),a("div",ne,"å
é¨ nft · 人工确认 · TTL è¿æ · "+r(f.value),1)])]),a("div",pe,[e[17]||(e[17]=a("div",{class:"px-4 py-2 border-b border-gray-800 text-[10px] tracking-widest text-gray-600 uppercase"},"çæè§å(5 å
ç»)",-1)),a("div",ie,[a("div",ue,[u(a("input",{"onUpdate:modelValue":e[0]||(e[0]=s=>p.value.dst=s),placeholder:"ç®ç IP/åç¼",class:"w-44 bg-black border border-gray-700 px-1.5 py-0.5 text-gray-200 font-mono"},null,512),[[b,p.value.dst]]),u(a("input",{"onUpdate:modelValue":e[1]||(e[1]=s=>p.value.src=s),placeholder:"æº IP/åç¼(å¯ç©º)",class:"w-44 bg-black border border-gray-700 px-1.5 py-0.5 text-gray-200 font-mono"},null,512),[[b,p.value.src]]),u(a("select",{"onUpdate:modelValue":e[2]||(e[2]=s=>p.value.proto=s),class:"bg-black border border-gray-700 px-1 py-0.5 text-gray-300"},[...e[10]||(e[10]=[te('<option value="">ä»»æåè®®</option><option value="tcp">tcp</option><option value="udp">udp</option><option value="icmp">icmp</option><option value="icmpv6">icmpv6</option>',5)])],512),[[R,p.value.proto]]),a("label",ce,[e[11]||(e[11]=c("dport ",-1)),u(a("input",{"onUpdate:modelValue":e[3]||(e[3]=s=>p.value.dst_port=s),type:"number",class:"w-20 bg-black border border-gray-700 px-1 py-0.5 text-gray-200 text-right"},null,512),[[b,p.value.dst_port,void 0,{number:!0}]])])]),a("div",ye,[u(a("select",{"onUpdate:modelValue":e[4]||(e[4]=s=>p.value.action=s),class:"bg-black border border-gray-700 px-1 py-0.5 text-gray-300"},[...e[12]||(e[12]=[a("option",{value:"drop"},"drop",-1),a("option",{value:"rate"},"rate-limit",-1)])],512),[[R,p.value.action]]),p.value.action==="rate"?(d(),l("label",xe,[e[13]||(e[13]=c("éç ",-1)),u(a("input",{"onUpdate:modelValue":e[5]||(e[5]=s=>p.value.rate_pps=s),type:"number",class:"w-24 bg-black border border-gray-700 px-1 py-0.5 text-gray-200 text-right"},null,512),[[b,p.value.rate_pps,void 0,{number:!0}]]),e[14]||(e[14]=c(" pps",-1))])):x("",!0),a("label",be,[e[15]||(e[15]=c("TTL ",-1)),u(a("input",{"onUpdate:modelValue":e[6]||(e[6]=s=>p.value.ttl_secs=s),type:"number",class:"w-24 bg-black border border-gray-700 px-1 py-0.5 text-gray-200 text-right"},null,512),[[b,p.value.ttl_secs,void 0,{number:!0}]]),e[16]||(e[16]=c(" ç§",-1))]),a("button",{onClick:G,disabled:y.value,class:"border border-gray-700 px-3 py-0.5 text-gray-300 hover:border-emerald-600 hover:text-emerald-400 disabled:opacity-40"},"çæè稿",8,ve)]),L.value?(d(),l("pre",ge,"nft: "+r(L.value),1)):x("",!0)])]),a("div",me,[e[19]||(e[19]=a("div",{class:"px-4 py-2 border-b border-gray-800 text-[10px] tracking-widest text-gray-600 uppercase"},"æ´»å¨ / è稿è§å",-1)),a("div",fe,[(d(!0),l($,null,j(V.value,s=>{var g;return d(),l("div",{key:s.id,class:"border-b border-gray-800/40 pb-3 last:border-0 text-[12px]"},[a("div",_e,[a("span",he,r(s.id),1),a("span",{class:C(E(s.status))},r(s.status),3),s.origin==="auto"?(d(),l("span",ke,r(s.auto_applied?"auto·applied":"auto·draft"),1)):x("",!0),a("span",we,r(I(s)),1),s.anomaly_pps?(d(),l("span",Ve,"å¼å¸¸ ~"+r(Math.round(s.anomaly_pps))+"pps",1)):x("",!0),B(s)?(d(),l("span",Ce,"å© "+r(B(s)),1)):x("",!0),(g=s.applied_pops)!=null&&g.length?(d(),l("span",Ue,"@ "+r(s.applied_pops.join(",")),1)):x("",!0),e[18]||(e[18]=a("span",{class:"flex-1"},null,-1)),a("button",{onClick:n=>H(s),disabled:y.value,class:"text-gray-400 hover:text-red-300 border border-gray-700 px-2 py-0.5"},"æ¤é",8,Te)]),s.status==="draft"?(d(),l("div",Pe,[u(a("input",{"onUpdate:modelValue":n=>_.value[s.id]=n,placeholder:"ç®æ PoP(éå·åé, å¦ ctrl-01,pop-02)",class:"w-72 bg-black border border-gray-700 px-1.5 py-0.5 text-gray-200 font-mono"},null,8,Ae),[[b,_.value[s.id]]]),u(a("input",{"onUpdate:modelValue":n=>h.value[s.id]=n,placeholder:"APPLY DDOS "+s.id,class:"w-56 bg-black border border-gray-700 px-1.5 py-0.5 text-gray-200 font-mono"},null,8,Le),[[b,h.value[s.id]]]),a("button",{onClick:n=>Q(s),disabled:y.value,class:"border border-gray-700 px-2 py-0.5 text-gray-400 hover:text-gray-200"}
1,"å¡«å
确认串",8,Me),a("button",{onClick:n=>z(s),disabled:y.value,class:"border border-red-800 px-3 py-0.5 text-red-400 hover:bg-red-900/30 disabled:opacity-40"},"ä¸å",8,De)])):x("",!0),k.value[s.id]?(d(),l("div",Se,r(k.value[s.id]),1)):x("",!0)])}),128)),V.value.length?x("",!0):(d(),l("div",$e,"æ æ´»å¨è§åãå¼å¸¸æµéä¼å¨æ¤èªå¨çæè稿(é人工确认ä¸å,é¤éå·²å¼å¯èªå¨ç¼è§£çç¥)ã"))])]),a("div",je,[a("div",Ne,[e[20]||(e[20]=a("span",{class:"text-[10px] tracking-widest text-gray-600 uppercase"},"èªå¨ç¼è§£çç¥ Â· auto-mitigation(é»è®¤å
³é)",-1)),a("span",{class:C(["text-[10px] tracking-widest uppercase",T.value?"text-red-400":"text-gray-600"])},r(T.value?"â å·²æ¦è£
(èªå¨ä¸åçæ)":"â æªæ¦è£
(ä»
èªå¨è稿)"),3)]),a("div",Be,[a("div",Ie,[a("label",Ee,[u(a("input",{type:"checkbox","onUpdate:modelValue":e[7]||(e[7]=s=>v.value.enabled=s),class:"accent-red-600"},null,512),[[ae,v.value.enabled]]),e[21]||(e[21]=c(" å¯ç¨èªå¨ä¸å(ä½å±è§å) ",-1))]),a("span",{class:C(["text-[11px]",M.value?"text-emerald-400":"text-amber-400"])}," env NCN_DDOS_AUTOAPPLY="+r(M.value?"1 â":"0 â å³ä½¿å¯ç¨ä¹ä¸ä¼èªå¨ä¸å"),3),a("span",Oe,"TTL ä¸é "+r(D.value)+"s",1)]),a("p",Re,[e[22]||(e[22]=c(" ä»
",-1)),e[23]||(e[23]=a("b",{class:"text-gray-400"},"ä½å±",-1)),e[24]||(e[24]=c("è§å(éé,æ dst+åè®®+端å£ççªäºå
ç»)ä¼è¢«èªå¨ä¸å;å®½æ³ drop æ°¸è¿ä»
æè®®ã æ¯è½®æå¤èªå¨ä¸å 2 æ¡,ä¸å¼ºå¶ç TTLãå¼å¯éé®å
¥ç¡®è®¤ä¸² ",-1)),a("code",Ye,r(S.value),1),e[25]||(e[25]=c("ã ",-1))]),a("div",Fe,[(d(!0),l($,null,j(v.value.thresholds||[],(s,g)=>(d(),l("div",{key:g,class:"flex items-center gap-2 flex-wrap border border-gray-800 px-2 py-1.5"},[a("label",Ge,[e[26]||(e[26]=c("â¥",-1)),u(a("input",{"onUpdate:modelValue":n=>s.min_pps=n,type:"number",class:"w-24 bg-black border border-gray-700 px-1 py-0.5 text-gray-200 text-right"},null,8,ze),[[b,s.min_pps,void 0,{number:!0}]]),e[27]||(e[27]=c("pps",-1))]),a("label",He,[e[28]||(e[28]=c("éé",-1)),u(a("input",{"onUpdate:modelValue":n=>s.max_rate_pps=n,type:"number",class:"w-24 bg-black border border-gray-700 px-1 py-0.5 text-gray-200 text-right"},null,8,Qe),[[b,s.max_rate_pps,void 0,{number:!0}]]),e[29]||(e[29]=c("pps",-1))]),a("label",qe,[e[30]||(e[30]=c("TTL",-1)),u(a("input",{"onUpdate:modelValue":n=>s.ttl_secs=n,type:"number",class:"w-20 bg-black border border-gray-700 px-1 py-0.5 text-gray-200 text-right"},null,8,Je),[[b,s.ttl_secs,void 0,{number:!0}]]),e[31]||(e[31]=c("s",-1))]),a("input",{value:K(s),onInput:n=>W(s,n.target.value),placeholder:"ç®æ PoP(éå·åé)",class:"w-56 bg-black border border-gray-700 px-1.5 py-0.5 text-gray-200 font-mono"},null,40,Ke),u(a("input",{"onUpdate:modelValue":n=>s.note=n,placeholder:"夿³¨",class:"w-32 bg-black border border-gray-700 px-1.5 py-0.5 text-gray-300"},null,8,We),[[b,s.note]]),a("button",{onClick:n=>J(g),class:"text-gray-500 hover:text-red-300 border border-gray-700 px-2 py-0.5"},"å é¤",8,Xe)]))),128)),a("button",{onClick:q,class:"text-[11px] text-gray-400 hover:text-emerald-400 border border-gray-700 px-2 py-0.5"},"+ éå¼"),(o=v.value.thresholds)!=null&&o.length?x("",!0):(d(),l("div",Ze,"æªé
ç½®éå¼ â èªå¨ä¸åä¸ä¼è§¦å(ä»
èªå¨è稿)ã"))]),a("div",et,[u(a("input",{"onUpdate:modelValue":e[8]||(e[8]=s=>P.value=s),placeholder:S.value,class:"w-64 bg-black border border-gray-700 px-1.5 py-0.5 text-gray-200 font-mono"},null,8,tt),[[b,P.value]]),a("button",{onClick:X,disabled:y.value,class:"border border-red-800 px-3 py-0.5 text-red-400 hover:bg-red-900/30 disabled:opacity-40"},"ä¿åçç¥",8,at),a("span",st,r(w.value),1)])])]),O.value.length?(d(),l("div",ot,[e[32]||(e[32]=a("div",{class:"px-4 py-2 border-b border-gray-800 text-[10px] tracking-widest text-gray-600 uppercase"},"åå²(å·²è¿æ/æ¤é)",-1)),a("div",lt,[(d(!0),l($,null,j(O.value,s=>(d(),l("div",{key:s.id,class:"text-[11px] text-gray-600 flex items-center gap-2"},[a("span",rt,r(s.id),1),a("span",{class:C(E(s.status))},r(s.status),3),a("span",null,r(I(s)),1)]))),128))])])):x("",!0)])}}});
1export{ut 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.