cfpilot 0.15.9 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/assets/control.js CHANGED
@@ -3,7 +3,7 @@ const __sfx=(()=>{const __t=new TextDecoder(),__c=new Map();return b=>{let v=__c
3
3
  `))),i){let F=""+D+__sfx("IFRyb2phbg==");r.push(F),T.push(F),n.push([__sfx("ICAtIG5hbWU6IA==")+z(F)+"",__sfx("ICAgIHR5cGU6IHRyb2phbg=="),__sfx("ICAgIHBhc3N3b3JkOiA=")+z(t.config.trojanPassword)+"",__sfx("ICAgIHNlcnZlcjog")+g.ip+"",__sfx("ICAgIHBvcnQ6IA==")+x+"",__sfx("ICAgIG5ldHdvcms6IHdz"),__sfx("ICAgIHRsczogdHJ1ZQ=="),__sfx("ICAgIHNuaTog")+t.domain+"",__sfx("ICAgIGNsaWVudC1maW5nZXJwcmludDog")+t.config.clientFingerprint+"",...u()," ws-opts:",__sfx("ICAgICAgcGF0aDog")+z(t.config.trojanPath)+""," headers:",` Host: ${t.domain}`].join(`
4
4
  `))}}});e.push(__sfx("IyBDRlBpbG90IOiHquWKqOeUn+aIkOiuoumYhQ==")),e.push(__sfx("bWl4ZWQtcG9ydDogNzg5MA==")),e.push(__sfx("YWxsb3ctbGFuOiBmYWxzZQ==")),e.push(__sfx("bW9kZTogcnVsZQ==")),e.push(__sfx("bG9nLWxldmVsOiBpbmZv")),e.push(__sfx("dW5pZmllZC1kZWxheTogdHJ1ZQ==")),e.push(__sfx("dGNwLWNvbmN1cnJlbnQ6IHRydWU=")),e.push(""),e.push("dns:"),e.push(__sfx("ICBlbmFibGU6IHRydWU=")),e.push(__sfx("ICBpcHY2OiBmYWxzZQ==")),e.push(__sfx("ICBlbmhhbmNlZC1tb2RlOiBmYWtlLWlw")),e.push(__sfx("ICBmYWtlLWlwLXJhbmdlOiAxOTguMTguMC4xLzE2")),e.push(" default-nameserver:"),e.push(" - 223.5.5.5"),e.push(" - 119.29.29.29"),e.push(" nameserver:"),e.push(" - https://223.5.5.5/dns-query"),e.push(" - https://dns.alidns.com/dns-query"),e.push(" fallback:"),e.push(" - 8.8.4.4"),e.push(" - 1.1.1.1"),e.push(" fallback-filter:"),e.push(__sfx("ICAgIGdlb2lwOiB0cnVl")),e.push(__sfx("ICAgIGdlb2lwLWNvZGU6IENO")),e.push(""),l&&(e.push(" nameserver-policy:"),e.push(` ${z(p)}: ${c?z(c):"https://223.5.5.5/dns-query"}`),e.push(""));let f=Me(t.routeProfile??"",{mainGroup:__sfx("Q0ZQaWxvdA=="),autoGroup:__sfx("6Ieq5Yqo6YCJ5oup")});if(e.push("proxies:"),n.length===0?e.push(" []"):e.push(...n),e.push(""),e.push(__sfx("cHJveHktZ3JvdXBzOg==")),e.push(__sfx("ICAtIG5hbWU6ICJDRlBpbG90Ig==")),e.push(__sfx("ICAgIHR5cGU6IHNlbGVjdA==")),e.push(" proxies:"),e.push(__sfx("ICAgICAgLSAi6Ieq5Yqo6YCJ5oupIg==")),e.push(__sfx("ICAgICAgLSAi5pWF6Zqc6L2s56e7Ig==")),o.v4.length>0&&e.push(__sfx("ICAgICAgLSAi5LyY6YCJSVB2NCI=")),o.v6.length>0&&e.push(__sfx("ICAgICAgLSAi5LyY6YCJSVB2NiI=")),r.length===0)e.push(" []");else for(let d of r)e.push(` - ${z(d)}`);if(r.length>0){e.push(""),e.push(__sfx("ICAtIG5hbWU6ICLoh6rliqjpgInmi6ki")),e.push(__sfx("ICAgIHR5cGU6IHVybC10ZXN0")),e.push(__sfx("ICAgIHVybDogImh0dHA6Ly93d3cuZ3N0YXRpYy5jb20vZ2VuZXJhdGVfMjA0Ig==")),e.push(__sfx("ICAgIGludGVydmFsOiAzMDA=")),e.push(__sfx("ICAgIHRvbGVyYW5jZTogNTA=")),e.push(" proxies:");for(let g of r)e.push(` - ${z(g)}`);e.push(""),e.push(__sfx("ICAtIG5hbWU6ICLmlYXpmpzovaznp7si")),e.push(__sfx("ICAgIHR5cGU6IGZhbGxiYWNr")),e.push(__sfx("ICAgIHVybDogImh0dHA6Ly93d3cuZ3N0YXRpYy5jb20vZ2VuZXJhdGVfMjA0Ig==")),e.push(__sfx("ICAgIGludGVydmFsOiAzMDA=")),e.push(" proxies:");for(let g of r)e.push(` - ${z(g)}`);let d=(g,h)=>{e.push(""),e.push(__sfx("ICAtIG5hbWU6IA==")+z(g)+""),e.push(__sfx("ICAgIHR5cGU6IHNlbGVjdA==")),e.push(" proxies:");for(let L of h)e.push(` - ${z(L)}`)};o.v4.length>0&&d(__sfx("5LyY6YCJSVB2NA=="),o.v4),o.v6.length>0&&d(__sfx("5LyY6YCJSVB2Ng=="),o.v6)}return f.groups.length>0&&(e.push(""),e.push(...f.groups)),e.push(""),e.push("rules:"),f.rules.length>0?(e.push(...f.rules),f.rules.some(d=>d.includes("MATCH,"))||e.push(__sfx("ICAtIE1BVENILENGUGlsb3Q="))):e.push(...Ue(__sfx("Q0ZQaWxvdA=="))),e.push(""),e.join(`
5
5
  `)}function jr(t){let e=[],n=[],r=Jt(t.config.subVariants,t.config,qe),o=r.some(c=>c===__sfx("dmxlc3Mtd3M=")),s=r.includes(__sfx("dHJvamFu")),a=t.config.ech,i=t.config.echHost.trim()||__sfx("Y2xvdWRmbGFyZS1lY2guY29t"),l=()=>a?{ech:{enabled:!0,query_server_name:i}}:{};for(let c of Gt(t)){let u=[];c.entries.forEach((f,d)=>{let g=`${c.name} ${ht(f,"vless",d,"")}`;for(let h of qt(f,t)){let L=t.ports.length>1?`:${h}`:"",T=`${g}${L}`,x=""+T+__sfx("IFRyb2phbg==");o&&u.push(T),s&&u.push(x),o&&e.push({type:__sfx("dmxlc3M="),tag:T,server:f.ip,server_port:h,uuid:t.config.uuid,tls:{enabled:!0,server_name:t.domain,insecure:!1,utls:{enabled:!0,fingerprint:t.config.clientFingerprint},...l()},transport:{type:"ws",path:t.config.wsPath,headers:{Host:t.domain}}}),s&&e.push({type:__sfx("dHJvamFu"),tag:x,server:f.ip,server_port:h,password:t.config.trojanPassword,tls:{enabled:!0,server_name:t.domain,insecure:!1,utls:{enabled:!0,fingerprint:t.config.clientFingerprint},...l()},transport:{type:"ws",path:t.config.trojanPath,headers:{Host:t.domain}}})}}),u.length>0&&n.push({tag:c.name,members:u})}e.push({type:"direct",tag:"direct"});for(let c of n)e.push({type:"selector",tag:c.tag,outbounds:c.members,default:c.members[0]});return e.push({type:"selector",tag:__sfx("Q0ZQaWxvdA=="),outbounds:n.length>0?n.map(c=>c.tag):["direct"],default:n.length>0?n[0].tag:"direct"}),JSON.stringify({log:{level:"info",timestamp:!0},dns:{servers:[{tag:"dns-out",address:"https://1.1.1.1/dns-query"},{tag:"local",address:"local"}],rules:[{domain_suffix:Qe,server:"local"}]},inbounds:[{type:"mixed",tag:"mixed-in",listen:__sfx("MTI3LjAuMC4x"),listen_port:2080}],outbounds:e,route:{rules:[{ip_is_private:!0,outbound:"direct"},{domain_suffix:Qe,outbound:"direct"}],final:__sfx("Q0ZQaWxvdA=="),auto_detect_interface:!0}},null,2)}function Vr(t){let e=[],n=Jt(t.config.subVariants,t.config);for(let r of Gt(t))r.entries.forEach((o,s)=>{let a=ht(o,__sfx("dmxlc3M="),s,r.name);for(let i of qt(o,t)){let l=t.ports.length>1?`:${i}`:"",p=`${a}${l}`,c={...o,port:i};for(let u of n)u===__sfx("dmxlc3Mtd3M=")?e.push(Ge(c,t,"ws",`${p} WS`)):u===__sfx("dmxlc3MteGh0dHA=")?e.push(Ge(c,t,__sfx("eGh0dHA="),""+p+__sfx("IFhIVFRQ"))):e.push(Mr(c,t,""+p+__sfx("IFRyb2phbg==")))}});return Se(e.join(`
6
- `))}function nn(t,e){let n=Qt(e.config.subName);switch(t){case __sfx("Y2xhc2g="):return{body:zr(e),contentType:"text/yaml; charset=utf-8",fileName:n};case"singbox":return{body:jr(e),contentType:"application/json; charset=utf-8",fileName:n};default:return{body:Vr(e),contentType:"text/plain; charset=utf-8",fileName:n}}}var $,mr,hr,Ve,Be,He,yr,br,Pr,Or,Lr,vr,_,Dr,Je,qe,Fr,Qe,Zt=k(()=>{"use strict";Oe();K();Xt();ze();$=443;mr=[__sfx("aXDlnLDlnYA="),__sfx("aXAg5Zyw5Z2A"),"ip",__sfx("5Zyw5Z2A"),__sfx("5pyN5Yqh5Zmo"),"server","host"],hr=[__sfx("56uv5Y+j"),"port"],Ve=[__sfx("5LiL6L296YCf5bqm"),__sfx("6YCf5bqm"),"speed","download"],Be=[__sfx("5bmz5Z2H5bu26L+f"),__sfx("5bu26L+f"),"latency","delay",__sfx("5ZON5bqU5pe26Ze0"),"rtt"],He=["colo",__sfx("5py65oi/"),__sfx("5pWw5o2u5Lit5b+D"),__sfx("5Zyw5Yy6"),"region"],yr=[__sfx("5Zu95a62"),"country",__sfx("5Zu95Yir")],br=[__sfx("5Z+O5biC"),"city"],Pr=["tls",__sfx("5piv5ZCm5pSv5oyBdGxz"),__sfx("5pSv5oyBdGxz")];Or={official:__sfx("5a6Y5pa55LyY6YCJSVA="),domain:__sfx("5LyY6YCJ5Z+f5ZCN"),manual:__sfx("5LyY6YCJ"),api:__sfx("6L+c56iLQVBJ"),csv:__sfx("5rWL6YCfQ1NW")};Lr=12e4,vr=32,_=new Map,Dr="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36";Je=[__sfx("dmxlc3Mtd3M="),__sfx("dmxlc3MteGh0dHA="),__sfx("dHJvamFu")];qe=[__sfx("dmxlc3Mtd3M="),__sfx("dHJvamFu")];Fr=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;Qe=".cn,qq.com,tencent.com,weixin.qq.com,baidu.com,bdstatic.com,bilibili.com,hdslb.com,taobao.com,tmall.com,jd.com,aliyun.com,alicdn.com,alipay.com,163.com,126.net,zhihu.com,weibo.com,sina.com.cn,youku.com,iqiyi.com,douyin.com,xiaohongshu.com,mi.com,huawei.com,csdn.net,gitee.com,cnblogs.com".split(",")});function Gr(t){let e="";for(let n=0;n<t.length;n++)e+=String.fromCharCode(t[n]);return btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function cn(t,e){let n=await crypto.subtle.importKey("raw",un.encode(t),{name:"HMAC",hash:"SHA-256"},!1,["sign"]),r=await crypto.subtle.sign("HMAC",n,un.encode(e));return Gr(new Uint8Array(r))}async function Nt(t){let e=(await t.get(Tt))?.trim();if(e)return e;let n=ln();return t instanceof W&&await t.put(Tt,n),n}async function fn(t){let e=ln();return t instanceof W?await t.put(Tt,e):await t.put(Tt,e),e}async function pn(t,e={}){let n=e.ttlDays??0,r=Math.floor((e.now??Date.now())/1e3),o=n>0?r+Math.round(n*86400):0,s=Math.floor(Math.random()*36**8).toString(36).padStart(8,"0"),a=`${te}.${o.toString(36)}.${s}`,i=(await cn(t,a)).slice(0,ee);return`${a}.${i}`}async function It(t,e,n=Date.now()){if(!t||!e)return{ok:!1,reason:"format"};let r=e.split(".");if(r.length!==4||r[0]!==te)return{ok:!1,reason:"format"};let o=r[1],s=r[2],a=r[3];if(!o||!s||a.length!==ee)return{ok:!1,reason:"format"};let i=Number.parseInt(o,36);if(!Number.isFinite(i)||i<0)return{ok:!1,reason:"format"};let l=(await cn(t,`${te}.${o}.${s}`)).slice(0,ee);return X(a,l)?i>0&&Math.floor(n/1e3)>=i?{ok:!1,reason:"expired",exp:i}:{ok:!0,exp:i}:{ok:!1,reason:"signature"}}var Tt,te,ee,un,ln,ne=k(()=>{"use strict";bt();K();Tt="SUB_TOKEN_SECRET",te="v1",ee=22,un=new TextEncoder;ln=()=>M(32)});function Zr(t){let e="";for(let n of t)e+=(n<16?"0":"")+n.toString(16);return e}function _r(t){if(!/^[0-9a-f]*$/.test(t)||t.length%2!==0)return null;let e=new Uint8Array(new ArrayBuffer(t.length/2));for(let n=0;n<e.length;n++)e[n]=Number.parseInt(t.slice(n*2,n*2+2),16);return e}async function Pn(t,e,n){let r=_r(e);if(!r)return null;let o=await crypto.subtle.importKey("raw",new TextEncoder().encode(t),"PBKDF2",!1,["deriveBits"]),s=await crypto.subtle.deriveBits({name:"PBKDF2",salt:r,iterations:n,hash:"SHA-256"},o,256);return Zr(new Uint8Array(s))}function wn(t){if(t.startsWith(`${oe}$`)){let[r,o,s,a]=t.split("$");if(r!==oe||!s||!a)return null;let i=Number.parseInt(o??"",10);return!Number.isFinite(i)||i<1||i>1e6?null:{scheme:"pbkdf2",salt:s,iterations:i,expected:a}}let[e,n]=t.split(":");return!e||!n?null:{scheme:"sha256",salt:e,iterations:0,expected:n}}async function Sn(t,e){return t.scheme==="pbkdf2"?await Pn(e,t.salt,t.iterations):await Mt(`${t.salt}:${e}`)}async function se(t,e){let n=await Pn(t,e,hn);return n?`${oe}$${hn}$${e}$${n}`:`${e}:${await Mt(`${e}:${t}`)}`}async function $r(t,e){let n=wn(t);if(!n)return!1;let r=await Sn(n,e);return r?X(r,n.expected):!1}function yn(t){return`/${t.trim().replace(/^\/+/,"")}`}async function Cn(t,e,n){let r=await t.get(St)??"",o=n&&n.trim()?yn(n):"";o?r!==o&&(r=o,await t.put(St,r)):r||(r=yn(`${Ae}-${we(6)}`),await t.put(St,r));let s=await t.get(it)??"",a=null,i=e&&e.trim()?e.trim():"";if(i){if(!s||!await $r(s,i)){let p=M(8);s=await se(i,p),await t.put(it,s)}await t.get(nt)&&await t.delete(nt)}else if(!s){let l=`cfp-${M(8)}`,p=M(8);s=await se(l,p),await t.put(it,s),a=l,await t.put(nt,l)}return{panelPath:r,passwordHash:s,generatedPassword:a}}async function En(t,e){let n=wn(t.passwordHash);if(!n)return{ok:!1,legacy:!1};let r=await Sn(n,e);if(!r)return{ok:!1,legacy:!1};let o=X(r,n.expected);return{ok:o,legacy:o&&n.scheme==="sha256"}}async function xn(t,e){let n=M(8);await t.put(it,await se(e,n))}async function An(t){await t.get(nt)&&await t.delete(nt)}function Rn(t){let e=t.headers.get("Cookie")??"",n={};for(let r of e.split(";")){let o=r.indexOf("=");if(o<0)continue;let s=r.slice(0,o).trim(),a=r.slice(o+1).trim();s&&(n[s]=decodeURIComponent(a))}return n}async function Tn(t){let e=M(24);return await t.put(`${wt}${e}`,JSON.stringify({ua:"",t:Date.now()}),bn),e}async function ie(t,e){let n=Rn(e)[kt];return n?!!await t.get(`${wt}${n}`):!1}function Nn(t,e=bn){return`${kt}=${t}; Path=/; HttpOnly; Secure; SameSite=Strict; Max-Age=${e}`}function In(){return`${kt}=; Path=/; HttpOnly; Secure; SameSite=Strict; Max-Age=0`}async function On(t,e){let n=Rn(e)[kt];n&&await t.delete(`${wt}${n}`)}async function kn(t){let e=M(20);return await t.put(`${Pt}${e}`,"1",qr),e}async function Ln(t,e){if(!e)return!1;let n=await t.get("SCANNER_TOKEN");return n&&X(n,e)?!0:await t.get(`${Pt}${e}`)?(await t.delete(`${Pt}${e}`),!0):!1}var kt,bn,qr,hn,oe,ae=k(()=>{"use strict";ft();K();kt=__sfx("Y2ZwaWxvdF9zZXNz"),bn=3600*24,qr=600,hn=3e4,oe="pbkdf2"});function vn(t){return Ce(t)}async function ue(t,e){if(V.config&&Date.now()-V.configAt<to)return V.config;let n=await Ne(t,e);return V.config=n,V.configAt=Date.now(),n}function Dn(){V.config=null,V.configAt=0}async function ce(t,e){if(V.auth&&Date.now()-V.authAt<eo)return V.auth;let n=await Cn(t,e.PANEL_PASSWORD,e.PANEL_PATH);return V.auth=n,V.authAt=Date.now(),n}function le(t){switch((t??"").toLowerCase()){case __sfx("Y2xhc2g="):case"mihomo":case"yaml":return __sfx("Y2xhc2g=");case"singbox":case"sing-box":case"json":return"singbox";case"v2ray":return"v2ray";case"base64":return"base64";default:return"base64"}}function yt(t){let e=String(t??"").trim();if(!e)return e;e=e.replace(/^[a-zA-Z][a-zA-Z0-9+.-]*:\/\//,""),e=e.replace(/[/?#].*$/,"");let n=e.lastIndexOf("@");if(n>=0&&(e=e.slice(n+1)),e.startsWith("[")){let r=e.indexOf("]");r>0&&(e=e.slice(1,r))}else{let r=e.indexOf(":");r>=0&&e.indexOf(":",r+1)<0&&(e=e.slice(0,r))}return e.trim()}function Fn(t){let e=(t??"").toLowerCase();return e?e.includes(__sfx("Y2xhc2g="))||e.includes("mihomo")||e.includes(__sfx("ZmxjbGFzaA=="))||e.includes(__sfx("Y2xhc2h4"))||e.includes("stash")?__sfx("Y2xhc2g="):e.includes("sing-box")||e.includes("singbox")?"singbox":e.includes("v2ray")||e.includes("v2rayng")||e.includes("shadowrocket")||e.includes("nekobox")||e.includes("surge")||e.includes("loon")||e.includes("quantumult")?"base64":null:null}var to,eo,V,Lt=k(()=>{"use strict";bt();ft();ae();to=15e3,eo=6e4,V={config:null,configAt:0,auth:null,authAt:0}});function fe(t,e,n){if(!t){n.push({field:e,message:""+e+__sfx("IOS4jeiDveS4uuepug==")});return}if(!t.startsWith("/")){n.push({field:e,message:""+e+__sfx("IOW/hemhu+S7pSAvIOW8gOWktA==")});return}if(t.length>128){n.push({field:e,message:""+e+__sfx("IOi/h+mVv++8iOacgOWkmiAxMjgg5a2X56ym77yJ")});return}/[\s\u0000-\u001f]/.test(t)&&n.push({field:e,message:""+e+__sfx("IOS4jeiDveWMheWQq+epuuagvOaIluaOp+WItuWtl+espg==")})}function tt(t,e,n,r,o){if(!Number.isFinite(t)){o.push({field:e,message:""+e+__sfx("IOW/hemhu+aYr+aVsOWtlw==")});return}(t<n||t>r)&&o.push({field:e,message:""+e+__sfx("IOW/hemhu+WcqCA=")+n+" ~ "+r+__sfx("IOS5i+mXtO+8iOW9k+WJjSA=")+t+")"})}function vt(t,e,n){let r=t.split(/\r?\n|,/).map(o=>o.trim()).filter(Boolean);if(r.length>20){n.push({field:e,message:""+e+__sfx("IOacgOWkmiAyMCDmnaHvvIjlvZPliY0g")+r.length+")"});return}for(let o of r)if(!ro.test(o)){n.push({field:e,message:""+e+__sfx("IOmHjOacieaXoOazleivhuWIq+eahOadoeebru+8mg==")+o.slice(0,40)+""});return}}function Un(t,e,n){let r=t.split(/\r?\n|,/).map(o=>o.trim()).filter(Boolean);if(r.length>10){n.push({field:e,message:""+e+__sfx("IOacgOWkmiAxMCDmnaHvvIjlvZPliY0g")+r.length+")"});return}for(let o of r)if(!/^https?:\/\/\S+$/i.test(o)){n.push({field:e,message:""+e+__sfx("IOW/hemhu+aYryBodHRwKHMpIOWcsOWdgO+8mg==")+o.slice(0,40)+""});return}}function pe(t){let e=[],n=o=>Object.prototype.hasOwnProperty.call(t,o);n("wsPath")&&fe(String(t.wsPath??""),"wsPath",e),n(__sfx("dHJvamFuUGF0aA=="))&&fe(String(t.trojanPath??""),__sfx("dHJvamFuUGF0aA=="),e),n(__sfx("eGh0dHBQYXRo"))&&fe(String(t.xhttpPath??""),__sfx("eGh0dHBQYXRo"),e);let r=["wsPath",__sfx("dHJvamFuUGF0aA=="),__sfx("eGh0dHBQYXRo")].filter(o=>n(o)).map(o=>`${o}=${String(t[o]??"")}`);if(r.length>=2){let o=r.map(s=>s.slice(s.indexOf("=")+1));new Set(o).size!==o.length&&e.push({field:"paths",message:__sfx("d3NQYXRoIC8gdHJvamFuUGF0aCAvIHhodHRwUGF0aCDkuI3og73ph43lpI0=")})}if(n("subDomain")){let o=String(t.subDomain??"").trim();o&&(!no.test(o)||o.includes("/"))&&e.push({field:"subDomain",message:__sfx("c3ViRG9tYWluIOW/hemhu+aYr+WQiOazleS4u+acuuWQje+8iOS4jeWQq+WNj+iuruS4jui3r+W+hO+8iQ==")})}if(n(__sfx("cHJveHlJcA=="))&&vt(String(t.proxyIp??""),__sfx("cHJveHlJcA=="),e),n(__sfx("c29ja3M1"))&&vt(String(t.socks5??""),__sfx("c29ja3M1"),e),n("httpProxy")&&vt(String(t.httpProxy??""),"httpProxy",e),n("relayPool")&&vt(String(t.relayPool??""),"relayPool",e),n("officialCount")&&tt(Number(t.officialCount),"officialCount",1,200,e),n("domainCount")&&tt(Number(t.domainCount),"domainCount",1,200,e),n("maxNodes")&&tt(Number(t.maxNodes),"maxNodes",0,500,e),n("dls")&&tt(Number(t.dls),"dls",0,1e3,e),n("maxLatency")&&tt(Number(t.maxLatency),"maxLatency",0,1e4,e),n("dataBudgetMB")&&tt(Number(t.dataBudgetMB),"dataBudgetMB",0,102400,e),n("subTokenTtlDays")&&tt(Number(t.subTokenTtlDays),"subTokenTtlDays",0,3650,e),n("subPorts")){let o=String(t.subPorts??"").trim();if(o){let s=o.split(/[\n,;\s]+/).filter(Boolean);s.length>6?e.push({field:"subPorts",message:__sfx("c3ViUG9ydHMg5pyA5aSaIDYg5Liq56uv5Y+j")}):s.every(a=>/^\d{1,5}$/.test(a)&&Number(a)>=1&&Number(a)<=65535)||e.push({field:"subPorts",message:__sfx("c3ViUG9ydHMg6YeM5q+P5Liq56uv5Y+j6YO95b+F6aG75pivIDF+NjU1MzUg55qE5pWw5a2X")})}}if(n("subName")){let o=String(t.subName??"");o.length>40&&e.push({field:"subName",message:__sfx("c3ViTmFtZSDmnIDlpJogNDAg5a2X56ym")}),/[\u0000-\u001f]/.test(o)&&e.push({field:"subName",message:__sfx("c3ViTmFtZSDkuI3og73ljIXlkKvmjqfliLblrZfnrKY=")})}if(n("addApi")&&Un(String(t.addApi??""),"addApi",e),n("addCsv")&&Un(String(t.addCsv??""),"addCsv",e),n("uuid")){let o=String(t.uuid??"").trim();o&&!/^[0-9a-fA-F]{8}-?[0-9a-fA-F]{4}-?[0-9a-fA-F]{4}-?[0-9a-fA-F]{4}-?[0-9a-fA-F]{12}$/.test(o)&&e.push({field:"uuid",message:__sfx("dXVpZCDlv4XpobvmmK/moIflh4YgVVVJRO+8iDM2IOS9je+8jOWPr+W4pui/nuWtl+espu+8iQ==")})}if(n("poolCountries")){let o=String(t.poolCountries??"").trim();if(o){let s=o.split(/[\n,;\s]+/).filter(Boolean);s.length>30?e.push({field:"poolCountries",message:__sfx("cG9vbENvdW50cmllcyDmnIDlpJogMzAg5Liq5Zu95a62L+WcsOWMug==")}):s.every(a=>/^[A-Za-z]{2,3}$/.test(a))||e.push({field:"poolCountries",message:__sfx("cG9vbENvdW50cmllcyDlj6rog73mmK8gMn4zIOS9jeWtl+avjeS7o+eggQ==")})}}if(n("udpDnsEndpoint")){let o=String(t.udpDnsEndpoint??"").trim();o&&!/^https:\/\/\S+$/i.test(o)&&e.push({field:"udpDnsEndpoint",message:__sfx("dWRwRG5zRW5kcG9pbnQg5b+F6aG75pivIGh0dHBzIOWcsOWdgA==")})}return e}function de(t){return t.length===0?"":t.length===1?t[0].message:"有 "+t.length+__sfx("IOmhuemFjee9ruS4jeWQiOazle+8mg==")+t.map(e=>e.message).join("\uFF1B")+""}var no,ro,Mn=k(()=>{"use strict";no=/^(?=.{1,253}$)([A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?)(\.[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?)*$/,ro=/^(?:(?:socks5|socks|socks5h|http|https):\/\/)?(?:[^\s@/]+@)?(?:\[[0-9a-fA-F:]+\]|[A-Za-z0-9._-]+)(?::\d{1,5})?$/});function Vn(t,e=Date.now()){let n={};for(let o of jn){let s=t[o];s!==void 0&&(n[o]=s)}let r=oo.map(o=>({field:o.field,reason:o.reason}));for(let o of[__sfx("c29ja3M1"),"httpProxy"]){let s=String(t[o]??"");if(!s){n[o]="";continue}if(s.includes("@")){r.push({field:o,reason:__sfx("5ZCr55So5oi35ZCNL+WPo+S7pO+8jOmcgOaJi+W3pemHjeaWsOWhq+WGmQ==")});continue}n[o]=s}return{schemaVersion:1,exportedAt:new Date(e).toISOString(),config:n,omitted:r}}function Bn(t){let e=new Set([...jn.map(String),__sfx("c29ja3M1"),"httpProxy"]),n={};for(let[r,o]of Object.entries(t))e.has(r)&&(n[r]=o);return n}function zn(t){if(t==null)return"\uFF08\u7A7A\uFF09";if(typeof t=="string"){let e=t.replace(/\s+/g," ").trim();return e.length>60?`${e.slice(0,60)}\u2026`:e||"\uFF08\u7A7A\uFF09"}return String(t)}function Hn(t,e){let n=[];for(let[r,o]of Object.entries(e)){let s=t[r];String(s)!==String(o)&&n.push({field:r,from:zn(s),to:zn(o)})}return n}var jn,oo,Xn=k(()=>{"use strict";jn=["poolOfficial","officialCount","poolDomain","domainCount","poolManual","poolCountries","add","dls","maxLatency","maxNodes",__sfx("cHJveHlJcA=="),"relayPool","useBuiltinRelay","proxyMode","nat64","concurrentDial","dataBudgetMB","resolvePreferred","aggressiveRedial",__sfx("ZW5hYmxlVHJvamFu"),__sfx("ZW5hYmxlWGh0dHA="),"subProtocol","subTransport","subVariants","subName","subPorts","clientFingerprint","ech","echHost","echDns","tlsFragment","tlsFragmentSize","tlsFragmentDelay","subToken","subTokenTtlDays","unlockProbe","udpDns","udpDnsEndpoint"],oo=[{field:"uuid",reason:__sfx("5YWl56uZ5Yet5o2u")},{field:__sfx("dHJvamFuUGFzc3dvcmQ="),reason:__sfx("5YWl56uZ5Yet5o2u")},{field:"wsPath",reason:__sfx("5a6e5L6L5qCH6K+G77yI6K6i6ZiF6ZO+5o6l6YeM5Y+v6KeB77yM5a+85Ye65Y2z5pq06Zyy5YWl5Y+j77yJ")},{field:__sfx("dHJvamFuUGF0aA=="),reason:__sfx("5a6e5L6L5qCH6K+G")},{field:__sfx("eGh0dHBQYXRo"),reason:__sfx("5a6e5L6L5qCH6K+G")},{field:"subDomain",reason:__sfx("5a6e5L6L5qCH6K+G")},{field:"addApi",reason:__sfx("VVJMIOWPr+iDveWQq+engeaciSB0b2tlbg==")},{field:"addCsv",reason:__sfx("VVJMIOWPr+iDveWQq+engeaciSB0b2tlbg==")}]});function Kn(){return new Response(JSON.stringify({build:ge,version:me,ts:Date.now()}),{status:200,headers:{"Content-Type":"application/json","Cache-Control":"no-store","Access-Control-Allow-Origin":"*"}})}var ge,me,Yn,he=k(()=>{"use strict";ge="86b1357-d5c0a377",me=__sfx("MC4xNS45"),Yn=__sfx("L19fY2ZwX3ZlcnNpb24=")});var Gn={};er(Gn,{API_PREFIX:()=>ye,getScannerToken:()=>lo,handleApi:()=>fo,pruneLoginFailures:()=>Jn});function ao(t){return t.headers.get("CF-Connecting-IP")??t.headers.get("x-forwarded-for")?.split(",")[0]?.trim()??"unknown"}function uo(t,e){let n=st.get(t);return n?e>=n.resetAt?(st.delete(t),!1):n.count>=so:!1}function Jn(t,e,n=io){if(!(t.size<n)){for(let[r,o]of t)e>=o.resetAt&&t.delete(r);for(;t.size>=n;){let r=t.keys().next().value;if(r===void 0)break;t.delete(r)}}}function co(t,e){let n=st.get(t);if(!n||e>=n.resetAt){Jn(st,e),st.set(t,{count:1,resetAt:e+Wn});return}n.count+=1}function E(t,e=200,n={}){return new Response(JSON.stringify(t),{status:e,headers:{"Content-Type":"application/json; charset=utf-8","Cache-Control":"no-store",...n}})}function R(t,e){return E({ok:!1,error:t},e)}async function lo(t,e){let n=await t.get(Vt);if(n)return n;if(typeof e.SCANNER_TOKEN=="string"&&e.SCANNER_TOKEN)return e.SCANNER_TOKEN;let r=M(24);return await t.put(Vt,r),r}async function fo(t,e,n){if(!e.pathname.startsWith(ye))return null;let{store:r,env:o,config:s,auth:a}=n,i=e.pathname.slice(ye.length)||"/",l=t.method.toUpperCase();if(i==="/session"&&l==="GET"){let c=await ie(r,t);return E({ok:!0,authenticated:c,panelPath:a.panelPath})}if(i==="/login"&&l==="POST"){let c="";try{let h=await t.json();c=String(h.password??"")}catch{return R(__sfx("6K+35rGC5L2T6Kej5p6Q5aSx6LSl"),400)}if(!c)return R(__sfx("6K+36L6T5YWl5a+G56CB"),400);let u=ao(t),f=Date.now();if(uo(u,f))return new Response(JSON.stringify({ok:!1,error:__sfx("5bCd6K+V6L+H5LqO6aKR57mB77yM6K+356iN5ZCO5YaN6K+V")}),{status:429,headers:{"Content-Type":"application/json; charset=utf-8","Cache-Control":"no-store","Retry-After":String(Math.ceil(Wn/1e3))}});let d=await En(a,c);if(!d.ok)return co(u,f),R(__sfx("5a+G56CB6ZSZ6K+v"),401);st.delete(u),d.legacy&&await xn(r,c).catch(()=>{}),await An(r).catch(()=>{});let g=await Tn(r);return E({ok:!0},200,{"Set-Cookie":Nn(g)})}if(i==="/logout"&&l==="POST")return await On(r,t),E({ok:!0},200,{"Set-Cookie":In()});if(i==="/preferred-ips"&&l==="POST"){let c=t.headers.get("Authorization")??"",u=c.startsWith("Bearer ")?c.slice(7).trim():c.trim();if(!await Ln(r,u))return R(__sfx("VG9rZW4g5qCh6aqM5aSx6LSl"),401);let d;try{d=await t.json()}catch{return R(__sfx("6K+35rGC5L2T6Kej5p6Q5aSx6LSl"),400)}let h=(Array.isArray(d.ips)?d.ips.map(S=>String(S)):[]).map(S=>S.trim()).filter(S=>S.length>0),L=d.mode==="append",T=S=>S.split("#")[0].trim().replace(/^\[([^\]]+)\]:(\d+)$/,"$1:$2"),x=await r.get(H),v,D=h.length;if(L){let S=(x??"").split(`
6
+ `))}function nn(t,e){let n=Qt(e.config.subName);switch(t){case __sfx("Y2xhc2g="):return{body:zr(e),contentType:"text/yaml; charset=utf-8",fileName:n};case"singbox":return{body:jr(e),contentType:"application/json; charset=utf-8",fileName:n};default:return{body:Vr(e),contentType:"text/plain; charset=utf-8",fileName:n}}}var $,mr,hr,Ve,Be,He,yr,br,Pr,Or,Lr,vr,_,Dr,Je,qe,Fr,Qe,Zt=k(()=>{"use strict";Oe();K();Xt();ze();$=443;mr=[__sfx("aXDlnLDlnYA="),__sfx("aXAg5Zyw5Z2A"),"ip",__sfx("5Zyw5Z2A"),__sfx("5pyN5Yqh5Zmo"),"server","host"],hr=[__sfx("56uv5Y+j"),"port"],Ve=[__sfx("5LiL6L296YCf5bqm"),__sfx("6YCf5bqm"),"speed","download"],Be=[__sfx("5bmz5Z2H5bu26L+f"),__sfx("5bu26L+f"),"latency","delay",__sfx("5ZON5bqU5pe26Ze0"),"rtt"],He=["colo",__sfx("5py65oi/"),__sfx("5pWw5o2u5Lit5b+D"),__sfx("5Zyw5Yy6"),"region"],yr=[__sfx("5Zu95a62"),"country",__sfx("5Zu95Yir")],br=[__sfx("5Z+O5biC"),"city"],Pr=["tls",__sfx("5piv5ZCm5pSv5oyBdGxz"),__sfx("5pSv5oyBdGxz")];Or={official:__sfx("5a6Y5pa55LyY6YCJSVA="),domain:__sfx("5LyY6YCJ5Z+f5ZCN"),manual:__sfx("5LyY6YCJ"),api:__sfx("6L+c56iLQVBJ"),csv:__sfx("5rWL6YCfQ1NW")};Lr=12e4,vr=32,_=new Map,Dr="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36";Je=[__sfx("dmxlc3Mtd3M="),__sfx("dmxlc3MteGh0dHA="),__sfx("dHJvamFu")];qe=[__sfx("dmxlc3Mtd3M="),__sfx("dHJvamFu")];Fr=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;Qe=".cn,qq.com,tencent.com,weixin.qq.com,baidu.com,bdstatic.com,bilibili.com,hdslb.com,taobao.com,tmall.com,jd.com,aliyun.com,alicdn.com,alipay.com,163.com,126.net,zhihu.com,weibo.com,sina.com.cn,youku.com,iqiyi.com,douyin.com,xiaohongshu.com,mi.com,huawei.com,csdn.net,gitee.com,cnblogs.com".split(",")});function Gr(t){let e="";for(let n=0;n<t.length;n++)e+=String.fromCharCode(t[n]);return btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function cn(t,e){let n=await crypto.subtle.importKey("raw",un.encode(t),{name:"HMAC",hash:"SHA-256"},!1,["sign"]),r=await crypto.subtle.sign("HMAC",n,un.encode(e));return Gr(new Uint8Array(r))}async function Nt(t){let e=(await t.get(Tt))?.trim();if(e)return e;let n=ln();return t instanceof W&&await t.put(Tt,n),n}async function fn(t){let e=ln();return t instanceof W?await t.put(Tt,e):await t.put(Tt,e),e}async function pn(t,e={}){let n=e.ttlDays??0,r=Math.floor((e.now??Date.now())/1e3),o=n>0?r+Math.round(n*86400):0,s=Math.floor(Math.random()*36**8).toString(36).padStart(8,"0"),a=`${te}.${o.toString(36)}.${s}`,i=(await cn(t,a)).slice(0,ee);return`${a}.${i}`}async function It(t,e,n=Date.now()){if(!t||!e)return{ok:!1,reason:"format"};let r=e.split(".");if(r.length!==4||r[0]!==te)return{ok:!1,reason:"format"};let o=r[1],s=r[2],a=r[3];if(!o||!s||a.length!==ee)return{ok:!1,reason:"format"};let i=Number.parseInt(o,36);if(!Number.isFinite(i)||i<0)return{ok:!1,reason:"format"};let l=(await cn(t,`${te}.${o}.${s}`)).slice(0,ee);return X(a,l)?i>0&&Math.floor(n/1e3)>=i?{ok:!1,reason:"expired",exp:i}:{ok:!0,exp:i}:{ok:!1,reason:"signature"}}var Tt,te,ee,un,ln,ne=k(()=>{"use strict";bt();K();Tt="SUB_TOKEN_SECRET",te="v1",ee=22,un=new TextEncoder;ln=()=>M(32)});function Zr(t){let e="";for(let n of t)e+=(n<16?"0":"")+n.toString(16);return e}function _r(t){if(!/^[0-9a-f]*$/.test(t)||t.length%2!==0)return null;let e=new Uint8Array(new ArrayBuffer(t.length/2));for(let n=0;n<e.length;n++)e[n]=Number.parseInt(t.slice(n*2,n*2+2),16);return e}async function Pn(t,e,n){let r=_r(e);if(!r)return null;let o=await crypto.subtle.importKey("raw",new TextEncoder().encode(t),"PBKDF2",!1,["deriveBits"]),s=await crypto.subtle.deriveBits({name:"PBKDF2",salt:r,iterations:n,hash:"SHA-256"},o,256);return Zr(new Uint8Array(s))}function wn(t){if(t.startsWith(`${oe}$`)){let[r,o,s,a]=t.split("$");if(r!==oe||!s||!a)return null;let i=Number.parseInt(o??"",10);return!Number.isFinite(i)||i<1||i>1e6?null:{scheme:"pbkdf2",salt:s,iterations:i,expected:a}}let[e,n]=t.split(":");return!e||!n?null:{scheme:"sha256",salt:e,iterations:0,expected:n}}async function Sn(t,e){return t.scheme==="pbkdf2"?await Pn(e,t.salt,t.iterations):await Mt(`${t.salt}:${e}`)}async function se(t,e){let n=await Pn(t,e,hn);return n?`${oe}$${hn}$${e}$${n}`:`${e}:${await Mt(`${e}:${t}`)}`}async function $r(t,e){let n=wn(t);if(!n)return!1;let r=await Sn(n,e);return r?X(r,n.expected):!1}function yn(t){return`/${t.trim().replace(/^\/+/,"")}`}async function Cn(t,e,n){let r=await t.get(St)??"",o=n&&n.trim()?yn(n):"";o?r!==o&&(r=o,await t.put(St,r)):r||(r=yn(`${Ae}-${we(6)}`),await t.put(St,r));let s=await t.get(it)??"",a=null,i=e&&e.trim()?e.trim():"";if(i){if(!s||!await $r(s,i)){let p=M(8);s=await se(i,p),await t.put(it,s)}await t.get(nt)&&await t.delete(nt)}else if(!s){let l=`cfp-${M(8)}`,p=M(8);s=await se(l,p),await t.put(it,s),a=l,await t.put(nt,l)}return{panelPath:r,passwordHash:s,generatedPassword:a}}async function En(t,e){let n=wn(t.passwordHash);if(!n)return{ok:!1,legacy:!1};let r=await Sn(n,e);if(!r)return{ok:!1,legacy:!1};let o=X(r,n.expected);return{ok:o,legacy:o&&n.scheme==="sha256"}}async function xn(t,e){let n=M(8);await t.put(it,await se(e,n))}async function An(t){await t.get(nt)&&await t.delete(nt)}function Rn(t){let e=t.headers.get("Cookie")??"",n={};for(let r of e.split(";")){let o=r.indexOf("=");if(o<0)continue;let s=r.slice(0,o).trim(),a=r.slice(o+1).trim();s&&(n[s]=decodeURIComponent(a))}return n}async function Tn(t){let e=M(24);return await t.put(`${wt}${e}`,JSON.stringify({ua:"",t:Date.now()}),bn),e}async function ie(t,e){let n=Rn(e)[kt];return n?!!await t.get(`${wt}${n}`):!1}function Nn(t,e=bn){return`${kt}=${t}; Path=/; HttpOnly; Secure; SameSite=Strict; Max-Age=${e}`}function In(){return`${kt}=; Path=/; HttpOnly; Secure; SameSite=Strict; Max-Age=0`}async function On(t,e){let n=Rn(e)[kt];n&&await t.delete(`${wt}${n}`)}async function kn(t){let e=M(20);return await t.put(`${Pt}${e}`,"1",qr),e}async function Ln(t,e){if(!e)return!1;let n=await t.get("SCANNER_TOKEN");return n&&X(n,e)?!0:await t.get(`${Pt}${e}`)?(await t.delete(`${Pt}${e}`),!0):!1}var kt,bn,qr,hn,oe,ae=k(()=>{"use strict";ft();K();kt=__sfx("Y2ZwaWxvdF9zZXNz"),bn=3600*24,qr=600,hn=3e4,oe="pbkdf2"});function vn(t){return Ce(t)}async function ue(t,e){if(V.config&&Date.now()-V.configAt<to)return V.config;let n=await Ne(t,e);return V.config=n,V.configAt=Date.now(),n}function Dn(){V.config=null,V.configAt=0}async function ce(t,e){if(V.auth&&Date.now()-V.authAt<eo)return V.auth;let n=await Cn(t,e.PANEL_PASSWORD,e.PANEL_PATH);return V.auth=n,V.authAt=Date.now(),n}function le(t){switch((t??"").toLowerCase()){case __sfx("Y2xhc2g="):case"mihomo":case"yaml":return __sfx("Y2xhc2g=");case"singbox":case"sing-box":case"json":return"singbox";case"v2ray":return"v2ray";case"base64":return"base64";default:return"base64"}}function yt(t){let e=String(t??"").trim();if(!e)return e;e=e.replace(/^[a-zA-Z][a-zA-Z0-9+.-]*:\/\//,""),e=e.replace(/[/?#].*$/,"");let n=e.lastIndexOf("@");if(n>=0&&(e=e.slice(n+1)),e.startsWith("[")){let r=e.indexOf("]");r>0&&(e=e.slice(1,r))}else{let r=e.indexOf(":");r>=0&&e.indexOf(":",r+1)<0&&(e=e.slice(0,r))}return e.trim()}function Fn(t){let e=(t??"").toLowerCase();return e?e.includes(__sfx("Y2xhc2g="))||e.includes("mihomo")||e.includes(__sfx("ZmxjbGFzaA=="))||e.includes(__sfx("Y2xhc2h4"))||e.includes("stash")?__sfx("Y2xhc2g="):e.includes("sing-box")||e.includes("singbox")?"singbox":e.includes("v2ray")||e.includes("v2rayng")||e.includes("shadowrocket")||e.includes("nekobox")||e.includes("surge")||e.includes("loon")||e.includes("quantumult")?"base64":null:null}var to,eo,V,Lt=k(()=>{"use strict";bt();ft();ae();to=15e3,eo=6e4,V={config:null,configAt:0,auth:null,authAt:0}});function fe(t,e,n){if(!t){n.push({field:e,message:""+e+__sfx("IOS4jeiDveS4uuepug==")});return}if(!t.startsWith("/")){n.push({field:e,message:""+e+__sfx("IOW/hemhu+S7pSAvIOW8gOWktA==")});return}if(t.length>128){n.push({field:e,message:""+e+__sfx("IOi/h+mVv++8iOacgOWkmiAxMjgg5a2X56ym77yJ")});return}/[\s\u0000-\u001f]/.test(t)&&n.push({field:e,message:""+e+__sfx("IOS4jeiDveWMheWQq+epuuagvOaIluaOp+WItuWtl+espg==")})}function tt(t,e,n,r,o){if(!Number.isFinite(t)){o.push({field:e,message:""+e+__sfx("IOW/hemhu+aYr+aVsOWtlw==")});return}(t<n||t>r)&&o.push({field:e,message:""+e+__sfx("IOW/hemhu+WcqCA=")+n+" ~ "+r+__sfx("IOS5i+mXtO+8iOW9k+WJjSA=")+t+")"})}function vt(t,e,n){let r=t.split(/\r?\n|,/).map(o=>o.trim()).filter(Boolean);if(r.length>20){n.push({field:e,message:""+e+__sfx("IOacgOWkmiAyMCDmnaHvvIjlvZPliY0g")+r.length+")"});return}for(let o of r)if(!ro.test(o)){n.push({field:e,message:""+e+__sfx("IOmHjOacieaXoOazleivhuWIq+eahOadoeebru+8mg==")+o.slice(0,40)+""});return}}function Un(t,e,n){let r=t.split(/\r?\n|,/).map(o=>o.trim()).filter(Boolean);if(r.length>10){n.push({field:e,message:""+e+__sfx("IOacgOWkmiAxMCDmnaHvvIjlvZPliY0g")+r.length+")"});return}for(let o of r)if(!/^https?:\/\/\S+$/i.test(o)){n.push({field:e,message:""+e+__sfx("IOW/hemhu+aYryBodHRwKHMpIOWcsOWdgO+8mg==")+o.slice(0,40)+""});return}}function pe(t){let e=[],n=o=>Object.prototype.hasOwnProperty.call(t,o);n("wsPath")&&fe(String(t.wsPath??""),"wsPath",e),n(__sfx("dHJvamFuUGF0aA=="))&&fe(String(t.trojanPath??""),__sfx("dHJvamFuUGF0aA=="),e),n(__sfx("eGh0dHBQYXRo"))&&fe(String(t.xhttpPath??""),__sfx("eGh0dHBQYXRo"),e);let r=["wsPath",__sfx("dHJvamFuUGF0aA=="),__sfx("eGh0dHBQYXRo")].filter(o=>n(o)).map(o=>`${o}=${String(t[o]??"")}`);if(r.length>=2){let o=r.map(s=>s.slice(s.indexOf("=")+1));new Set(o).size!==o.length&&e.push({field:"paths",message:__sfx("d3NQYXRoIC8gdHJvamFuUGF0aCAvIHhodHRwUGF0aCDkuI3og73ph43lpI0=")})}if(n("subDomain")){let o=String(t.subDomain??"").trim();o&&(!no.test(o)||o.includes("/"))&&e.push({field:"subDomain",message:__sfx("c3ViRG9tYWluIOW/hemhu+aYr+WQiOazleS4u+acuuWQje+8iOS4jeWQq+WNj+iuruS4jui3r+W+hO+8iQ==")})}if(n(__sfx("cHJveHlJcA=="))&&vt(String(t.proxyIp??""),__sfx("cHJveHlJcA=="),e),n(__sfx("c29ja3M1"))&&vt(String(t.socks5??""),__sfx("c29ja3M1"),e),n("httpProxy")&&vt(String(t.httpProxy??""),"httpProxy",e),n("relayPool")&&vt(String(t.relayPool??""),"relayPool",e),n("officialCount")&&tt(Number(t.officialCount),"officialCount",1,200,e),n("domainCount")&&tt(Number(t.domainCount),"domainCount",1,200,e),n("maxNodes")&&tt(Number(t.maxNodes),"maxNodes",0,500,e),n("dls")&&tt(Number(t.dls),"dls",0,1e3,e),n("maxLatency")&&tt(Number(t.maxLatency),"maxLatency",0,1e4,e),n("dataBudgetMB")&&tt(Number(t.dataBudgetMB),"dataBudgetMB",0,102400,e),n("subTokenTtlDays")&&tt(Number(t.subTokenTtlDays),"subTokenTtlDays",0,3650,e),n("subPorts")){let o=String(t.subPorts??"").trim();if(o){let s=o.split(/[\n,;\s]+/).filter(Boolean);s.length>6?e.push({field:"subPorts",message:__sfx("c3ViUG9ydHMg5pyA5aSaIDYg5Liq56uv5Y+j")}):s.every(a=>/^\d{1,5}$/.test(a)&&Number(a)>=1&&Number(a)<=65535)||e.push({field:"subPorts",message:__sfx("c3ViUG9ydHMg6YeM5q+P5Liq56uv5Y+j6YO95b+F6aG75pivIDF+NjU1MzUg55qE5pWw5a2X")})}}if(n("subName")){let o=String(t.subName??"");o.length>40&&e.push({field:"subName",message:__sfx("c3ViTmFtZSDmnIDlpJogNDAg5a2X56ym")}),/[\u0000-\u001f]/.test(o)&&e.push({field:"subName",message:__sfx("c3ViTmFtZSDkuI3og73ljIXlkKvmjqfliLblrZfnrKY=")})}if(n("addApi")&&Un(String(t.addApi??""),"addApi",e),n("addCsv")&&Un(String(t.addCsv??""),"addCsv",e),n("uuid")){let o=String(t.uuid??"").trim();o&&!/^[0-9a-fA-F]{8}-?[0-9a-fA-F]{4}-?[0-9a-fA-F]{4}-?[0-9a-fA-F]{4}-?[0-9a-fA-F]{12}$/.test(o)&&e.push({field:"uuid",message:__sfx("dXVpZCDlv4XpobvmmK/moIflh4YgVVVJRO+8iDM2IOS9je+8jOWPr+W4pui/nuWtl+espu+8iQ==")})}if(n("poolCountries")){let o=String(t.poolCountries??"").trim();if(o){let s=o.split(/[\n,;\s]+/).filter(Boolean);s.length>30?e.push({field:"poolCountries",message:__sfx("cG9vbENvdW50cmllcyDmnIDlpJogMzAg5Liq5Zu95a62L+WcsOWMug==")}):s.every(a=>/^[A-Za-z]{2,3}$/.test(a))||e.push({field:"poolCountries",message:__sfx("cG9vbENvdW50cmllcyDlj6rog73mmK8gMn4zIOS9jeWtl+avjeS7o+eggQ==")})}}if(n("udpDnsEndpoint")){let o=String(t.udpDnsEndpoint??"").trim();o&&!/^https:\/\/\S+$/i.test(o)&&e.push({field:"udpDnsEndpoint",message:__sfx("dWRwRG5zRW5kcG9pbnQg5b+F6aG75pivIGh0dHBzIOWcsOWdgA==")})}return e}function de(t){return t.length===0?"":t.length===1?t[0].message:"有 "+t.length+__sfx("IOmhuemFjee9ruS4jeWQiOazle+8mg==")+t.map(e=>e.message).join("\uFF1B")+""}var no,ro,Mn=k(()=>{"use strict";no=/^(?=.{1,253}$)([A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?)(\.[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?)*$/,ro=/^(?:(?:socks5|socks|socks5h|http|https):\/\/)?(?:[^\s@/]+@)?(?:\[[0-9a-fA-F:]+\]|[A-Za-z0-9._-]+)(?::\d{1,5})?$/});function Vn(t,e=Date.now()){let n={};for(let o of jn){let s=t[o];s!==void 0&&(n[o]=s)}let r=oo.map(o=>({field:o.field,reason:o.reason}));for(let o of[__sfx("c29ja3M1"),"httpProxy"]){let s=String(t[o]??"");if(!s){n[o]="";continue}if(s.includes("@")){r.push({field:o,reason:__sfx("5ZCr55So5oi35ZCNL+WPo+S7pO+8jOmcgOaJi+W3pemHjeaWsOWhq+WGmQ==")});continue}n[o]=s}return{schemaVersion:1,exportedAt:new Date(e).toISOString(),config:n,omitted:r}}function Bn(t){let e=new Set([...jn.map(String),__sfx("c29ja3M1"),"httpProxy"]),n={};for(let[r,o]of Object.entries(t))e.has(r)&&(n[r]=o);return n}function zn(t){if(t==null)return"\uFF08\u7A7A\uFF09";if(typeof t=="string"){let e=t.replace(/\s+/g," ").trim();return e.length>60?`${e.slice(0,60)}\u2026`:e||"\uFF08\u7A7A\uFF09"}return String(t)}function Hn(t,e){let n=[];for(let[r,o]of Object.entries(e)){let s=t[r];String(s)!==String(o)&&n.push({field:r,from:zn(s),to:zn(o)})}return n}var jn,oo,Xn=k(()=>{"use strict";jn=["poolOfficial","officialCount","poolDomain","domainCount","poolManual","poolCountries","add","dls","maxLatency","maxNodes",__sfx("cHJveHlJcA=="),"relayPool","useBuiltinRelay","proxyMode","nat64","concurrentDial","dataBudgetMB","resolvePreferred","aggressiveRedial",__sfx("ZW5hYmxlVHJvamFu"),__sfx("ZW5hYmxlWGh0dHA="),"subProtocol","subTransport","subVariants","subName","subPorts","clientFingerprint","ech","echHost","echDns","tlsFragment","tlsFragmentSize","tlsFragmentDelay","subToken","subTokenTtlDays","unlockProbe","udpDns","udpDnsEndpoint"],oo=[{field:"uuid",reason:__sfx("5YWl56uZ5Yet5o2u")},{field:__sfx("dHJvamFuUGFzc3dvcmQ="),reason:__sfx("5YWl56uZ5Yet5o2u")},{field:"wsPath",reason:__sfx("5a6e5L6L5qCH6K+G77yI6K6i6ZiF6ZO+5o6l6YeM5Y+v6KeB77yM5a+85Ye65Y2z5pq06Zyy5YWl5Y+j77yJ")},{field:__sfx("dHJvamFuUGF0aA=="),reason:__sfx("5a6e5L6L5qCH6K+G")},{field:__sfx("eGh0dHBQYXRo"),reason:__sfx("5a6e5L6L5qCH6K+G")},{field:"subDomain",reason:__sfx("5a6e5L6L5qCH6K+G")},{field:"addApi",reason:__sfx("VVJMIOWPr+iDveWQq+engeaciSB0b2tlbg==")},{field:"addCsv",reason:__sfx("VVJMIOWPr+iDveWQq+engeaciSB0b2tlbg==")}]});function Kn(){return new Response(JSON.stringify({build:ge,version:me,ts:Date.now()}),{status:200,headers:{"Content-Type":"application/json","Cache-Control":"no-store","Access-Control-Allow-Origin":"*"}})}var ge,me,Yn,he=k(()=>{"use strict";ge="2c7b165-d5c0a377",me=__sfx("MC4xNi4w"),Yn=__sfx("L19fY2ZwX3ZlcnNpb24=")});var Gn={};er(Gn,{API_PREFIX:()=>ye,getScannerToken:()=>lo,handleApi:()=>fo,pruneLoginFailures:()=>Jn});function ao(t){return t.headers.get("CF-Connecting-IP")??t.headers.get("x-forwarded-for")?.split(",")[0]?.trim()??"unknown"}function uo(t,e){let n=st.get(t);return n?e>=n.resetAt?(st.delete(t),!1):n.count>=so:!1}function Jn(t,e,n=io){if(!(t.size<n)){for(let[r,o]of t)e>=o.resetAt&&t.delete(r);for(;t.size>=n;){let r=t.keys().next().value;if(r===void 0)break;t.delete(r)}}}function co(t,e){let n=st.get(t);if(!n||e>=n.resetAt){Jn(st,e),st.set(t,{count:1,resetAt:e+Wn});return}n.count+=1}function E(t,e=200,n={}){return new Response(JSON.stringify(t),{status:e,headers:{"Content-Type":"application/json; charset=utf-8","Cache-Control":"no-store",...n}})}function R(t,e){return E({ok:!1,error:t},e)}async function lo(t,e){let n=await t.get(Vt);if(n)return n;if(typeof e.SCANNER_TOKEN=="string"&&e.SCANNER_TOKEN)return e.SCANNER_TOKEN;let r=M(24);return await t.put(Vt,r),r}async function fo(t,e,n){if(!e.pathname.startsWith(ye))return null;let{store:r,env:o,config:s,auth:a}=n,i=e.pathname.slice(ye.length)||"/",l=t.method.toUpperCase();if(i==="/session"&&l==="GET"){let c=await ie(r,t);return E({ok:!0,authenticated:c,panelPath:a.panelPath})}if(i==="/login"&&l==="POST"){let c="";try{let h=await t.json();c=String(h.password??"")}catch{return R(__sfx("6K+35rGC5L2T6Kej5p6Q5aSx6LSl"),400)}if(!c)return R(__sfx("6K+36L6T5YWl5a+G56CB"),400);let u=ao(t),f=Date.now();if(uo(u,f))return new Response(JSON.stringify({ok:!1,error:__sfx("5bCd6K+V6L+H5LqO6aKR57mB77yM6K+356iN5ZCO5YaN6K+V")}),{status:429,headers:{"Content-Type":"application/json; charset=utf-8","Cache-Control":"no-store","Retry-After":String(Math.ceil(Wn/1e3))}});let d=await En(a,c);if(!d.ok)return co(u,f),R(__sfx("5a+G56CB6ZSZ6K+v"),401);st.delete(u),d.legacy&&await xn(r,c).catch(()=>{}),await An(r).catch(()=>{});let g=await Tn(r);return E({ok:!0},200,{"Set-Cookie":Nn(g)})}if(i==="/logout"&&l==="POST")return await On(r,t),E({ok:!0},200,{"Set-Cookie":In()});if(i==="/preferred-ips"&&l==="POST"){let c=t.headers.get("Authorization")??"",u=c.startsWith("Bearer ")?c.slice(7).trim():c.trim();if(!await Ln(r,u))return R(__sfx("VG9rZW4g5qCh6aqM5aSx6LSl"),401);let d;try{d=await t.json()}catch{return R(__sfx("6K+35rGC5L2T6Kej5p6Q5aSx6LSl"),400)}let h=(Array.isArray(d.ips)?d.ips.map(S=>String(S)):[]).map(S=>S.trim()).filter(S=>S.length>0),L=d.mode==="append",T=S=>S.split("#")[0].trim().replace(/^\[([^\]]+)\]:(\d+)$/,"$1:$2"),x=await r.get(H),v,D=h.length;if(L){let S=(x??"").split(`
7
7
  `).map(y=>y.trim()).filter(y=>y.length>0),Y=new Set(S.map(T)),B=h.filter(y=>{let w=T(y);return Y.has(w)?!1:(Y.add(w),!0)});D=B.length,v=[...S,...B].join(`
8
8
  `)}else v=h.join(`
9
9
  `);x!==v&&await r.put(H,v);let P={};!L&&(s.add??"").trim()!==""&&(P.add=""),s.poolManual||(P.poolManual=!0);let m=!1;return Object.keys(P).length>0&&(await ut(r,at(s,P)),n.onConfigChanged(),m=P.add!==void 0),E({ok:!0,mode:L?"append":"replace",count:h.length,added:D,clearedManual:m,enabledManual:P.poolManual===!0})}if(!await ie(r,t))return R(__sfx("5pyq55m75b2V5oiW5Lya6K+d5bey6L+H5pyf"),401);if(i==="/status"&&l==="GET"){let c=await ct(r),u=mt(c),f=yt(s.subDomain||o.DATA_HOST||e.hostname);return E({ok:!0,panelPath:a.panelPath,domain:e.hostname,nodeDomain:f,dataHost:o.DATA_HOST??"",colo:t.cf?.colo??"UNK",coloLabel:dt(t.cf?.colo??""),localIps:u.length,generatedPassword:a.generatedPassword,version:ge,pkgVersion:me,readAt:Date.now()})}if(i==="/config"&&l==="GET")return E({ok:!0,config:s});if(i==="/config"&&l==="PUT"){let c;try{c=await t.json()}catch{return R(__sfx("6K+35rGC5L2T6Kej5p6Q5aSx6LSl"),400)}if(!c.config||typeof c.config!="object")return R(__sfx("57y65bCR6YWN572u5a+56LGh"),400);let u=pe(c.config);if(u.length>0)return R(de(u),400);let f=at(s,c.config);return await ut(r,f),n.onConfigChanged(),E({ok:!0,config:f})}if(i==="/config/export"&&l==="GET")return E({ok:!0,...Vn(s)});if(i==="/config/import"&&l==="POST"){let c;try{c=await t.json()}catch{return R(__sfx("6K+35rGC5L2T6Kej5p6Q5aSx6LSl"),400)}if(!c.config||typeof c.config!="object")return R(__sfx("57y65bCR6YWN572u5a+56LGh"),400);let u=Bn(c.config);if(Object.keys(u).length===0)return R(__sfx("5rKh5pyJ5Y+v5a+85YWl55qE5a2X5q6177yI56Gu6K6k5piv5pys6aG555uu5a+85Ye655qE6YWN572u5paH5Lu277yf77yJ"),400);let f=pe(u);if(f.length>0)return R(de(f),400);let d=Hn(s,u);if(c.dryRun)return E({ok:!0,dryRun:!0,diff:d,count:d.length});if(d.length===0)return E({ok:!0,applied:0,diff:[],config:s});let g=at(s,u);return await ut(r,g),n.onConfigChanged(),E({ok:!0,applied:d.length,diff:d,config:g})}if(i==="/ips"&&l==="GET"){let c=await ct(r),u=mt(c);return E({ok:!0,raw:c,count:u.length,entries:u})}if(i==="/ips"&&l==="DELETE")return await r.delete(H),E({ok:!0});if(i==="/ips"&&l==="PUT"){let c;try{c=await t.json()}catch{return R(__sfx("6K+35rGC5L2T6Kej5p6Q5aSx6LSl"),400)}if(typeof c.raw!="string")return R(__sfx("57y65bCRIHJhdyDlrZfmrrU="),400);let u=c.raw.split(/\r?\n/).map(f=>f.trim()).filter(f=>f.length>0).join(`
@@ -2,4 +2,4 @@ const __sfx=(()=>{const __t=new TextDecoder(),__c=new Map();return b=>{let v=__c
2
2
  `);await i.write(new TextEncoder().encode(f));let c=Date.now()+ot,u="";for(;;){let R=s.peek(),C=Kr(R);if(C>=0){u=new TextDecoder().decode(R.subarray(0,C)),s.skip(C+4);break}if(R.byteLength>8192)throw new Error(__sfx("SFRUUCDku6PnkIblk43lupTlpLTotoXov4cgODE5MiDlrZfoioI="));let d=c-Date.now();if(d<=0)throw new Error(__sfx("SFRUUCDku6PnkIbmj6HmiYvotoXml7bvvIg=")+ot+__sfx("bXMg5peg5ZON5bqU77yJ"));let w=null,x;try{x=await Promise.race([s.fill(),new Promise(L=>{w=setTimeout(()=>L("timeout"),d)})])}finally{w&&clearTimeout(w)}if(x==="timeout")throw new Error(__sfx("SFRUUCDku6PnkIbmj6HmiYvotoXml7bvvIg=")+ot+__sfx("bXMg5peg5ZON5bqU77yJ"));if(x===null)throw new Error(__sfx("SFRUUCDku6PnkIblk43lupTkuI3lrozmlbTvvIjov57mjqXooqvmj5DliY3lhbPpl63vvIk="))}let g=u.split(`\r
3
3
  `)[0]??"",b=/^HTTP\/1\.[01]\s+(\d{3})/.exec(g);if(!b)throw new Error(__sfx("SFRUUCDku6PnkIblk43lupTpnZ7ms5U="));if(b[1]!=="200")throw new Error(__sfx("SFRUUCDku6PnkIYgQ09OTkVDVCDlpLHotKXvvJo=")+b[1]+"");return s.release()}finally{try{i.releaseLock()}catch{}}}var Xr,ot,mn=P(()=>{"use strict";B();pe();Xr=[13,10,13,10];ot=6e3});function it(e){if(e instanceof _||(e instanceof Error?e.message:String(e)).includes(gn))return!0;let n=e instanceof Error?e.cause:void 0;return n!==void 0&&n!==e&&it(n)}function hn(e){let t=e.split(".");if(t.length!==4)return null;let n=0;for(let o of t){if(!/^\d{1,3}$/.test(o))return null;let r=Number(o);if(r>255)return null;n=n*256+r}return n>>>0}function Ie(e){let t=hn(e);if(t===null)return null;for(let[n,o,r,s]of jr){let i=hn(n);if(i===null)continue;let a=o===0?0:4294967295<<32-o>>>0;if((t&a)===(i&a))return{kind:r,reason:s}}return null}function st(e){let t=e[6]??0,n=e[7]??0;return`${t>>>8}.${t&255}.${n>>>8}.${n&255}`}function Wr(e){let t=(e.split("%")[0]??"").toLowerCase();if(!t.includes(":"))return null;let n=fe(t);if(!n)return null;let o=n[0]===0&&n[1]===0&&n[2]===0&&n[3]===0&&n[4]===0;if(o&&n[5]===65535)return Ie(st(n))??null;if(o&&n[5]===0&&n[6]===0&&(n[7]===0||n[7]===1))return n[7]===1?{kind:"loopback",reason:__sfx("546v5Zue5Zyw5Z2A")}:{kind:"unspecified",reason:__sfx("5pyq5oyH5a6a5Zyw5Z2A")};if(o&&n[5]===0)return Ie(st(n))??null;if(n[0]===100&&n[1]===65435&&n[2]===0&&n[3]===0&&n[4]===0&&n[5]===0){let s=Ie(st(n));if(s)return s}let r=n[0]??0;return(r&65024)===64512?{kind:"ula",reason:__sfx("SVB2NiDllK/kuIDmnKzlnLDlnLDlnYA=")}:(r&65472)===65152?{kind:"link-local",reason:__sfx("SVB2NiDpk77ot6/mnKzlnLDlnLDlnYA=")}:(r&65280)===65280?{kind:"multicast",reason:__sfx("SVB2NiDnu4Tmkq3lnLDlnYA=")}:null}function at(e){let t=e.trim().toLowerCase().replace(/^\[|\]$/g,"");if(t==="")return null;if(t.includes(":"))return Wr(t);if(/^\d{1,3}(?:\.\d{1,3}){3}$/.test(t))return Ie(t);if(t==="localhost"||t.endsWith(".localhost"))return{kind:"loopback",reason:__sfx("546v5Zue5Li75py65ZCN")};for(let n of Yr)if(t.endsWith(n))return{kind:"internal-name",reason:__sfx("5YaF572R5Z+f5ZCN5ZCO57yA")};return null}var gn,yn,_,jr,Yr,lt=P(()=>{"use strict";B();gn=__sfx("55uu5qCH5Zyw5Z2A6KKr562W55Wl5oum5oiq"),yn={kind:"ipv6-direct-unsupported",reason:__sfx("55u06L+e5LiO5Y+N5Luj6YCa6YGT5LiN5pSv5oyBIElQdjYg55uu5qCH77yM5Y+v5pS555So6JC95Zyw5Luj55CG6L2s5Y+R")},_=class extends Error{kind;constructor(t,n){super(`${gn}\uFF1A${t}\uFF08${n.reason}\uFF09`),this.name="TargetBlockedError",this.kind=n.kind}};jr=[[__sfx("MC4wLjAuMA=="),8,"unspecified",__sfx("5pyq5oyH5a6a5Zyw5Z2A")],[__sfx("MTAuMC4wLjA="),8,"private",__sfx("56eB5pyJ572R5q61")],[__sfx("MTAwLjY0LjAuMA=="),10,"cgnat",__sfx("6L+Q6JCl5ZWG57qnIE5BVCDnvZHmrrU=")],[__sfx("MTI3LjAuMC4w"),8,"loopback",__sfx("546v5Zue5Zyw5Z2A")],[__sfx("MTY5LjI1NC4wLjA="),16,"link-local",__sfx("6ZO+6Lev5pys5ZywIC8g5LqR5YWD5pWw5o2u5Zyw5Z2A")],[__sfx("MTcyLjE2LjAuMA=="),12,"private",__sfx("56eB5pyJ572R5q61")],[__sfx("MTkyLjE2OC4wLjA="),16,"private",__sfx("56eB5pyJ572R5q61")],[__sfx("MjI0LjAuMC4w"),4,"multicast",__sfx("57uE5pKt5Zyw5Z2A")],[__sfx("MjQwLjAuMC4w"),4,"reserved",__sfx("5L+d55WZ5Zyw5Z2A")]];Yr=[".local",".internal"]});function Qr(e){return/^\d{1,3}(\.\d{1,3}){3}$/.test(e)?!0:e.includes(":")&&/^[0-9a-fA-F:.]+$/.test(e)}function ct(e,t){let n=e.trim(),o=/^\[([^\]]+)\](?::(\d+))?$/.exec(n);if(o)return{host:o[1],port:Number(o[2]??t)};if(n.includes(":")&&n.split(":").length>2)return{host:n,port:t};let r=n.lastIndexOf(":");if(r<0)return{host:n,port:t};let s=n.slice(0,r),i=Number(n.slice(r+1));return s?{host:s,port:Number.isInteger(i)&&i>0?i:t}:{host:n,port:t}}async function qr(e,t,n,o=Pn){try{let r=`${e}?name=${encodeURIComponent(t)}&type=${n}`,s=await fetch(r,{headers:{accept:"application/dns-json"},signal:AbortSignal.timeout(o)});if(!s.ok)return null;let i=await s.json();if(!i||i.Status!==0&&i.Status!==3)return null;if(!Array.isArray(i.Answer))return[];let a=n==="TXT"?16:n==="A"?1:28;return i.Answer.filter(l=>l.type===a).map(l=>String(l.data))}catch{return null}}async function wn(e,t,n={}){for(let o of Jr){if(n.deadline!==void 0&&Date.now()>=n.deadline)break;let r=n.timeoutMs??Pn,s=n.deadline!==void 0?n.deadline-Date.now():Number[__sfx("UE9TSVRJVkVfSU5GSU5JVFk=")],i=Math.max(50,Math.min(r,s)),a=await qr(o,e,t,i);if(a!==null)return a}return[]}function Zr(e,t){let n=[],o=String(e).replace(/^"|"$/g,"").replace(/\\010/g,",").replace(/\\n/g,",").trim();if(!o||o===xn)return n;let r=o.split(/[,;\s]+/).filter(Boolean);if(r.length===0)return n;for(let s of r){let i=s.trim();if(!i)continue;let{host:a,port:l}=ct(i,t);if(!N(a)&&!G(a))return[];n.push({hostname:a,port:l})}return n}async function Le(e,t,n={}){let o=e.trim();if(!o)return[];if(Qr(o))return[{hostname:o,port:t}];let r=`${o}:${t}`,s=X.get(r);if(s&&Date.now()-s.at<bn)return X.delete(r),X.set(r,s),s.ips;let i=[],[a,l]=await Promise.all([n.skipTxt?Promise.resolve([]):wn(o,"TXT",n),wn(o,"A",n)]);if(!n.skipTxt)for(let u of a){let p=Zr(u,t);if(p.length>0){i.push(...p);break}if(String(u).replace(/^"|"$/g,"").replace(/\\010/g,",").trim()===xn)break}if(i.length===0)for(let u of l)N(u)&&i.push({hostname:u,port:t});let f=[],c=new Set;for(let u of i){let p=`${u.hostname}:${u.port}`;c.has(p)||(c.add(p),f.push(u))}if(f.length>0){let u=Date.now();for(let[p,g]of X)u-g.at>=bn&&X.delete(p);for(;X.size>=Gr;){let p=X.keys().next().value;if(p===void 0)break;X.delete(p)}X.set(r,{at:u,ips:f})}return f}var xn,Jr,Pn,bn,Gr,X,De=P(()=>{"use strict";B();xn=__sfx("QGVkZ2V0dW5uZWw="),Jr=["https://cloudflare-dns.com/dns-query","https://dns.google/resolve","https://dns.alidns.com/resolve","https://doh.pub/dns-query"],Pn=4e3,bn=300*1e3,Gr=1e3,X=new Map});var ht={};Ee(ht,{[__sfx("QlVJTFRJTl9SRUxBWV9ET01BSU5T")]:()=>Tn,[__sfx("QlVJTFRJTl9SRUxBWV9SRUdJT04=")]:()=>Oe,[__sfx("Q09MT19UT19DT1VOVFJZ")]:()=>Rn,[__sfx("UkVHSU9OX0FESkFDRU5DWQ==")]:()=>En,[__sfx("UkVHSU9OX09SREVS")]:()=>ft,[__sfx("UkVMQVlfQkFUQ0hfU0laRQ==")]:()=>oe,[__sfx("UkVMQVlfRE9NQUlOX0xJTUlU")]:()=>mt,[__sfx("VU5LTk9XTl9SRUdJT04=")]:()=>An,clearRelayCache:()=>no,collectRelayEndpoints:()=>me,coloToCountry:()=>Ue,rankRegions:()=>pt,regionOfEntry:()=>ut,relayCacheSize:()=>ro,resolveRelayEntry:()=>dt,selectRelayDomains:()=>vn,sortEndpointsByRegion:()=>Sn});function ut(e,t=Oe){let o=e.trim().toLowerCase().replace(/:\d{1,5}$/,"");return t[o]??An}function pt(e){let t=(e??"").trim().toUpperCase();if(!t)return[...ft];let n=En[t]??[],o=ft.filter(r=>r!==t&&!n.includes(r));return[t,...n,...o]}function Sn(e,t){let n=pt(t),o=r=>{let s=n.indexOf(r);return s>=0?s:n.length};return e.map((r,s)=>({e:r,i:s})).sort((r,s)=>{let i=o(r.e.regionCode),a=o(s.e.regionCode);return i!==a?i-a:r.i-s.i}).map(r=>r.e)}function Ue(e){let t=String(e??"").toUpperCase();return t?Rn[t]??(/^[A-Z]{2}$/.test(t)?t:"US"):"US"}function to(e){for(let[t,n]of K)e-n.at>=kn&&K.delete(t);for(;K.size>=eo;){let t=K.keys().next().value;if(t===void 0)break;K.delete(t)}}async function dt(e,t=443,n=Cn,o={}){let r=e.trim();if(!r)return[];let s=`${r}:${t}:${n}`,i=K.get(s);if(i&&Date.now()-i.at<kn)return i.ips;let a=r,l=t,f=(r.match(/:/g)??[]).length;if(f===1){let u=/^(.*):(\d{1,5})$/.exec(r);u&&(a=u[1],l=Number(u[2]))}else if(f>1&&r.startsWith("[")){let u=/^\[([^\]]+)\]:(\d{1,5})$/.exec(r);u&&(a=u[1],l=Number(u[2]))}let c=[];if(N(a)||G(a))c=[{ip:a,port:Number.isInteger(l)&&l>0?l:t,label:r,regionCode:ut(r)}];else try{c=(await Le(a,l,{skipTxt:o.skipTxt,deadline:o.deadline,timeoutMs:o.timeoutMs})).slice(0,n).map(p=>({ip:p.hostname,port:p.port,label:`${a} \u2192 ${p.hostname}`,regionCode:ut(r)}))}catch{c=[]}if(c.length>0){let u=Date.now();to(u),K.set(s,{at:u,ips:c})}return c}function vn(e,t=mt,n=Tn,o=Oe){let r=Ue(e),s=pt(r),i=a=>{let l=o[a];if(!l)return s.length+1;let f=s.indexOf(l);return f>=0?f:s.length};return n.map((a,l)=>({d:a,i:l,rank:i(a)})).sort((a,l)=>a.rank!==l.rank?a.rank-l.rank:a.i-l.i).map(a=>a.d).slice(0,Math.max(0,t))}async function me(e={}){let t=e.perDomain??Cn,n=[],o=new Set,r=d=>{for(let w of d){let x=`${w.ip}:${w.port}`;o.has(x)||(o.add(x),n.push(w))}},s=(e.userEntries??"").trim(),i=s?s.split(/[\n,;]+/).map(d=>d.trim()).filter(Boolean):[],a=e.domainLimit??mt,l=e.useBuiltin!==!1?vn(e.colo,a):[],f=d=>e.perDomain!==void 0?t:Oe[d]===Ue(e.colo)?_r:$r,c=await Promise.all([...i.map(d=>dt(d,443,t,{deadline:e.deadline,timeoutMs:e.timeoutMs})),...l.map(d=>dt(d,443,f(d),{skipTxt:!0,deadline:e.deadline,timeoutMs:e.timeoutMs}))]),u=n.length;for(let d=0;d<i.length;d++)r(c[d]);let p=n.length-u,g=c.slice(i.length),b=g.reduce((d,w)=>Math.max(d,w.length),0);for(let d=0;d<b;d++)for(let w of g)d<w.length&&r([w[d]]);let R=n.slice(0,p),C=Sn(n.slice(p),Ue(e.colo));return[...R,...C]}function no(){K.clear()}function ro(){return K.size}var An,En,ft,Oe,Tn,Rn,Cn,oe,mt,_r,$r,kn,eo,K,he=P(()=>{"use strict";B();De();An="??";En={[__sfx("VVM=")]:["SG","JP","KR"],[__sfx("U0c=")]:["JP","KR","US"],[__sfx("SlA=")]:["SG","KR","US"],[__sfx("S1I=")]:["JP","SG","US"],[__sfx("REU=")]:["NL","GB","SE","FI"],[__sfx("U0U=")]:["DE","NL","FI","GB"],[__sfx("Tkw=")]:["DE","GB","SE","FI"],[__sfx("Rkk=")]:["SE","DE","NL","GB"],[__sfx("R0I=")]:["DE","NL","SE","FI"]},ft=["US","SG","JP","KR","DE","SE","NL","FI","GB"];Oe={},Tn=[__sfx("MTkyLjE4LjEzNi4yNTU="),__sfx("MTI4LjEyMS4zMS4yNTI="),__sfx("MTI5LjE1OS4zNy4xMzY="),__sfx("MjMuMTQ0LjEyLjYz"),__sfx("MjE2LjM2Ljg2LjYy"),__sfx("NDUuMTMzLjExNy4xODU="),__sfx("MzguODQuMjAxLjIyOA=="),__sfx("MTA5LjEyMC4xNDIuMjE5"),__sfx("NDUuMTQwLjE2Ny40Mw=="),__sfx("NS4yNTMuMTg4LjEzOQ=="),__sfx("MjE2LjM2LjgyLjMx"),__sfx("MTY3LjI1My45Ni45MA=="),__sfx("MTk0Ljg3LjYyLjEzOQ=="),__sfx("MjMuMTQ0LjIwLjE4NA=="),__sfx("MTI4LjEyMS4zMS41OA=="),__sfx("MTA0LjIzOC4xNTQuNzc="),__sfx("MzguMjQ0LjE1MC4xMTM="),__sfx("MTU1LjI0OC4xODEuMTg5"),__sfx("MjE2LjM2LjgyLjE0MQ=="),__sfx("NjQuMTgxLjI1NS4yMTU="),__sfx("MzEuMjUuMjM5LjY2"),__sfx("NDUuNzYuMjQ2LjE5Mg=="),__sfx("MjMuOTUuMTEzLjYx"),__sfx("MTUxLjI0NC4yMDEuMjA3")],Rn={[__sfx("SEtH")]:"HK",[__sfx("U1lE")]:"AU",[__sfx("TUVM")]:"AU",[__sfx("Qk5F")]:"AU",[__sfx("UEVS")]:"AU",[__sfx("QURM")]:"AU",[__sfx("Q0JS")]:"AU",[__sfx("U0lO")]:"SG",[__sfx("TlJU")]:"JP",[__sfx("SE5E")]:"JP",[__sfx("S0lY")]:"JP",[__sfx("VFlP")]:"JP",[__sfx("T1NB")]:"JP",[__sfx("TkdP")]:"JP",[__sfx("Q1RT")]:"JP",[__sfx("RlVL")]:"JP",[__sfx("T0tB")]:"JP",[__sfx("SUNO")]:"KR",[__sfx("U0VM")]:"KR",[__sfx("UFVT")]:"KR",[__sfx("RlJB")]:"DE",[__sfx("TVVD")]:"DE",[__sfx("RFVT")]:"DE",[__sfx("QkVS")]:"DE",[__sfx("SEFN")]:"DE",[__sfx("U1RS")]:"DE",[__sfx("VklF")]:"DE",[__sfx("WlJI")]:"DE",[__sfx("Q0RH")]:"FR",[__sfx("TUFE")]:"ES",[__sfx("TVhQ")]:"IT",[__sfx("RkNP")]:"IT",[__sfx("UFJH")]:"CZ",[__sfx("V0FX")]:"PL",[__sfx("QVJO")]:"SE",[__sfx("QU1T")]:"NL",[__sfx("SEVM")]:"FI",[__sfx("TEhS")]:"GB",[__sfx("TEdX")]:"GB",[__sfx("TUFO")]:"GB",[__sfx("RURJ")]:"GB",[__sfx("TEFY")]:"US",[__sfx("U0pD")]:"US",[__sfx("U0ZP")]:"US",[__sfx("U0VB")]:"US",[__sfx("UERY")]:"US",[__sfx("U0FO")]:"US",[__sfx("TEFT")]:"US",[__sfx("UEhY")]:"US",[__sfx("U0xD")]:"US",[__sfx("REVO")]:"US",[__sfx("REZX")]:"US",[__sfx("SUFI")]:"US",[__sfx("QVVT")]:"US",[__sfx("T1JE")]:"US",[__sfx("TVNQ")]:"US",[__sfx("RFRX")]:"US",[__sfx("U1RM")]:"US",[__sfx("TUNJ")]:"US",[__sfx("QVRM")]:"US",[__sfx("TUlB")]:"US",[__sfx("TUNP")]:"US",[__sfx("Qk5B")]:"US",[__sfx("Q0xU")]:"US",[__sfx("SUFE")]:"US",[__sfx("Qk9T")]:"US",[__sfx("RVdS")]:"US",[__sfx("SkZL")]:"US",[__sfx("UEhM")]:"US",[__sfx("WVla")]:"CA",[__sfx("WVZS")]:"CA",[__sfx("WVVM")]:"CA",[__sfx("TUVY")]:"MX",[__sfx("R1JV")]:"BR",[__sfx("VFBF")]:"TW",[__sfx("S0hI")]:"TW",[__sfx("VFNB")]:"TW",[__sfx("Uk1R")]:"TW"};Cn=4,oe=6,mt=6,_r=2,$r=1,kn=30*1e3,eo=256,K=new Map});function gt(e){let t=e.split(".");if(t.length!==4)return null;let n=0;for(let o of t){if(!/^\d{1,3}$/.test(o))return null;let r=Number(o);if(r>255)return null;n=n*256+r}return n>>>0}function In(e){return e.map(([t,n])=>{let o=gt(t)??0,r=n===0?0:4294967295<<32-n>>>0;return[(o&r)>>>0,r]})}function Ln(e){let t=gt(e);if(t===null)return!1;for(let[n,o]of co)if((t&o)>>>0===n)return!0;return!1}function Z(e){let t=gt(e);if(t===null)return!1;for(let[n,o]of lo)if((t&o)>>>0===n)return!0;return!1}function Dn(e){let t=[],n=new Set,o=c=>{let u=`${c.source}|${c.host}|${c.port}`;n.has(u)||(n.add(u),t.push(c))};for(let c of e.proxies??[])c.kind==="direct"?o({source:"proxy",host:c.host,port:c.port,label:__sfx("UHJveHlJUCA=")+c.host+":"+c.port+"",via:{kind:"direct",host:c.host,port:c.port}}):o({source:"proxy",host:c.host,port:c.port,label:`${c.kind.toUpperCase()} ${c.host}:${c.port}`,via:{kind:c.kind,host:c.host,port:c.port,username:c.username,password:c.password,serverName:c.serverName}});let s=Z(e.targetHost)||e.deprioritizeDirect===!0;o({source:"direct",host:e.targetHost,port:e.targetPort,label:__sfx("55u06L+eIA==")+e.targetHost+":"+e.targetPort+"",deprioritized:s});let i=e.optimizedIps??[],a=i.filter(c=>!Z(c.ip)),l=i.filter(c=>Z(c.ip));for(let c of a)o({source:"optimized",host:c.ip,port:c.port,label:__sfx("5LyY6YCJIA==")+c.ip+":"+c.port+""});for(let c of l)o({source:"optimized",host:c.ip,port:c.port,label:__sfx("5LyY6YCJIA==")+c.ip+":"+c.port+__sfx("77yIQ2xvdWRmbGFyZSDnvZHmrrXvvIzlj6/og73kuI3lj6/ovr7vvIk="),deprioritized:!0});let f=e.relay??[];for(let c of f)o({source:"relay",host:c.ip,port:c.port,label:__sfx("5Y+N5LujIA==")+c.label+"",deprioritized:!e.relayAsPrimary});return t.map((c,u)=>({candidate:c,index:u})).sort((c,u)=>{let p=+!!c.candidate.deprioritized-+!!u.candidate.deprioritized;return p!==0?p:c.index-u.index}).map(c=>c.candidate)}function Un(e){let t=e.filter(o=>!o.deprioritized),n=t.filter(o=>o.source==="proxy");return{landing:n.filter(o=>o.via?.kind!=="direct"),[__sfx("cHJveHlJcA==")]:n.filter(o=>o.via?.kind==="direct"),direct:t.filter(o=>o.source!=="proxy"),fallback:e.filter(o=>o.deprioritized)}}function On(e,t){let n=e instanceof Error?e.message:String(e);return it(e)?{kind:"policy",message:n,candidate:t}:/proxy request failed|cannot connect to the specified address|TCP Loop/i.test(n)?{kind:"blocked",message:n,candidate:t}:/timeout|超时|timed out|abort/i.test(n)?{kind:"timeout",message:n,candidate:t}:{kind:"other",message:n,candidate:t}}function Nn(e){switch(e.kind){case"blocked":return __sfx("5Ye656uZ6KKrIENsb3VkZmxhcmUg5ouS57ud77yI")+e.candidate+"):"+e.message+__sfx("CiAg5bi46KeB5Y6f5Zug77ya55uu5qCH5Zyw5Z2A5ZyoIENsb3VkZmxhcmUg6Ieq5a62572R5q6177yIV29ya2VyIOS4jeiDveS4u+WKqOi/nuWbniBDRiDoh6rlt7HnmoTlhaXlj6PvvInjgIIKICDihpIg5o2i5LiA5Liq56ys5LiJ5pa5IElQ77yM5oiW5pS555So5Luj55CG6JC95Zyw44CC");case"policy":return __sfx("5Ye656uZ6KKr562W55Wl5ouS57ud77yI")+e.candidate+"):"+e.message+__sfx("CiAg55uu5qCH5bGe5LqO546v5ZueIC8g5YaF572RIC8g6ZO+6Lev5pys5ZywIC8g5L+d55WZ5Zyw5Z2A77yMV29ya2VyIOebtOi/nuaXoOazleWIsOi+vuOAggogIOKGkiDopoHorr/pl67lsYDln5/nvZHorr7lpIfvvIzor7fphY3nva7okL3lnLDku6PnkIbvvIjnlLHku6PnkIbkvqflu7rov57vvInjgII=");case"timeout":return __sfx("5Ye656uZ6LaF5pe277yI")+e.candidate+"):"+e.message+__sfx("CiAg4oaSIOivpeWcsOWdgOW9k+WJjeS4jeWPr+i+vu+8jOWPr+aNouS4gOadoeWAmemAieaIluWQr+eUqOS7o+eQhuiQveWcsOOAgg==");default:return __sfx("5Ye656uZ5aSx6LSl77yI")+e.candidate+"):"+e.message+""}}var oo,so,io,ao,lo,co,yt=P(()=>{"use strict";lt();oo=[[__sfx("MTAzLjIxLjI0NC4w"),22],[__sfx("MTAzLjIyLjIwMC4w"),22],[__sfx("MTAzLjMxLjQuMA=="),22],[__sfx("MTA0LjE2LjAuMA=="),13],[__sfx("MTA0LjI0LjAuMA=="),14],[__sfx("MTA4LjE2Mi4xOTIuMA=="),18],[__sfx("MTMxLjAuNzIuMA=="),22],[__sfx("MTQxLjEwMS42NC4w"),18],[__sfx("MTYyLjE1OC4wLjA="),15],[__sfx("MTcyLjY0LjAuMA=="),13],[__sfx("MTczLjI0NS40OC4w"),20],[__sfx("MTg4LjExNC45Ni4w"),20],[__sfx("MTkwLjkzLjI0MC4w"),20],[__sfx("MTk3LjIzNC4yNDAuMA=="),22],[__sfx("MTk4LjQxLjEyOC4w"),17]],so=[[__sfx("MTA0LjMxLjAuMA=="),15],[__sfx("MTkyLjAuMC4w"),24],[__sfx("MTkyLjAuMi4w"),24],[__sfx("MTkyLjg4Ljk5LjA="),24],[__sfx("MTk5LjI3LjEyOC4w"),21],[__sfx("MS4wLjAuMA=="),24],[__sfx("MS4xLjEuMA=="),24]],io=[[__sfx("MjIzLjUuNS4w"),24]],ao=[...oo,...so];lo=In(ao),co=In(io)});function Mn(e,t="direct"){let n=e.trim();if(!n)return null;let o=t,r=n,s=/^([a-z0-9+.-]+):\/\//i.exec(n);if(s){let p=s[1].toLowerCase();r=n.slice(s[0].length),p===__sfx("c29ja3M1")||p===__sfx("c29ja3M=")||p===__sfx("c29ja3M1aA==")?o=__sfx("c29ja3M1"):p==="https"?o="https":p==="http"&&(o="http")}let i=r.lastIndexOf("@"),a={};if(i>=0){let p=r.slice(0,i);r=r.slice(i+1);let g=p.indexOf(":");g>=0?a={username:p.slice(0,g),password:p.slice(g+1)}:a={username:p}}let l,f=/#sni=([^/#]+)/i.exec(r);f&&(l=f[1].trim(),r=r.slice(0,f.index)+r.slice(f.index+f[0].length));let{host:c,port:u}=ct(r,0);return!c||!Number.isInteger(u)||u<=0||u>65535?null:(!l&&o==="https"&&!uo(c)&&(l=c),{host:c,port:u,kind:o,...a,...l?{serverName:l}:{}})}function uo(e){return/^\d{1,3}(\.\d{1,3}){3}$/.test(e)}function ge(e,t="direct"){let n=[];for(let o of e.split(/[\n,;]+/)){let r=o.trim();if(!r)continue;let s=Mn(r,t);s&&n.push(s)}return n}var bt=P(()=>{"use strict";De()});async function fo(){return wt||(wt=(async()=>(await import("cloudflare:sockets")).connect)()),await wt}function mo(e,t){if(!N(e))return null;let n=e.split(".").map(i=>Number(i)),o=(n[0]<<8|n[1]).toString(16),r=(n[2]<<8|n[3]).toString(16);return`${t.replace(/:+$/,"")}::${o}:${r}`}async function Ne(e,t,n,o,r){let i=(await fo())({hostname:e,port:t},o?{secureTransport:o}:void 0),a=async(f,c)=>{let u,p=new Promise((g,b)=>{u=setTimeout(()=>b(new Error(""+c+__sfx("6LaF5pe277ya")+e+":"+t+"")),n)});try{return await Promise.race([f,p])}finally{u&&clearTimeout(u)}},l;try{if(await a(i.opened,__sfx("6L+e5o6l")),o==="starttls"){if(l=i.startTls?.(r?{expectedServerHostname:r}:void 0),!l)throw new Error(__sfx("5b2T5YmN6L+Q6KGM5pe25LiN5pSv5oyBIHN0YXJ0VGxz"));return await a(l.opened,__sfx("VExTIOaPoeaJiw==")),l}return i}catch(f){try{await(l??i).close()}catch{}throw f}}async function ho(e){let t=e.timeoutMs??At;try{let n=await Ne(e.hostname,e.port,t);return{readable:n.readable,writable:n.writable,via:"direct",endpoint:`${e.hostname}:${e.port}`,close:()=>{try{n.close()}catch{}}}}catch(n){if(e.nat64&&N(e.hostname)){let o=mo(e.hostname,e.nat64);if(o){let r=await Ne(o,e.port,t);return{readable:r.readable,writable:r.writable,via:"nat64",endpoint:`${o}:${e.port}`,close:()=>{try{r.close()}catch{}}}}}throw n}}function go(e){return e.includes(":")}function yo(e){return e.source==="proxy"&&e.via!==void 0&&e.via.kind!=="direct"}async function bo(e,t){let n=e.timeoutMs??At;if(t.kind==="direct"){let s=await Ne(t.host,t.port,n);return{readable:s.readable,writable:s.writable,via:"direct",endpoint:`${t.host}:${t.port}`,close:()=>{try{s.close()}catch{}}}}let o=t.kind==="https"?"starttls":void 0,r=await Ne(t.host,t.port,n,o,t.kind==="https"?t.serverName:void 0);try{return t.kind==="http"||t.kind==="https"?{readable:await pn(r.readable,r.writable,e.hostname,e.port,{username:t.username,password:t.password}),writable:r.writable,via:t.kind,endpoint:`${t.host}:${t.port}`,close:()=>{try{r.close()}catch{}}}:{readable:await fn(r.readable,r.writable,e.hostname,e.port,{username:t.username,password:t.password}),writable:r.writable,via:__sfx("c29ja3M1"),endpoint:`${t.host}:${t.port}`,close:()=>{try{r.close()}catch{}}}}catch(s){try{await r.close()}catch{}throw s}}function Bn(e){return e instanceof Error?e.message:typeof e=="string"?e:String(e)}function xo(e){if(e.length===0)return __sfx("5pyq55+l5Y6f5Zug");let t=e.map(Bn),n=t.slice(-wo),o=t.length-n.length;return`${o>0?`\uFF08\u5171 ${t.length} \u6761\uFF0C\u7701\u7565\u524D ${o} \u6761\uFF09`:""}${n.join("\uFF1B")}`}function Po(e){return e.length===0?Promise.reject(new Error(__sfx("5rKh5pyJ5Y+v55So55qE5Ye656uZ5ouo5Y+35pa55byP"))):new Promise((t,n)=>{let o=e.length,r=!1,s=[];for(let i of e)i().then(a=>{if(r){try{let l=a.close;Promise.resolve(l?l():a.writable.close()).catch(()=>{})}catch{}return}r=!0,t(a)},a=>{s.push(a),o-=1,o===0&&!r&&(r=!0,n(new Error(__sfx("5pys5om5IA==")+e.length+__sfx("IOS4quWAmemAieWFqOmDqOWksei0pe+8mg==")+xo(s)+"")))})})}async function Pt(e,t){if(e.length===0)throw new Error(__sfx("5rKh5pyJ5Y+v55So55qE5Ye656uZ5ouo5Y+35pa55byP"));if(!t||e.length<=1){let s=new Error(__sfx("5ouo5Y+35aSx6LSl"));for(let i of e)try{return await i()}catch(a){s=a}throw s}let n=[],o=new Error(__sfx("5ouo5Y+35aSx6LSl"));for(let s=0;s<e.length;s+=xt){let i=e.slice(s,s+xt);try{return await Po(i)}catch(a){o=a,n.push(Bn(a))}}throw new Error(__sfx("5YWo6YOoIA==")+e.length+__sfx("IOS4quWAmemAieWdh+Wksei0pe+8iOWIhiA=")+n.length+__sfx("IOaJue+8jOavj+aJueacgOWkmiA=")+xt+__sfx("IOS4quW5tuWPke+8ie+8mgo=")+n.join(`
4
4
  `),{cause:o})}async function Fn(e,t){let n=[...e];if(!t)return n;try{let o=await me(t),r=new Set(n.map(s=>`${s.ip}:${s.port}`));for(let s of o){let i=`${s.ip}:${s.port}`;r.has(i)||(r.add(i),n.push(s))}}catch{}return n}async function Ao(e,t,n){if(e.length===0)return null;for(let o=0;o<e.length;o+=oe){let s=e.slice(o,o+oe).map(i=>t({source:"relay",host:i.ip,port:i.port,label:__sfx("5Y+N5LujIA==")+i.label+""}));try{return await Pt(s,n)}catch{}}return null}async function ye(e){let t=e.proxies??[],n=e.concurrent??!0;if(!e.skipTargetPolicy&&t.length===0){let h=at(e.hostname);if(h)throw new _(e.hostname,h)}let o=e.budgetMs??po,r=Date.now()+o,s=[...e.optimizedIps??[]],i=!1;if(e.resolvePreferred)try{let h=await Le(e.hostname,e.port,{deadline:r});if(h.length>0){i=!0;for(let E of h)s.push({ip:E.hostname,port:E.port})}}catch{}let a=Z(e.hostname),l=i&&s.length>0&&s.every(h=>Z(h.ip)),f=[...e.relay??[]],c=l||a;c&&e.relayPool&&(f=await Fn(f,{...e.relayPool,deadline:r}));let u=c?f.slice(0,oe):[],p=c?f.slice(oe):[],g=Dn({targetHost:e.hostname,targetPort:e.port,optimizedIps:s,proxies:t,deprioritizeDirect:a||l,relay:u,relayAsPrimary:u.length>0});if(g.length===0)throw new Error(__sfx("5rKh5pyJ5Y+v55So55qE5Ye656uZ5ouo5Y+35pa55byP"));let b=h=>async()=>{let E=r-Date.now();if(E<=0)throw new Error(__sfx("5ouo5Y+36aKE566X5bey55So5bC977yI")+o+"ms):"+e.hostname+":"+e.port+"");let v=Math.max(200,Math.min(e.timeoutMs??At,E)),ne={...e,timeoutMs:v};try{if(!yo(h)&&go(e.hostname))throw new _(e.hostname,yn);if(!e.skipTargetPolicy&&h.source!=="proxy"&&h.source!=="relay"){let Y=at(h.host);if(Y)throw new _(h.host,Y)}return h.source==="proxy"&&h.via?await bo(ne,{host:h.via.host,port:h.via.port,kind:h.via.kind,username:h.via.username,password:h.via.password,serverName:h.via.serverName}):await ho({...ne,hostname:h.host,port:h.port})}catch(Y){let ce=On(Y,h.label);throw e.onFailure?.(ce),Y}},R=Un(g),{landing:C,[__sfx("cHJveHlJcA==")]:d,direct:w,fallback:x}=R,L=C.length>0||d.length>0,z=async()=>{if(C.length===0)throw new Error(__sfx("5pyq6YWN572u6JC95Zyw5Luj55CG"));let h;for(let E of C)try{return await b(E)()}catch(v){h=v}throw h??new Error(__sfx("6JC95Zyw5Luj55CG5YWo6YOo5aSx6LSl"))},j=async()=>{if(d.length===0)throw new Error(__sfx("5pyq6YWN572uIFByb3h5SVA="));return await Pt(d.map(b),!0)},V=async()=>{let h;if(C.length>0)try{return await z()}catch(E){h=E}if(d.length>0)try{return await j()}catch(E){h=E}throw h??new Error(__sfx("5rKh5pyJ5Y+v55So55qE5Luj55CG"))},te=async()=>await Pt(w.map(b),n),k=async()=>{let h=p;return h.length===0&&e.relayPool&&(h=await Fn([],{...e.relayPool,deadline:r})),await Ao(h,b,n)},W=async()=>{for(let h of x)try{return await b(h)()}catch{}return null};if(!L)try{return await te()}catch(h){let E=await k();if(E)return E;let v=await W();if(v)return v;throw h}let D=e.proxyMode??"only",Pe=a||l;if(D==="only")try{return await V()}catch(h){let E=await k();if(E)return E;let v=await W();if(v)return v;throw h}if(D==="global"||D==="smart"&&Pe)try{return await V()}catch(h){if(D==="global")try{return await te()}catch{}let E=await k();if(E)return E;let v=await W();if(v)return v;throw h}try{return await te()}catch(h){try{return await V()}catch{}let E=await k();if(E)return E;let v=await W();if(v)return v;throw h}}var wt,At,po,xt,wo,Et=P(()=>{"use strict";dn();mn();lt();B();De();he();yt();bt();wt=null;At=8e3,po=15e3;xt=6,wo=8});async function Hn(e,t,n,o=!0,r,s){let i=e.getReader(),a=t.getWriter();try{for(;!n?.exhausted;){let l;try{l=await i.read()}catch(c){s?.(c,"read");break}if(l.done)break;let f=l.value;if(!(!f||f.byteLength===0)){if(r?.(f.byteLength))break;try{await a.write(f)}catch(c){s?.(c,"write");break}}}}finally{if(o)try{await a.close()}catch{}else try{a.releaseLock()}catch{}try{i.releaseLock()}catch{}}}var se,Me=P(()=>{"use strict";se=class{constructor(t){this.limitBytes=t}limitBytes;total=0;get enabled(){return this.limitBytes>0}get bytes(){return this.total}add(t){return this.limitBytes<=0||t<=0?!1:(this.total+=t,this.total>this.limitBytes)}}});var Yn={};Ee(Yn,{diagnosticCounters:()=>To,[__sfx("aGFuZGxlV2ViU29ja2V0")]:()=>ze,recentDiagnostics:()=>Co,recentRoutes:()=>Ro,recordDiagnostics:()=>$,truncateCloseReason:()=>Wn});function Wn(e,t=123){let n=new TextEncoder;if(n.encode(e).length<=t)return e;let o=e.slice(0,t);for(;n.encode(o).length>t;)o=o.slice(0,-1);o=o.replace(/\uFFFD+$/,"");let r="\u2026";for(;o.length>0&&n.encode(o+r).length>t;)o=o.slice(0,-1);return o+r}function To(){return{...ie}}function Ro(){return He}function jn(e,t,n){He.unshift({at:Date.now(),target:e,via:t.via,endpoint:t.endpoint,cfTarget:Z(e.split(":")[0]??""),publicDns:Ln(e.split(":")[0]??""),phase:n}),He.length>20&&(He.length=20)}function $(e,t,n){Be.unshift({at:Date.now(),target:e,failures:t,summary:n}),Be.length>Kn&&(Be.length=Kn)}function Co(){return Be}function Io(e){if(!e)return new Uint8Array(0);let t=e.trim();if(!t||t.length>16384)return new Uint8Array(0);try{let n=t.replace(/-/g,"+").replace(/_/g,"/"),o=n.length%4===0?"":"=".repeat(4-n.length%4),r=atob(n+o);if(r.length<17||r.length>8192)return new Uint8Array(0);let s=new Uint8Array(r.length);for(let i=0;i<r.length;i++)s[i]=r.charCodeAt(i);return s}catch{return new Uint8Array(0)}}async function ze(e,t,n,o,r,s){let[i,a]=Object.values(new WebSocketPair);try{a.accept({allowHalfOpen:!0})}catch{a.accept()}a.binaryType="arraybuffer";let l=Io(e.headers.get(__sfx("c2VjLXdlYnNvY2tldC1wcm90b2NvbA=="))),f=!1,c=null,u=null,p=new ve,g=null,b=null,R=()=>{b&&(clearTimeout(b),b=null)},C=!1,d=new ke,w=null,x=!1,L=!1,z=null,j=null,V=m=>{try{a.send(m)}catch{}},te=m=>{let y=new Uint8Array(2+m.byteLength);y[0]=0,y[1]=m.byteLength,y.set(m,2),V(y)},k=(m,y)=>{x=!0;try{a.close(m,Wn(y))}catch{}W()},W=()=>{if(!L){if(L=!0,Y(),R(),g&&(clearTimeout(g),g=null),D&&(clearTimeout(D),D=null),w){let m=w;w=null;try{m.cancel()}catch{}}if(c){let m=c.close;if(m)try{m()}catch{}else try{c.writable.close()}catch{}}}},D=null,Pe=new Set,h=0,E=[],v=0,ne=m=>{if(!(m.byteLength===0||re>0)){if(v+m.byteLength>Xn){k(1009,__sfx("5pyq56Gu6K6k6YCa6Lev55qE5LiK6KGM5pWw5o2u6L+H5aSa"));return}if(Fe+m.byteLength>So){k(1009,__sfx("5a6e5L6L5YaF5a2Y6aKE566X5bey5ruh77yM6K+36YeN6K+V"));return}E.push(m),v+=m.byteLength,Fe+=m.byteLength}},Y=()=>{Fe=Math.max(0,Fe-v),E=[],v=0},ce=0,pr=()=>{ce+=1},Nt=async()=>{if(!c)return;let m=++ce,y=c.readable.getReader();w=y,D&&clearTimeout(D);let S=setTimeout(()=>{D===S&&(D=null),!(re>0)&&v!==0&&zt("stall")},Vn);D=S;try{for(;;){let{done:M,value:U}=await y.read();if(M)break;if(U&&U.byteLength>0){let T=re===0;if(re+=U.byteLength,T&&Y(),Mt.add(U.byteLength)){Ft();return}let O=d.yieldCount;await d.onChunk(U.byteLength),d.yieldCount>O&&ie.downlinkYields++,V(U)}}}catch{}finally{try{y.releaseLock()}catch{}if(clearTimeout(S),D===S&&(D=null),w===y&&(w=null),m!==ce||x)return;if(re===0&&v>0&&h<St&&!C){zt("eof");return}let M=c;k(1e3,M?`done via=${M.via} ep=${M.endpoint}`:"done")}},re=0,Mt=new se((n.dataBudgetMB||0)*1024*1024),Ft=()=>{let m=__sfx("5Y2V6L+e5o6l5rWB6YeP6LaF6L+HIA==")+n.dataBudgetMB+__sfx("TUIg5LiK6ZmQ");$(z?`${z.hostname}:${z.port}`:__sfx("5pyq5bu656uL5Ye656uZ"),[],m),k(1009,m)},Bt=async m=>{let y=u;if(y)try{await p.write(()=>u===y?y:null,m)}catch{W()}},mr=async m=>{if(l.byteLength===0)return;let y=l;l=new Uint8Array(0),ne(y),await m.write(y)},Ht=m=>{if(t===__sfx("dmxlc3M=")){let S=_t(m,n.uuid);return S?{command:S.header.command,port:S.header.port,hostname:S.header.hostname,headerLength:S.consumed}:null}let y=on(m,n[__sfx("dHJvamFuUGFzc3dvcmQ=")]);return y?{command:y.header.command,port:y.header.port,hostname:y.header.hostname,headerLength:y.consumed}:null},hr=()=>{g&&(clearTimeout(g),g=null)},gr=async()=>{if(!(x||f)){if(Ht(l)){await Je();return}k(1008,l.byteLength===0?__sfx("5o+h5omL6LaF5pe277ya5pyq5pS25Yiw5Y2P6K6u5aS0"):__sfx("5o+h5omL6LaF5pe277ya5Y2P6K6u5aS05LiN5a6M5pW05oiW6K6k6K+B5aSx6LSl"))}},Je=async()=>{if(x||f)return;let m=Ht(l);if(!m){l.byteLength>0&&!g&&(g=setTimeout(()=>{g=null,gr().catch(T=>k(1011,String(T)))},ko));return}if(hr(),R(),f)return;f=!0,z=m;let y=t===__sfx("dmxlc3M=")?Qt:rn;if(m.command===y){if(t===__sfx("dmxlc3M=")&&n.udpDns==="doh"&&m.port===53){te(new Uint8Array(0)),j=new Ce({endpoint:n.udpDnsEndpoint,send:V});let T=l.subarray(m.headerLength);T.byteLength>0&&j.push(T);return}k(1002,n.udpDns==="doh"?__sfx("VURQIOS7heaUr+aMgSBETlPvvIg1MyDnq6/lj6PvvIk="):__sfx("VURQIOacquWQr+eUqO+8iOmdouadv+WPr+W8gOWQryBETlMgb3ZlciBEb0jvvIk="));return}t===__sfx("dmxlc3M=")&&te(new Uint8Array(0));let S=[],M=null;try{c=await ye({hostname:m.hostname,port:m.port,proxies:o,timeoutMs:zn,concurrent:n.concurrentDial,nat64:n.nat64||void 0,proxyMode:n.proxyMode,resolvePreferred:n.resolvePreferred,relayPool:{userEntries:n.relayPool||void 0,useBuiltin:n.useBuiltinRelay,colo:typeof e.cf?.colo=="string"?e.cf.colo:void 0},onFailure:T=>{S.push(T),s?.failures.push(T)}})}catch(T){M=T}if(!c){let T=S.length>0?S.map(O=>Nn(O)).join(`
5
- `):__sfx("5Ye656uZ6L+e5o6l5aSx6LSl77ya")+String(M)+"";$(`${m.hostname}:${m.port}`,S,T),k(1011,T);return}u=c.writable.getWriter(),jn(`${m.hostname}:${m.port}`,c,"initial");let U=l.byteLength>m.headerLength?l.subarray(m.headerLength):new Uint8Array(0);U.byteLength>0&&(ne(U),await Bt(U)),l=new Uint8Array(0),r?.waitUntil(Nt())},zt=async m=>{if(x||C)return;let y=z;if(!y){k(1011,__sfx("5Ye656uZ5peg5pWw5o2u77ya55uu5qCH5pyq6Kej5p6Q"));return}if(h>=St){k(1011,__sfx("5Ye656uZ5peg5pWw5o2u77ya55u06L+e5LiO5Y+N5Luj5YWl5Y+j5Z2H5peg5ZON5bqU"));return}C=!0;let S=ln({via:c?.via,port:y.port,userProxyConfigured:o.length>0||!!n[__sfx("cHJveHlJcA==")],aggressive:n.aggressiveRedial===!0});if(!S.allowed){ie.guardedRedials++,$(`${y.hostname}:${y.port}`,[],__sfx("5Ye656uZ5peg5pWw5o2u77ya")+S.reason+__sfx("77yb5pyq5YiH5o2i5Y+N5Luj77yI5Y+v5byA5ZCvIGFnZ3Jlc3NpdmVSZWRpYWzvvIk=")),k(1011,__sfx("5Ye656uZ5peg5pWw5o2u77ya")+S.reason+"");return}h++,m==="stall"?ie.stallRedials++:ie.eofRedials++,$(`${y.hostname}:${y.port}`,[],m==="stall"?__sfx("55u06L+eIA==")+Vn+__sfx("bXMg5peg5LiL6KGM5pWw5o2u77yM5pS56LWw5Y+N5Luj5YWl5Y+j"):__sfx("5Ye656uZ6Zu25LiL6KGM5Y2zIEVPRi9SZXNldO+8jOeri+WNs+aUuei1sOWPjeS7o+WFpeWPow=="));let M=[];try{M=await me({userEntries:n.relayPool||void 0,useBuiltin:n.useBuiltinRelay,colo:typeof e.cf?.colo=="string"?e.cf.colo:void 0})}catch{M=[]}let U=M.filter(T=>!Pe.has(`${T.ip}:${T.port}`));if(U.length===0){k(1011,__sfx("5Ye656uZ5peg5pWw5o2u77ya5peg5Y+N5Luj5YWl5Y+j5Y+v55So"));return}for(let T of U.slice(0,St)){if(Pe.add(`${T.ip}:${T.port}`),pr(),c){let O=c;if(O.close)try{O.close()}catch{}}u=null,re=0;try{let O=await ye({hostname:T.ip,port:T.port,timeoutMs:zn,resolvePreferred:!1,skipTargetPolicy:!0,proxies:n.aggressiveRedial?o:void 0,proxyMode:n.aggressiveRedial?n.proxyMode:void 0});if(!O)continue;c=O,jn(`${y.hostname}:${y.port}`,O,"redial");let Ge=O.writable.getWriter();u=Ge;let Xt=0;for(let Ae of E)Xt+=Ae.byteLength;let Qe=new Uint8Array(Xt),Kt=0;for(let Ae of E)Qe.set(Ae,Kt),Kt+=Ae.byteLength;await p.run(async()=>{Qe.byteLength>0&&await Ge.write(Qe),await mr(Ge)}),$(`${y.hostname}:${y.port}`,[],__sfx("5bey5YiH5o2i5Y+N5Luj5YWl5Y+jIA==")+T.ip+":"+T.port+""),r?.waitUntil(Nt());return}catch(O){$(`${y.hostname}:${y.port}`,[],__sfx("5Y+N5Luj5YWl5Y+jIA==")+T.ip+":"+T.port+__sfx("IOWksei0pe+8mg==")+String(O)+"")}}k(1011,__sfx("5Ye656uZ5peg5pWw5o2u77ya5omA5pyJ5Y+N5Luj5YWl5Y+j5Z2H5aSx6LSl"))};a.addEventListener("message",m=>{(async()=>{let y=m.data,S=typeof y=="string"?new TextEncoder().encode(y):new Uint8Array(y);if(S.byteLength!==0){if(R(),Mt.add(S.byteLength)){Ft();return}if(!f){if(l=rt(l,S),l.byteLength>Eo){k(1009,__sfx("5o+h5omL5aS06LaF6L+HIDY0S0I="));return}await Je();return}if(j){j.push(S);return}if(!u){if(l=rt(l,S),l.byteLength>Xn){k(1009,__sfx("5ouo5Y+35pyf6Ze05pWw5o2u6L+H5aSa"));return}return}ne(S),await Bt(S)}})()});let Vt=()=>{W()};a.addEventListener("close",Vt),a.addEventListener("error",Vt),l.byteLength>0?Je().catch(m=>k(1011,String(m))):b=setTimeout(()=>{b=null,!(x||f||l.byteLength>0)&&(ie.firstPacketTimeouts++,k(1008,__sfx("6aaW5YyF6LaF5pe277ya5pyq5pS25Yiw5Y2P6K6u5aS0")))},vo);try{return new Response(null,{status:101,[__sfx("d2ViU29ja2V0")]:i})}catch(m){return console.error(__sfx("W+iHqueglOaVsOaNrumdol0gMTAxIOWTjeW6lOaehOmAoOWksei0pe+8mg=="),m),new Response(null,{status:200})}}var zn,Vn,St,Eo,Xn,So,Fe,Be,Kn,ie,He,ko,vo,Tt=P(()=>{"use strict";tt();sn();an();pe();cn();un();Et();Me();yt();he();zn=5e3,Vn=2500,St=2,Eo=64*1024,Xn=8*1024*1024,So=32*1024*1024,Fe=0;Be=[],Kn=20,ie={stallRedials:0,eofRedials:0,guardedRedials:0,firstPacketTimeouts:0,downlinkYields:0};He=[];ko=2e3,vo=8e3});var Jn={};Ee(Jn,{[__sfx("aGFuZGxlWGh0dHA=")]:()=>Rt,[__sfx("cmVjZW50WGh0dHBEaWFnbm9zdGljcw==")]:()=>Uo,[__sfx("cmVjb3JkWGh0dHBEaWFnbm9zdGljcw==")]:()=>be});function Do(e,t){return new Promise(n=>{let o=setTimeout(()=>n(null),t);e.then(r=>{clearTimeout(o),n(r)},()=>{clearTimeout(o),n(null)})})}function be(e,t,n){Ve.unshift({at:Date.now(),target:e,...t,summary:n}),Ve.length>20&&(Ve.length=20)}function Uo(){return Ve}async function Rt(e,t,n){let o=e.body;if(!o)return new Response(__sfx("57y65bCR6K+35rGC5L2T"),{status:400});let r=new Q(o),s=await Do(Zt(r,t.uuid),Lo);if(!s)return await r.cancel("header timeout"),new Response(__sfx("VkxFU1Mg5aS06Kej5p6Q5aSx6LSl"),{status:400});if(s.header.command!==Gt)return await s.payload.cancel("unsupported UDP"),new Response(__sfx("WEhUVFAg5pqC5LiN5pSv5oyBIFVEUA=="),{status:400});let i;try{i=await ye({hostname:s.header.hostname,port:s.header.port,proxies:n,nat64:t.nat64,concurrent:t.concurrentDial,proxyMode:t.proxyMode,resolvePreferred:t.resolvePreferred,relayPool:{userEntries:t.relayPool||void 0,useBuiltin:t.useBuiltinRelay,colo:typeof e.cf?.colo=="string"?e.cf.colo:void 0},onFailure:d=>{be(`${s.header.hostname}:${s.header.port}`,d,__sfx("WEhUVFAg5Ye656uZ5aSx6LSl77yI")+d.candidate+"):"+d.message+"")}})}catch(d){be(`${s.header.hostname}:${s.header.port}`,{kind:"dial",message:String(d),candidate:"all"},__sfx("WEhUVFAg5Ye656uZ5YWo6YOo5aSx6LSl77ya")+String(d)+"");try{s.payload.cancel("dial failed").catch(()=>{})}catch{}return new Response(__sfx("5Ye656uZ5LiN5Y+v55So"),{status:502})}let a=s.header.addons;if(a.byteLength>255)return new Response(__sfx("QWRkb25zIOmVv+W6pui2heWHuiBWTEVTUyDljY/orq7kuIrpmZA="),{status:400});let l=new Uint8Array(2+a.byteLength);l[0]=s.header.version,l[1]=a.byteLength,l.set(a,2);let f=!1,c=null,u=!1,p=new se((t.dataBudgetMB||0)*1024*1024),g=null,b=()=>{if(u)return;u=!0;let d=__sfx("5Y2V6L+e5o6l5rWB6YeP6LaF6L+HIA==")+t.dataBudgetMB+__sfx("TUIg5LiK6ZmQ");if(be(`${s.header.hostname}:${s.header.port}`,{kind:"budget",message:d,candidate:"traffic"},d),i.close)try{i.close()}catch{}try{g?.close()}catch{}},R=d=>p.add(d)?(b(),!0):!1;Hn(s.payload,i.writable,void 0,!1,R,(d,w)=>{let x=d instanceof Error?d.message:String(d),L=`relay-${w}`;/cancel|abort|closed/i.test(x)?L=`relay-${w}-client-cancel`:/reset|broken pipe/i.test(x)&&(L=`relay-${w}-upstream-reset`),be(`${s.header.hostname}:${s.header.port}`,{kind:L,message:x.slice(0,200),candidate:i.endpoint},__sfx("WEhUVFAg5Lit57un")+w==="read"?"\u8BFB\u4E0A\u6E38":"\u5199\u76EE\u6807"+__sfx("5aSx6LSl77yI")+L+"):"+x.slice(0,120)+"")}).catch(()=>{});let C=new ReadableStream({start(d){g=d,d.enqueue(l),f=!0},async pull(d){if(!(u||!f)){c||(c=i.readable.getReader());try{let{done:w,value:x}=await c.read();if(u)return;if(w){if(i.close)try{i.close()}catch{}d.close();return}if(x&&x.byteLength>0){if(p.add(x.byteLength)){b();return}d.enqueue(x)}}catch(w){if(u)return;if(i.close)try{i.close()}catch{}try{d.error(w)}catch{}}}},cancel(d){u=!0;try{i.readable.cancel(d)}catch{}if(i.close)try{i.close()}catch{}}});return new Response(C,{status:200,headers:{"Content-Type":"text/event-stream","Cache-Control":"no-store","X-Accel-Buffering":"no"}})}var Lo,Ve,Ct=P(()=>{"use strict";pe();tt();Me();Et();Lo=2e3;Ve=[]});function Ke(){return new Response(JSON.stringify({build:kt,version:Oo,ts:Date.now()}),{status:200,headers:{"Content-Type":"application/json","Cache-Control":"no-store","Access-Control-Allow-Origin":"*"}})}var kt,Oo,Xe,vt=P(()=>{"use strict";kt="86b1357-d5c0a377",Oo=__sfx("MC4xNS45"),Xe=__sfx("L19fY2ZwX3ZlcnNpb24=")});function Gn(e){return e[__sfx("S1Y=")]?new ae(e[__sfx("S1Y=")]):new It}var ae,It,je=P(()=>{"use strict";ae=class{constructor(t){this.kv=t}kv;async get(t){return await this.kv.get(t)}async put(t,n,o){o&&o>=60?await this.kv.put(t,n,{expirationTtl:o}):await this.kv.put(t,n)}async delete(t){await this.kv.delete(t)}async list(t){let n=[],o;do{let r=await this.kv.list({prefix:t,cursor:o});for(let s of r.keys)n.push(s.name);o=r.list_complete?void 0:r.cursor}while(o);return n}},It=class{data=new Map;async get(t){let n=this.data.get(t);return n?n.expiresAt>0&&n.expiresAt<=Date.now()?(this.data.delete(t),null):n.value:null}async put(t,n,o){let r=o?Date.now()+o*1e3:0;this.data.set(t,{value:n,expiresAt:r})}async delete(t){this.data.delete(t)}async list(t){return[...this.data.keys()].filter(n=>n.startsWith(t))}}});function ee(e,t){if(e==null)return t;let n=String(e).trim();if(n==="")return t;let o=Number(n);return Number.isFinite(o)?o:t}function F(e,t){if(e==null||e==="")return t;let n=String(e).trim().toLowerCase();return["1","true","yes","on"].includes(n)?!0:["0","false","no","off"].includes(n)?!1:t}function No(e){let t=e.trim().toLowerCase();return t==="global"||t==="fallback"||t==="smart"?t:"only"}function qn(e){return e.trim().toLowerCase()==="signed"?"signed":"legacy"}function Zn(e){return e.trim().toLowerCase()==="doh"?"doh":"off"}function I(e,t){return e==null?t:String(e)}function Mo(e){return{uuid:I(e[__sfx("VVVJRA==")],""),[__sfx("dHJvamFuUGFzc3dvcmQ=")]:I(e[__sfx("VFJPSkFOX1BBU1NXT1JE")],""),wsPath:I(e[__sfx("V1NfUEFUSA==")]||e[__sfx("UEFUSA==")],A.wsPath),[__sfx("dHJvamFuUGF0aA==")]:A[__sfx("dHJvamFuUGF0aA==")],[__sfx("eGh0dHBQYXRo")]:A[__sfx("eGh0dHBQYXRo")],add:I(e[__sfx("QURE")],""),addApi:I(e[__sfx("QUREQVBJ")],""),addCsv:I(e[__sfx("QUREX0NTVg==")],""),poolOfficial:F(e[__sfx("T0ZGSUNJQUxfSVA=")],A.poolOfficial),officialCount:ee(e[__sfx("T0ZGSUNJQUxfSVBfQ09VTlQ=")],A.officialCount),poolDomain:F(e[__sfx("UFJFRkVSUkVEX0RPTUFJTg==")],A.poolDomain),domainCount:ee(e[__sfx("UFJFRkVSUkVEX0RPTUFJTl9DT1VOVA==")],A.domainCount),poolManual:F(e[__sfx("TUFOVUFMX0lQ")],A.poolManual),poolCountries:I(e[__sfx("UE9PTF9DT1VOVFJJRVM=")],A.poolCountries),dls:ee(e[__sfx("RExT")],0),maxLatency:ee(e[__sfx("TUFYX0xBVEVOQ1k=")],0),maxNodes:0,[__sfx("cHJveHlJcA==")]:I(e[__sfx("UFJPWFlJUA==")],""),[__sfx("c29ja3M1")]:I(e[__sfx("U09DS1M1")],""),httpProxy:I(e[__sfx("SFRUUF9QUk9YWQ==")],""),proxyMode:No(I(e[__sfx("UFJPWFlfTU9ERQ==")],"")),nat64:I(e[__sfx("TkFUNjQ=")],""),concurrentDial:F(e[__sfx("VENQX0NPTkNVUlJFTlRfRElBTA==")],!0),dataBudgetMB:ee(e[__sfx("REFUQV9CVURHRVRfTUI=")],A.dataBudgetMB),resolvePreferred:F(e[__sfx("UkVTT0xWRV9QUkVGRVJSRUQ=")],A.resolvePreferred),aggressiveRedial:F(e[__sfx("QUdHUkVTU0lWRV9SRURJQUw=")],A.aggressiveRedial),relayPool:I(e[__sfx("UkVMQVlfUE9PTA==")],""),useBuiltinRelay:F(e[__sfx("VVNFX0JVSUxUSU5fUkVMQVk=")],A.useBuiltinRelay),[__sfx("ZW5hYmxlVHJvamFu")]:F(e[__sfx("RU5BQkxFX1RST0pBTg==")]??e[__sfx("VFJPSkFO")],A[__sfx("ZW5hYmxlVHJvamFu")]),[__sfx("ZW5hYmxlWGh0dHA=")]:F(e[__sfx("RU5BQkxFX1hIVFRQ")]??e[__sfx("WEhUVFA=")],A[__sfx("ZW5hYmxlWGh0dHA=")]),subDomain:"",subProtocol:"both",subTransport:"both",subVariants:I(e[__sfx("U1VCX1ZBUklBTlRT")],A.subVariants),subName:I(e[__sfx("U1VCX05BTUU=")],A.subName).trim()||A.subName,subPorts:I(e[__sfx("U1VCX1BPUlRT")],A.subPorts),clientFingerprint:A.clientFingerprint,ech:F(e[__sfx("RUNI")],A.ech),echHost:I(e[__sfx("RUNIX0hPU1Q=")],A.echHost),echDns:I(e[__sfx("RUNIX0ROUw==")],A.echDns),tlsFragment:!1,tlsFragmentSize:A.tlsFragmentSize,tlsFragmentDelay:A.tlsFragmentDelay,subToken:qn(I(e[__sfx("U1VCX1RPS0VOX01PREU=")],"")),subTokenTtlDays:ee(e[__sfx("U1VCX1RPS0VOX1RUTF9EQVlT")],A.subTokenTtlDays),unlockProbe:F(e[__sfx("VU5MT0NLX1BST0JF")],A.unlockProbe),udpDns:Zn(I(e[__sfx("VURQX0ROUw==")],"")),udpDnsEndpoint:I(e[__sfx("VURQX0ROU19FTkRQT0lOVA==")],A.udpDnsEndpoint)}}function Fo(e,t){let n={...e};for(let[o,r]of Object.entries(t))if(r!=null)if(o==="dls"||o==="maxLatency"||o==="maxNodes"||o==="officialCount"||o==="domainCount"||o==="dataBudgetMB"||o==="subTokenTtlDays")n[o]=ee(r,0);else if(o==="concurrentDial"||o==="resolvePreferred"||o==="aggressiveRedial"||o==="useBuiltinRelay"||o===__sfx("ZW5hYmxlVHJvamFu")||o===__sfx("ZW5hYmxlWGh0dHA=")||o==="tlsFragment"||o==="ech"||o==="poolOfficial"||o==="poolDomain"||o==="poolManual"||o==="unlockProbe")n[o]=F(r,!1);else if(o==="subProtocol"){let s=String(r);n[o]=s===__sfx("dmxlc3M=")||s===__sfx("dHJvamFu")||s==="both"?s:"both"}else if(o==="subTransport"){let s=String(r);n[o]=s==="ws"||s===__sfx("eGh0dHA=")||s==="both"?s:"both"}else o==="subToken"?n[o]=qn(String(r)):o==="udpDns"?n[o]=Zn(String(r)):n[o]=String(r);return n}async function _n(e,t){let n=Mo(t),o=await e.get(Qn),r={};if(o)try{r=JSON.parse(o)}catch{r={}}let s=Fo(n,r),i=!1,a=e instanceof ae;return!s.uuid&&a&&(s.uuid=qe(),i=!0),!s[__sfx("dHJvamFuUGFzc3dvcmQ=")]&&a&&(s[__sfx("dHJvamFuUGFzc3dvcmQ=")]=qe().replace(/-/g,"").slice(0,16),i=!0),s.officialCount<1&&(s.officialCount=A.officialCount,i=!0),s.domainCount<1&&(s.domainCount=A.domainCount,i=!0),i&&await Bo(e,s),s}async function Bo(e,t){await e.put(Qn,JSON.stringify(t))}var Qn,A,We=P(()=>{"use strict";J();je();Qn="CONFIG",A={uuid:"",[__sfx("dHJvamFuUGFzc3dvcmQ=")]:"",wsPath:__sfx("L3ZsZXNz"),[__sfx("dHJvamFuUGF0aA==")]:__sfx("L3Ryb2phbg=="),[__sfx("eGh0dHBQYXRo")]:__sfx("L3hodHRw"),add:"",addApi:"",addCsv:"",poolOfficial:!0,officialCount:20,poolDomain:!0,domainCount:10,poolManual:!0,poolCountries:"",dls:0,maxLatency:0,maxNodes:0,[__sfx("cHJveHlJcA==")]:"",[__sfx("c29ja3M1")]:"",httpProxy:"",proxyMode:"only",nat64:"",concurrentDial:!0,dataBudgetMB:0,resolvePreferred:!0,aggressiveRedial:!1,relayPool:"",useBuiltinRelay:!0,[__sfx("ZW5hYmxlVHJvamFu")]:!0,[__sfx("ZW5hYmxlWGh0dHA=")]:!0,subDomain:"",subProtocol:__sfx("dmxlc3M="),subTransport:"ws",subVariants:__sfx("dmxlc3Mtd3M="),subName:__sfx("Q0ZQaWxvdA=="),subPorts:"443",clientFingerprint:"chrome",ech:!1,echHost:__sfx("Y2xvdWRmbGFyZS1lY2guY29t"),echDns:"",tlsFragment:!1,tlsFragmentSize:"10-20",tlsFragmentDelay:"10-20",subToken:"legacy",subTokenTtlDays:0,unlockProbe:!1,udpDns:"off",udpDnsEndpoint:"https://dns.google/dns-query"}});var $n,Ho,ii,zo,ai,er=P(()=>{"use strict";$n={[__sfx("SEs=")]:["HKG"],[__sfx("VFc=")]:["TPE","KHH"],[__sfx("SlA=")]:["NRT","KIX","CTS","FUK"],[__sfx("S1I=")]:["ICN","PUS"],[__sfx("U0c=")]:["SIN"],[__sfx("TVk=")]:["KUL"],[__sfx("VEg=")]:["BKK"],[__sfx("Vk4=")]:["SGN","HAN"],[__sfx("SUQ=")]:["CGK","DPS"],[__sfx("UEg=")]:["MNL"],[__sfx("SU4=")]:["BOM","MAA","DEL"],[__sfx("QVU=")]:["SYD","MEL","BNE","PER"],[__sfx("Tlo=")]:["AKL"],[__sfx("VVM=")]:["LAX","SJC","SEA","ORD","DFW","IAD","EWR","ATL","MIA","DEN","PHX","BOS"],[__sfx("Q0E=")]:["YYZ","YVR","YYC"],[__sfx("R0I=")]:["LHR","MAN"],[__sfx("REU=")]:["FRA","MUC","BER"],[__sfx("RlI=")]:["CDG","MRS"],[__sfx("Tkw=")]:["AMS"],[__sfx("SVQ=")]:["MXP","FCO"],[__sfx("RVM=")]:["MAD","BCN"],[__sfx("U0U=")]:["ARN"],[__sfx("Q0g=")]:["ZRH"],[__sfx("QVQ=")]:["VIE"],[__sfx("UEw=")]:["WAW"],[__sfx("UlU=")]:["DME","SVO"],[__sfx("VFI=")]:["IST"],[__sfx("QUU=")]:["DXB"],[__sfx("SUw=")]:["TLV"],[__sfx("WkE=")]:["JNB"],[__sfx("QlI=")]:["GRU","GIG"],[__sfx("QVI=")]:["EZE"],[__sfx("Q0w=")]:["SCL"],[__sfx("TVg=")]:["MEX"]},Ho=__sfx("SEtH6aaZ5rivLFRQReWPsOWMlyxOUlTkuJzkuqwsS0lY5aSn6ZiqLElDTummluWwlCxTSU7mlrDliqDlnaEsS1VM5ZCJ6ZqG5Z2hLEJLS+abvOiwtyxTR07og6Hlv5fmmI7luIIsTU5M6ams5bC85ouJLFNZROaCieWwvCxNRUzloqjlsJTmnKwsTEFY5rSb5p2J55+2LFNKQ+Wco+S9leWhnixTRUHopb/pm4Xlm74sT1JE6Iqd5Yqg5ZOlLElBROWNjuebm+mhvyxFV1Lnur3nk6blhYssWVla5aSa5Lym5aSaLFlWUua4qeWTpeWNjixMSFLkvKbmlaYsRlJB5rOV5YWw5YWL56aPLENER+W3tOm7jixBTVPpmL/lp4bmlq/nibnkuLksTUFE6ams5b636YeMLEFSTuaWr+W+t+WTpeWwlOaRqSxJU1TkvIrmlq/lnabluIPlsJQsRFhC6L+q5ouc"),ii=(()=>{let e={};for(let t of Ho.split(","))t.length>3&&(e[t.slice(0,3)]=t.slice(3));return e})(),zo=new Map;for(let[e,t]of Object.entries($n))for(let n of t)zo.set(n,e);ai=Object.keys($n)});var tr=P(()=>{"use strict"});var Ei,nr=P(()=>{"use strict";B();J();er();tr();Ei=".cn,qq.com,tencent.com,weixin.qq.com,baidu.com,bdstatic.com,bilibili.com,hdslb.com,taobao.com,tmall.com,jd.com,aliyun.com,alicdn.com,alipay.com,163.com,126.net,zhihu.com,weibo.com,sina.com.cn,youku.com,iqiyi.com,douyin.com,xiaohongshu.com,mi.com,huawei.com,csdn.net,gitee.com,cnblogs.com".split(",")});var Ci,rr=P(()=>{"use strict";je();J();Ci=new TextEncoder});var ji,or=P(()=>{"use strict";We();J();ji=3600*24});function sr(e){return Gn(e)}async function ir(e,t){if(we.config&&Date.now()-we.configAt<Vo)return we.config;let n=await _n(e,t);return we.config=n,we.configAt=Date.now(),n}var Vo,we,Dt=P(()=>{"use strict";je();We();or();Vo=15e3,we={config:null,configAt:0,auth:null,authAt:0}});var lr={};Ee(lr,{clearUnlockCache:()=>qo,runUnlockProbe:()=>Qo});function Jo(e,t,n){return e===200?"ok":e===404?t==="status"?"region":"unknown":e===403||e===451?"blocked":t==="trace"&&/\bloc=[A-Z]{2}\b/.test(n)?"ok":"unknown"}async function Go(e){let t=Date.now(),n=new AbortController,o=setTimeout(()=>n.abort(),jo);try{let r=await fetch(e.url,{method:"GET",redirect:"manual",signal:n.signal,headers:{"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0 Safari/537.36",Accept:"text/html,application/xhtml+xml,*/*"}}),s="";e.mode==="trace"&&(s=(await r.text()).slice(0,512));let i=/\bloc=([A-Z]{2})\b/.exec(s)?.[1];return{id:e.id,status:r.status,verdict:Jo(r.status,e.mode,s),ms:Date.now()-t,...i?{loc:i}:{}}}catch(r){let s=r instanceof Error?r.message:String(r);return{id:e.id,status:0,verdict:"unknown",ms:Date.now()-t,error:/abort/i.test(s)?"timeout":"fetch-failed"}}finally{clearTimeout(o)}}async function Qo(e,t){let n=e||"UNK",o=Date.now(),r=le.get(n);if(r&&o-r.at<Wo)return{...r.data,cached:!0};let s=await Promise.all(Ko.map(a=>Go(a))),i={colo:n,region:t,cached:!1,at:o,targets:s};if(le.size>=Yo){let a="",l=Number[__sfx("UE9TSVRJVkVfSU5GSU5JVFk=")];for(let[f,c]of le)c.at<l&&(l=c.at,a=f);a&&le.delete(a)}return le.set(n,{at:o,data:i}),i}function qo(){le.clear()}var Ko,jo,Wo,Yo,le,cr=P(()=>{"use strict";Ko=[{id:"netflix",url:"https://www.netflix.com/title/81215567",mode:"status"},{id:"youtube",url:"https://www.youtube.com/premium",mode:"status"},{id:"gemini",url:"https://gemini.google.com/",mode:"status"}],jo=4e3,Wo=600*1e3,Yo=16,le=new Map});J();var br=8*1024*1024,wr=2*1024*1024,Wt=600*1e3,xr=6*1024*1024*1024,Ze=Date.now(),_e=0;function Yt(e){e-Ze>=Wt&&(Ze=e,_e=0)}function Pr(e,t=Date.now()){Yt(t),_e+=e}function jt(e){return Yt(e),xr-_e}var Ar=(()=>{let e=new Uint8Array(65536),t=2654435769;for(let n=0;n<e.length;n++)t^=t<<13,t^=t>>>17,t^=t<<5,e[n]=t&255;return e})(),Er=5e3;function Sr(e,t=Er){let n=!1,o=setTimeout(()=>{if(!n){n=!0;try{e(1e3,"Probe idle timeout")}catch{}}},t),r=o;return typeof r?.unref=="function"&&r.unref(),{cancel:()=>{n||(n=!0,clearTimeout(o))}}}async function $e(e){let t=new URL(e.url);if(e.headers.get("Upgrade")?.toLowerCase()===__sfx("d2Vic29ja2V0")){let f=new WebSocketPair,[c,u]=Object.values(f);u.accept();let p=Sr((g,b)=>u.close(g,b));return u.addEventListener("message",g=>{let b=typeof g.data=="string"?g.data:"";if(b==="PING"||b==="ping"){p.cancel(),u.send(JSON.stringify({pong:!0,colo:e.cf?.colo??"UNK",clientIp:e.headers.get("CF-Connecting-IP")??""}));try{u.close(1e3,"Probe complete")}catch{}return}p.cancel();try{u.close(1e3,"Probe aborted")}catch{}}),u.addEventListener("close",()=>p.cancel()),u.addEventListener("error",()=>p.cancel()),new Response(null,{status:101,[__sfx("d2ViU29ja2V0")]:c})}let o=Number.parseInt(t.searchParams.get("bytes")??"",10),r=Number.isFinite(o)&&o>0?Math.min(o,br):wr,s=Date.now();if(jt(s)<=0){let f=Math.max(1e3,Ze+Wt-s);return new Response(JSON.stringify({ok:!1,error:"probe budget exhausted"}),{status:429,headers:{"Content-Type":"application/json; charset=utf-8","Cache-Control":"no-store","Retry-After":String(Math.ceil(f/1e3))}})}let i=Ar,a=0,l=new ReadableStream({pull(f){let c=jt(Date.now());if(a>=r||c<=0){f.close();return}let u=Math.min(i.byteLength,r-a,c);f.enqueue(i.subarray(0,u)),a+=u,Pr(u)}});return new Response(l,{status:200,headers:{"Content-Type":"application/octet-stream","Content-Encoding":"identity","Cache-Control":"no-store","Access-Control-Allow-Origin":"*","X-Probe-Bytes":String(r),"X-Probe-Nonce":Te(4)}})}Tt();Ct();bt();vt();J();We();Me();nr();rr();J();function Lt(e){let t=e===200?"Welcome":e===404?"Not Found":"Service Unavailable",n=`<!DOCTYPE html><html lang="zh-CN"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>${t}</title><style>body{margin:0;min-height:100vh;display:flex;align-items:center;justify-content:center;background:#f7f8fa;color:#333;font-family:-apple-system,"Segoe UI","PingFang SC",sans-serif}.c{text-align:center}h1{font-size:22px;font-weight:600;margin:0 0 10px}p{color:#888;font-size:14px;margin:0}</style></head><body><div class="c"><h1>${t}</h1><p>This site is up and running.</p></div></body></html>`;return new Response(n,{status:e,headers:{"Content-Type":"text/html; charset=utf-8","Cache-Control":"no-store","X-Content-Type-Options":"nosniff"}})}Dt();Dt();async function ar(e){let t=sr(e);return await ir(t,e)}function Ut(e){let t=[];return t.push(...ge(e[__sfx("cHJveHlJcA==")],"direct")),t.push(...ge(e[__sfx("c29ja3M1")],__sfx("c29ja3M1"))),t.push(...ge(e.httpProxy,"http")),t}var Ot=6e4,Zo=10,xe=0,Ye=0;function ur(e){return e>=Ye?(xe=0,Ye=e+Ot,!1):xe>=Zo}function fr(e,t,n){if(!n)return!1;let o=(e.headers.get(__sfx("eC1jZnBpbG90LXRva2Vu"))??t.searchParams.get("token")??"").trim();if(!o)return!1;let r=Date.now();return ue(o,n)?(xe=0,!0):(r>=Ye&&(Ye=r+Ot,xe=0),xe+=1,!1)}async function dr(e,t,n){let o=new URL(e.url);if(o.pathname===__sfx("L19fZWRnZV9wcm9iZQ=="))return $e(e);if(o.pathname===Xe||o.pathname===__sfx("L19fdmVyc2lvbg=="))return Ke();if(o.pathname==="/region"&&e.method==="GET"){let{coloToCountry:i}=await Promise.resolve().then(()=>(he(),ht)),a=e.cf?.colo??"",l=a?i(a):"";return new Response(JSON.stringify({ok:!0,colo:a,region:l,timestamp:new Date().toISOString()},null,2),{status:200,headers:{"Content-Type":"application/json; charset=utf-8"}})}let r=await ar(t);if(o.pathname===__sfx("L19fZGlhZw==")){if(ur(Date.now()))return new Response(JSON.stringify({ok:!1,error:"token attempts throttled"},null,2),{status:429,headers:{"Content-Type":"application/json; charset=utf-8","Cache-Control":"no-store","Retry-After":String(Math.ceil(Ot/1e3))}});if(!fr(e,o,r.uuid))return null;let{recentDiagnostics:i,diagnosticCounters:a,recentRoutes:l}=await Promise.resolve().then(()=>(Tt(),Yn)),{[__sfx("cmVjZW50WGh0dHBEaWFnbm9zdGljcw==")]:f}=await Promise.resolve().then(()=>(Ct(),Jn));return new Response(JSON.stringify({ok:!0,impl:"self",build:kt,recent:i(),[__sfx("eGh0dHA=")]:f(),counters:a(),routes:l()},null,2),{status:200,headers:{"Content-Type":"application/json; charset=utf-8","Cache-Control":"no-store"}})}if(o.pathname==="/__unlock_probe"){if(!r.unlockProbe)return null;if(ur(Date.now()))return new Response(JSON.stringify({ok:!1,error:"token attempts throttled"},null,2),{status:429,headers:{"Content-Type":"application/json; charset=utf-8","Cache-Control":"no-store"}});if(!fr(e,o,r.uuid))return null;let{coloToCountry:i}=await Promise.resolve().then(()=>(he(),ht)),{runUnlockProbe:a}=await Promise.resolve().then(()=>(cr(),lr)),l=e.cf?.colo??"",f=l?i(l):"",c=await a(l,f);return new Response(JSON.stringify({ok:!0,...c},null,2),{status:200,headers:{"Content-Type":"application/json; charset=utf-8","Cache-Control":"no-store"}})}let s=e.headers.get("Upgrade")?.toLowerCase();return o.pathname===r.wsPath?s!==__sfx("d2Vic29ja2V0")?null:await ze(e,__sfx("dmxlc3M="),r,Ut(r),n):r[__sfx("ZW5hYmxlVHJvamFu")]&&o.pathname===r[__sfx("dHJvamFuUGF0aA==")]?s!==__sfx("d2Vic29ja2V0")?null:await ze(e,__sfx("dHJvamFu"),r,Ut(r),n):r[__sfx("ZW5hYmxlWGh0dHA=")]&&o.pathname===r[__sfx("eGh0dHBQYXRo")]?e.method!=="POST"?null:await Rt(e,r,Ut(r)):null}vt();var Ma={async fetch(e,t,n){try{return new URL(e.url).pathname===Xe?Ke():await dr(e,t,n)??Lt(200)}catch{return Lt(500)}}};export{Ma as default};
5
+ `):__sfx("5Ye656uZ6L+e5o6l5aSx6LSl77ya")+String(M)+"";$(`${m.hostname}:${m.port}`,S,T),k(1011,T);return}u=c.writable.getWriter(),jn(`${m.hostname}:${m.port}`,c,"initial");let U=l.byteLength>m.headerLength?l.subarray(m.headerLength):new Uint8Array(0);U.byteLength>0&&(ne(U),await Bt(U)),l=new Uint8Array(0),r?.waitUntil(Nt())},zt=async m=>{if(x||C)return;let y=z;if(!y){k(1011,__sfx("5Ye656uZ5peg5pWw5o2u77ya55uu5qCH5pyq6Kej5p6Q"));return}if(h>=St){k(1011,__sfx("5Ye656uZ5peg5pWw5o2u77ya55u06L+e5LiO5Y+N5Luj5YWl5Y+j5Z2H5peg5ZON5bqU"));return}C=!0;let S=ln({via:c?.via,port:y.port,userProxyConfigured:o.length>0||!!n[__sfx("cHJveHlJcA==")],aggressive:n.aggressiveRedial===!0});if(!S.allowed){ie.guardedRedials++,$(`${y.hostname}:${y.port}`,[],__sfx("5Ye656uZ5peg5pWw5o2u77ya")+S.reason+__sfx("77yb5pyq5YiH5o2i5Y+N5Luj77yI5Y+v5byA5ZCvIGFnZ3Jlc3NpdmVSZWRpYWzvvIk=")),k(1011,__sfx("5Ye656uZ5peg5pWw5o2u77ya")+S.reason+"");return}h++,m==="stall"?ie.stallRedials++:ie.eofRedials++,$(`${y.hostname}:${y.port}`,[],m==="stall"?__sfx("55u06L+eIA==")+Vn+__sfx("bXMg5peg5LiL6KGM5pWw5o2u77yM5pS56LWw5Y+N5Luj5YWl5Y+j"):__sfx("5Ye656uZ6Zu25LiL6KGM5Y2zIEVPRi9SZXNldO+8jOeri+WNs+aUuei1sOWPjeS7o+WFpeWPow=="));let M=[];try{M=await me({userEntries:n.relayPool||void 0,useBuiltin:n.useBuiltinRelay,colo:typeof e.cf?.colo=="string"?e.cf.colo:void 0})}catch{M=[]}let U=M.filter(T=>!Pe.has(`${T.ip}:${T.port}`));if(U.length===0){k(1011,__sfx("5Ye656uZ5peg5pWw5o2u77ya5peg5Y+N5Luj5YWl5Y+j5Y+v55So"));return}for(let T of U.slice(0,St)){if(Pe.add(`${T.ip}:${T.port}`),pr(),c){let O=c;if(O.close)try{O.close()}catch{}}u=null,re=0;try{let O=await ye({hostname:T.ip,port:T.port,timeoutMs:zn,resolvePreferred:!1,skipTargetPolicy:!0,proxies:n.aggressiveRedial?o:void 0,proxyMode:n.aggressiveRedial?n.proxyMode:void 0});if(!O)continue;c=O,jn(`${y.hostname}:${y.port}`,O,"redial");let Ge=O.writable.getWriter();u=Ge;let Xt=0;for(let Ae of E)Xt+=Ae.byteLength;let Qe=new Uint8Array(Xt),Kt=0;for(let Ae of E)Qe.set(Ae,Kt),Kt+=Ae.byteLength;await p.run(async()=>{Qe.byteLength>0&&await Ge.write(Qe),await mr(Ge)}),$(`${y.hostname}:${y.port}`,[],__sfx("5bey5YiH5o2i5Y+N5Luj5YWl5Y+jIA==")+T.ip+":"+T.port+""),r?.waitUntil(Nt());return}catch(O){$(`${y.hostname}:${y.port}`,[],__sfx("5Y+N5Luj5YWl5Y+jIA==")+T.ip+":"+T.port+__sfx("IOWksei0pe+8mg==")+String(O)+"")}}k(1011,__sfx("5Ye656uZ5peg5pWw5o2u77ya5omA5pyJ5Y+N5Luj5YWl5Y+j5Z2H5aSx6LSl"))};a.addEventListener("message",m=>{(async()=>{let y=m.data,S=typeof y=="string"?new TextEncoder().encode(y):new Uint8Array(y);if(S.byteLength!==0){if(R(),Mt.add(S.byteLength)){Ft();return}if(!f){if(l=rt(l,S),l.byteLength>Eo){k(1009,__sfx("5o+h5omL5aS06LaF6L+HIDY0S0I="));return}await Je();return}if(j){j.push(S);return}if(!u){if(l=rt(l,S),l.byteLength>Xn){k(1009,__sfx("5ouo5Y+35pyf6Ze05pWw5o2u6L+H5aSa"));return}return}ne(S),await Bt(S)}})()});let Vt=()=>{W()};a.addEventListener("close",Vt),a.addEventListener("error",Vt),l.byteLength>0?Je().catch(m=>k(1011,String(m))):b=setTimeout(()=>{b=null,!(x||f||l.byteLength>0)&&(ie.firstPacketTimeouts++,k(1008,__sfx("6aaW5YyF6LaF5pe277ya5pyq5pS25Yiw5Y2P6K6u5aS0")))},vo);try{return new Response(null,{status:101,[__sfx("d2ViU29ja2V0")]:i})}catch(m){return console.error(__sfx("W+iHqueglOaVsOaNrumdol0gMTAxIOWTjeW6lOaehOmAoOWksei0pe+8mg=="),m),new Response(null,{status:200})}}var zn,Vn,St,Eo,Xn,So,Fe,Be,Kn,ie,He,ko,vo,Tt=P(()=>{"use strict";tt();sn();an();pe();cn();un();Et();Me();yt();he();zn=5e3,Vn=2500,St=2,Eo=64*1024,Xn=8*1024*1024,So=32*1024*1024,Fe=0;Be=[],Kn=20,ie={stallRedials:0,eofRedials:0,guardedRedials:0,firstPacketTimeouts:0,downlinkYields:0};He=[];ko=2e3,vo=8e3});var Jn={};Ee(Jn,{[__sfx("aGFuZGxlWGh0dHA=")]:()=>Rt,[__sfx("cmVjZW50WGh0dHBEaWFnbm9zdGljcw==")]:()=>Uo,[__sfx("cmVjb3JkWGh0dHBEaWFnbm9zdGljcw==")]:()=>be});function Do(e,t){return new Promise(n=>{let o=setTimeout(()=>n(null),t);e.then(r=>{clearTimeout(o),n(r)},()=>{clearTimeout(o),n(null)})})}function be(e,t,n){Ve.unshift({at:Date.now(),target:e,...t,summary:n}),Ve.length>20&&(Ve.length=20)}function Uo(){return Ve}async function Rt(e,t,n){let o=e.body;if(!o)return new Response(__sfx("57y65bCR6K+35rGC5L2T"),{status:400});let r=new Q(o),s=await Do(Zt(r,t.uuid),Lo);if(!s)return await r.cancel("header timeout"),new Response(__sfx("VkxFU1Mg5aS06Kej5p6Q5aSx6LSl"),{status:400});if(s.header.command!==Gt)return await s.payload.cancel("unsupported UDP"),new Response(__sfx("WEhUVFAg5pqC5LiN5pSv5oyBIFVEUA=="),{status:400});let i;try{i=await ye({hostname:s.header.hostname,port:s.header.port,proxies:n,nat64:t.nat64,concurrent:t.concurrentDial,proxyMode:t.proxyMode,resolvePreferred:t.resolvePreferred,relayPool:{userEntries:t.relayPool||void 0,useBuiltin:t.useBuiltinRelay,colo:typeof e.cf?.colo=="string"?e.cf.colo:void 0},onFailure:d=>{be(`${s.header.hostname}:${s.header.port}`,d,__sfx("WEhUVFAg5Ye656uZ5aSx6LSl77yI")+d.candidate+"):"+d.message+"")}})}catch(d){be(`${s.header.hostname}:${s.header.port}`,{kind:"dial",message:String(d),candidate:"all"},__sfx("WEhUVFAg5Ye656uZ5YWo6YOo5aSx6LSl77ya")+String(d)+"");try{s.payload.cancel("dial failed").catch(()=>{})}catch{}return new Response(__sfx("5Ye656uZ5LiN5Y+v55So"),{status:502})}let a=s.header.addons;if(a.byteLength>255)return new Response(__sfx("QWRkb25zIOmVv+W6pui2heWHuiBWTEVTUyDljY/orq7kuIrpmZA="),{status:400});let l=new Uint8Array(2+a.byteLength);l[0]=s.header.version,l[1]=a.byteLength,l.set(a,2);let f=!1,c=null,u=!1,p=new se((t.dataBudgetMB||0)*1024*1024),g=null,b=()=>{if(u)return;u=!0;let d=__sfx("5Y2V6L+e5o6l5rWB6YeP6LaF6L+HIA==")+t.dataBudgetMB+__sfx("TUIg5LiK6ZmQ");if(be(`${s.header.hostname}:${s.header.port}`,{kind:"budget",message:d,candidate:"traffic"},d),i.close)try{i.close()}catch{}try{g?.close()}catch{}},R=d=>p.add(d)?(b(),!0):!1;Hn(s.payload,i.writable,void 0,!1,R,(d,w)=>{let x=d instanceof Error?d.message:String(d),L=`relay-${w}`;/cancel|abort|closed/i.test(x)?L=`relay-${w}-client-cancel`:/reset|broken pipe/i.test(x)&&(L=`relay-${w}-upstream-reset`),be(`${s.header.hostname}:${s.header.port}`,{kind:L,message:x.slice(0,200),candidate:i.endpoint},__sfx("WEhUVFAg5Lit57un")+w==="read"?"\u8BFB\u4E0A\u6E38":"\u5199\u76EE\u6807"+__sfx("5aSx6LSl77yI")+L+"):"+x.slice(0,120)+"")}).catch(()=>{});let C=new ReadableStream({start(d){g=d,d.enqueue(l),f=!0},async pull(d){if(!(u||!f)){c||(c=i.readable.getReader());try{let{done:w,value:x}=await c.read();if(u)return;if(w){if(i.close)try{i.close()}catch{}d.close();return}if(x&&x.byteLength>0){if(p.add(x.byteLength)){b();return}d.enqueue(x)}}catch(w){if(u)return;if(i.close)try{i.close()}catch{}try{d.error(w)}catch{}}}},cancel(d){u=!0;try{i.readable.cancel(d)}catch{}if(i.close)try{i.close()}catch{}}});return new Response(C,{status:200,headers:{"Content-Type":"text/event-stream","Cache-Control":"no-store","X-Accel-Buffering":"no"}})}var Lo,Ve,Ct=P(()=>{"use strict";pe();tt();Me();Et();Lo=2e3;Ve=[]});function Ke(){return new Response(JSON.stringify({build:kt,version:Oo,ts:Date.now()}),{status:200,headers:{"Content-Type":"application/json","Cache-Control":"no-store","Access-Control-Allow-Origin":"*"}})}var kt,Oo,Xe,vt=P(()=>{"use strict";kt="2c7b165-d5c0a377",Oo=__sfx("MC4xNi4w"),Xe=__sfx("L19fY2ZwX3ZlcnNpb24=")});function Gn(e){return e[__sfx("S1Y=")]?new ae(e[__sfx("S1Y=")]):new It}var ae,It,je=P(()=>{"use strict";ae=class{constructor(t){this.kv=t}kv;async get(t){return await this.kv.get(t)}async put(t,n,o){o&&o>=60?await this.kv.put(t,n,{expirationTtl:o}):await this.kv.put(t,n)}async delete(t){await this.kv.delete(t)}async list(t){let n=[],o;do{let r=await this.kv.list({prefix:t,cursor:o});for(let s of r.keys)n.push(s.name);o=r.list_complete?void 0:r.cursor}while(o);return n}},It=class{data=new Map;async get(t){let n=this.data.get(t);return n?n.expiresAt>0&&n.expiresAt<=Date.now()?(this.data.delete(t),null):n.value:null}async put(t,n,o){let r=o?Date.now()+o*1e3:0;this.data.set(t,{value:n,expiresAt:r})}async delete(t){this.data.delete(t)}async list(t){return[...this.data.keys()].filter(n=>n.startsWith(t))}}});function ee(e,t){if(e==null)return t;let n=String(e).trim();if(n==="")return t;let o=Number(n);return Number.isFinite(o)?o:t}function F(e,t){if(e==null||e==="")return t;let n=String(e).trim().toLowerCase();return["1","true","yes","on"].includes(n)?!0:["0","false","no","off"].includes(n)?!1:t}function No(e){let t=e.trim().toLowerCase();return t==="global"||t==="fallback"||t==="smart"?t:"only"}function qn(e){return e.trim().toLowerCase()==="signed"?"signed":"legacy"}function Zn(e){return e.trim().toLowerCase()==="doh"?"doh":"off"}function I(e,t){return e==null?t:String(e)}function Mo(e){return{uuid:I(e[__sfx("VVVJRA==")],""),[__sfx("dHJvamFuUGFzc3dvcmQ=")]:I(e[__sfx("VFJPSkFOX1BBU1NXT1JE")],""),wsPath:I(e[__sfx("V1NfUEFUSA==")]||e[__sfx("UEFUSA==")],A.wsPath),[__sfx("dHJvamFuUGF0aA==")]:A[__sfx("dHJvamFuUGF0aA==")],[__sfx("eGh0dHBQYXRo")]:A[__sfx("eGh0dHBQYXRo")],add:I(e[__sfx("QURE")],""),addApi:I(e[__sfx("QUREQVBJ")],""),addCsv:I(e[__sfx("QUREX0NTVg==")],""),poolOfficial:F(e[__sfx("T0ZGSUNJQUxfSVA=")],A.poolOfficial),officialCount:ee(e[__sfx("T0ZGSUNJQUxfSVBfQ09VTlQ=")],A.officialCount),poolDomain:F(e[__sfx("UFJFRkVSUkVEX0RPTUFJTg==")],A.poolDomain),domainCount:ee(e[__sfx("UFJFRkVSUkVEX0RPTUFJTl9DT1VOVA==")],A.domainCount),poolManual:F(e[__sfx("TUFOVUFMX0lQ")],A.poolManual),poolCountries:I(e[__sfx("UE9PTF9DT1VOVFJJRVM=")],A.poolCountries),dls:ee(e[__sfx("RExT")],0),maxLatency:ee(e[__sfx("TUFYX0xBVEVOQ1k=")],0),maxNodes:0,[__sfx("cHJveHlJcA==")]:I(e[__sfx("UFJPWFlJUA==")],""),[__sfx("c29ja3M1")]:I(e[__sfx("U09DS1M1")],""),httpProxy:I(e[__sfx("SFRUUF9QUk9YWQ==")],""),proxyMode:No(I(e[__sfx("UFJPWFlfTU9ERQ==")],"")),nat64:I(e[__sfx("TkFUNjQ=")],""),concurrentDial:F(e[__sfx("VENQX0NPTkNVUlJFTlRfRElBTA==")],!0),dataBudgetMB:ee(e[__sfx("REFUQV9CVURHRVRfTUI=")],A.dataBudgetMB),resolvePreferred:F(e[__sfx("UkVTT0xWRV9QUkVGRVJSRUQ=")],A.resolvePreferred),aggressiveRedial:F(e[__sfx("QUdHUkVTU0lWRV9SRURJQUw=")],A.aggressiveRedial),relayPool:I(e[__sfx("UkVMQVlfUE9PTA==")],""),useBuiltinRelay:F(e[__sfx("VVNFX0JVSUxUSU5fUkVMQVk=")],A.useBuiltinRelay),[__sfx("ZW5hYmxlVHJvamFu")]:F(e[__sfx("RU5BQkxFX1RST0pBTg==")]??e[__sfx("VFJPSkFO")],A[__sfx("ZW5hYmxlVHJvamFu")]),[__sfx("ZW5hYmxlWGh0dHA=")]:F(e[__sfx("RU5BQkxFX1hIVFRQ")]??e[__sfx("WEhUVFA=")],A[__sfx("ZW5hYmxlWGh0dHA=")]),subDomain:"",subProtocol:"both",subTransport:"both",subVariants:I(e[__sfx("U1VCX1ZBUklBTlRT")],A.subVariants),subName:I(e[__sfx("U1VCX05BTUU=")],A.subName).trim()||A.subName,subPorts:I(e[__sfx("U1VCX1BPUlRT")],A.subPorts),clientFingerprint:A.clientFingerprint,ech:F(e[__sfx("RUNI")],A.ech),echHost:I(e[__sfx("RUNIX0hPU1Q=")],A.echHost),echDns:I(e[__sfx("RUNIX0ROUw==")],A.echDns),tlsFragment:!1,tlsFragmentSize:A.tlsFragmentSize,tlsFragmentDelay:A.tlsFragmentDelay,subToken:qn(I(e[__sfx("U1VCX1RPS0VOX01PREU=")],"")),subTokenTtlDays:ee(e[__sfx("U1VCX1RPS0VOX1RUTF9EQVlT")],A.subTokenTtlDays),unlockProbe:F(e[__sfx("VU5MT0NLX1BST0JF")],A.unlockProbe),udpDns:Zn(I(e[__sfx("VURQX0ROUw==")],"")),udpDnsEndpoint:I(e[__sfx("VURQX0ROU19FTkRQT0lOVA==")],A.udpDnsEndpoint)}}function Fo(e,t){let n={...e};for(let[o,r]of Object.entries(t))if(r!=null)if(o==="dls"||o==="maxLatency"||o==="maxNodes"||o==="officialCount"||o==="domainCount"||o==="dataBudgetMB"||o==="subTokenTtlDays")n[o]=ee(r,0);else if(o==="concurrentDial"||o==="resolvePreferred"||o==="aggressiveRedial"||o==="useBuiltinRelay"||o===__sfx("ZW5hYmxlVHJvamFu")||o===__sfx("ZW5hYmxlWGh0dHA=")||o==="tlsFragment"||o==="ech"||o==="poolOfficial"||o==="poolDomain"||o==="poolManual"||o==="unlockProbe")n[o]=F(r,!1);else if(o==="subProtocol"){let s=String(r);n[o]=s===__sfx("dmxlc3M=")||s===__sfx("dHJvamFu")||s==="both"?s:"both"}else if(o==="subTransport"){let s=String(r);n[o]=s==="ws"||s===__sfx("eGh0dHA=")||s==="both"?s:"both"}else o==="subToken"?n[o]=qn(String(r)):o==="udpDns"?n[o]=Zn(String(r)):n[o]=String(r);return n}async function _n(e,t){let n=Mo(t),o=await e.get(Qn),r={};if(o)try{r=JSON.parse(o)}catch{r={}}let s=Fo(n,r),i=!1,a=e instanceof ae;return!s.uuid&&a&&(s.uuid=qe(),i=!0),!s[__sfx("dHJvamFuUGFzc3dvcmQ=")]&&a&&(s[__sfx("dHJvamFuUGFzc3dvcmQ=")]=qe().replace(/-/g,"").slice(0,16),i=!0),s.officialCount<1&&(s.officialCount=A.officialCount,i=!0),s.domainCount<1&&(s.domainCount=A.domainCount,i=!0),i&&await Bo(e,s),s}async function Bo(e,t){await e.put(Qn,JSON.stringify(t))}var Qn,A,We=P(()=>{"use strict";J();je();Qn="CONFIG",A={uuid:"",[__sfx("dHJvamFuUGFzc3dvcmQ=")]:"",wsPath:__sfx("L3ZsZXNz"),[__sfx("dHJvamFuUGF0aA==")]:__sfx("L3Ryb2phbg=="),[__sfx("eGh0dHBQYXRo")]:__sfx("L3hodHRw"),add:"",addApi:"",addCsv:"",poolOfficial:!0,officialCount:20,poolDomain:!0,domainCount:10,poolManual:!0,poolCountries:"",dls:0,maxLatency:0,maxNodes:0,[__sfx("cHJveHlJcA==")]:"",[__sfx("c29ja3M1")]:"",httpProxy:"",proxyMode:"only",nat64:"",concurrentDial:!0,dataBudgetMB:0,resolvePreferred:!0,aggressiveRedial:!1,relayPool:"",useBuiltinRelay:!0,[__sfx("ZW5hYmxlVHJvamFu")]:!0,[__sfx("ZW5hYmxlWGh0dHA=")]:!0,subDomain:"",subProtocol:__sfx("dmxlc3M="),subTransport:"ws",subVariants:__sfx("dmxlc3Mtd3M="),subName:__sfx("Q0ZQaWxvdA=="),subPorts:"443",clientFingerprint:"chrome",ech:!1,echHost:__sfx("Y2xvdWRmbGFyZS1lY2guY29t"),echDns:"",tlsFragment:!1,tlsFragmentSize:"10-20",tlsFragmentDelay:"10-20",subToken:"legacy",subTokenTtlDays:0,unlockProbe:!1,udpDns:"off",udpDnsEndpoint:"https://dns.google/dns-query"}});var $n,Ho,ii,zo,ai,er=P(()=>{"use strict";$n={[__sfx("SEs=")]:["HKG"],[__sfx("VFc=")]:["TPE","KHH"],[__sfx("SlA=")]:["NRT","KIX","CTS","FUK"],[__sfx("S1I=")]:["ICN","PUS"],[__sfx("U0c=")]:["SIN"],[__sfx("TVk=")]:["KUL"],[__sfx("VEg=")]:["BKK"],[__sfx("Vk4=")]:["SGN","HAN"],[__sfx("SUQ=")]:["CGK","DPS"],[__sfx("UEg=")]:["MNL"],[__sfx("SU4=")]:["BOM","MAA","DEL"],[__sfx("QVU=")]:["SYD","MEL","BNE","PER"],[__sfx("Tlo=")]:["AKL"],[__sfx("VVM=")]:["LAX","SJC","SEA","ORD","DFW","IAD","EWR","ATL","MIA","DEN","PHX","BOS"],[__sfx("Q0E=")]:["YYZ","YVR","YYC"],[__sfx("R0I=")]:["LHR","MAN"],[__sfx("REU=")]:["FRA","MUC","BER"],[__sfx("RlI=")]:["CDG","MRS"],[__sfx("Tkw=")]:["AMS"],[__sfx("SVQ=")]:["MXP","FCO"],[__sfx("RVM=")]:["MAD","BCN"],[__sfx("U0U=")]:["ARN"],[__sfx("Q0g=")]:["ZRH"],[__sfx("QVQ=")]:["VIE"],[__sfx("UEw=")]:["WAW"],[__sfx("UlU=")]:["DME","SVO"],[__sfx("VFI=")]:["IST"],[__sfx("QUU=")]:["DXB"],[__sfx("SUw=")]:["TLV"],[__sfx("WkE=")]:["JNB"],[__sfx("QlI=")]:["GRU","GIG"],[__sfx("QVI=")]:["EZE"],[__sfx("Q0w=")]:["SCL"],[__sfx("TVg=")]:["MEX"]},Ho=__sfx("SEtH6aaZ5rivLFRQReWPsOWMlyxOUlTkuJzkuqwsS0lY5aSn6ZiqLElDTummluWwlCxTSU7mlrDliqDlnaEsS1VM5ZCJ6ZqG5Z2hLEJLS+abvOiwtyxTR07og6Hlv5fmmI7luIIsTU5M6ams5bC85ouJLFNZROaCieWwvCxNRUzloqjlsJTmnKwsTEFY5rSb5p2J55+2LFNKQ+Wco+S9leWhnixTRUHopb/pm4Xlm74sT1JE6Iqd5Yqg5ZOlLElBROWNjuebm+mhvyxFV1Lnur3nk6blhYssWVla5aSa5Lym5aSaLFlWUua4qeWTpeWNjixMSFLkvKbmlaYsRlJB5rOV5YWw5YWL56aPLENER+W3tOm7jixBTVPpmL/lp4bmlq/nibnkuLksTUFE6ams5b636YeMLEFSTuaWr+W+t+WTpeWwlOaRqSxJU1TkvIrmlq/lnabluIPlsJQsRFhC6L+q5ouc"),ii=(()=>{let e={};for(let t of Ho.split(","))t.length>3&&(e[t.slice(0,3)]=t.slice(3));return e})(),zo=new Map;for(let[e,t]of Object.entries($n))for(let n of t)zo.set(n,e);ai=Object.keys($n)});var tr=P(()=>{"use strict"});var Ei,nr=P(()=>{"use strict";B();J();er();tr();Ei=".cn,qq.com,tencent.com,weixin.qq.com,baidu.com,bdstatic.com,bilibili.com,hdslb.com,taobao.com,tmall.com,jd.com,aliyun.com,alicdn.com,alipay.com,163.com,126.net,zhihu.com,weibo.com,sina.com.cn,youku.com,iqiyi.com,douyin.com,xiaohongshu.com,mi.com,huawei.com,csdn.net,gitee.com,cnblogs.com".split(",")});var Ci,rr=P(()=>{"use strict";je();J();Ci=new TextEncoder});var ji,or=P(()=>{"use strict";We();J();ji=3600*24});function sr(e){return Gn(e)}async function ir(e,t){if(we.config&&Date.now()-we.configAt<Vo)return we.config;let n=await _n(e,t);return we.config=n,we.configAt=Date.now(),n}var Vo,we,Dt=P(()=>{"use strict";je();We();or();Vo=15e3,we={config:null,configAt:0,auth:null,authAt:0}});var lr={};Ee(lr,{clearUnlockCache:()=>qo,runUnlockProbe:()=>Qo});function Jo(e,t,n){return e===200?"ok":e===404?t==="status"?"region":"unknown":e===403||e===451?"blocked":t==="trace"&&/\bloc=[A-Z]{2}\b/.test(n)?"ok":"unknown"}async function Go(e){let t=Date.now(),n=new AbortController,o=setTimeout(()=>n.abort(),jo);try{let r=await fetch(e.url,{method:"GET",redirect:"manual",signal:n.signal,headers:{"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0 Safari/537.36",Accept:"text/html,application/xhtml+xml,*/*"}}),s="";e.mode==="trace"&&(s=(await r.text()).slice(0,512));let i=/\bloc=([A-Z]{2})\b/.exec(s)?.[1];return{id:e.id,status:r.status,verdict:Jo(r.status,e.mode,s),ms:Date.now()-t,...i?{loc:i}:{}}}catch(r){let s=r instanceof Error?r.message:String(r);return{id:e.id,status:0,verdict:"unknown",ms:Date.now()-t,error:/abort/i.test(s)?"timeout":"fetch-failed"}}finally{clearTimeout(o)}}async function Qo(e,t){let n=e||"UNK",o=Date.now(),r=le.get(n);if(r&&o-r.at<Wo)return{...r.data,cached:!0};let s=await Promise.all(Ko.map(a=>Go(a))),i={colo:n,region:t,cached:!1,at:o,targets:s};if(le.size>=Yo){let a="",l=Number[__sfx("UE9TSVRJVkVfSU5GSU5JVFk=")];for(let[f,c]of le)c.at<l&&(l=c.at,a=f);a&&le.delete(a)}return le.set(n,{at:o,data:i}),i}function qo(){le.clear()}var Ko,jo,Wo,Yo,le,cr=P(()=>{"use strict";Ko=[{id:"netflix",url:"https://www.netflix.com/title/81215567",mode:"status"},{id:"youtube",url:"https://www.youtube.com/premium",mode:"status"},{id:"gemini",url:"https://gemini.google.com/",mode:"status"}],jo=4e3,Wo=600*1e3,Yo=16,le=new Map});J();var br=8*1024*1024,wr=2*1024*1024,Wt=600*1e3,xr=6*1024*1024*1024,Ze=Date.now(),_e=0;function Yt(e){e-Ze>=Wt&&(Ze=e,_e=0)}function Pr(e,t=Date.now()){Yt(t),_e+=e}function jt(e){return Yt(e),xr-_e}var Ar=(()=>{let e=new Uint8Array(65536),t=2654435769;for(let n=0;n<e.length;n++)t^=t<<13,t^=t>>>17,t^=t<<5,e[n]=t&255;return e})(),Er=5e3;function Sr(e,t=Er){let n=!1,o=setTimeout(()=>{if(!n){n=!0;try{e(1e3,"Probe idle timeout")}catch{}}},t),r=o;return typeof r?.unref=="function"&&r.unref(),{cancel:()=>{n||(n=!0,clearTimeout(o))}}}async function $e(e){let t=new URL(e.url);if(e.headers.get("Upgrade")?.toLowerCase()===__sfx("d2Vic29ja2V0")){let f=new WebSocketPair,[c,u]=Object.values(f);u.accept();let p=Sr((g,b)=>u.close(g,b));return u.addEventListener("message",g=>{let b=typeof g.data=="string"?g.data:"";if(b==="PING"||b==="ping"){p.cancel(),u.send(JSON.stringify({pong:!0,colo:e.cf?.colo??"UNK",clientIp:e.headers.get("CF-Connecting-IP")??""}));try{u.close(1e3,"Probe complete")}catch{}return}p.cancel();try{u.close(1e3,"Probe aborted")}catch{}}),u.addEventListener("close",()=>p.cancel()),u.addEventListener("error",()=>p.cancel()),new Response(null,{status:101,[__sfx("d2ViU29ja2V0")]:c})}let o=Number.parseInt(t.searchParams.get("bytes")??"",10),r=Number.isFinite(o)&&o>0?Math.min(o,br):wr,s=Date.now();if(jt(s)<=0){let f=Math.max(1e3,Ze+Wt-s);return new Response(JSON.stringify({ok:!1,error:"probe budget exhausted"}),{status:429,headers:{"Content-Type":"application/json; charset=utf-8","Cache-Control":"no-store","Retry-After":String(Math.ceil(f/1e3))}})}let i=Ar,a=0,l=new ReadableStream({pull(f){let c=jt(Date.now());if(a>=r||c<=0){f.close();return}let u=Math.min(i.byteLength,r-a,c);f.enqueue(i.subarray(0,u)),a+=u,Pr(u)}});return new Response(l,{status:200,headers:{"Content-Type":"application/octet-stream","Content-Encoding":"identity","Cache-Control":"no-store","Access-Control-Allow-Origin":"*","X-Probe-Bytes":String(r),"X-Probe-Nonce":Te(4)}})}Tt();Ct();bt();vt();J();We();Me();nr();rr();J();function Lt(e){let t=e===200?"Welcome":e===404?"Not Found":"Service Unavailable",n=`<!DOCTYPE html><html lang="zh-CN"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>${t}</title><style>body{margin:0;min-height:100vh;display:flex;align-items:center;justify-content:center;background:#f7f8fa;color:#333;font-family:-apple-system,"Segoe UI","PingFang SC",sans-serif}.c{text-align:center}h1{font-size:22px;font-weight:600;margin:0 0 10px}p{color:#888;font-size:14px;margin:0}</style></head><body><div class="c"><h1>${t}</h1><p>This site is up and running.</p></div></body></html>`;return new Response(n,{status:e,headers:{"Content-Type":"text/html; charset=utf-8","Cache-Control":"no-store","X-Content-Type-Options":"nosniff"}})}Dt();Dt();async function ar(e){let t=sr(e);return await ir(t,e)}function Ut(e){let t=[];return t.push(...ge(e[__sfx("cHJveHlJcA==")],"direct")),t.push(...ge(e[__sfx("c29ja3M1")],__sfx("c29ja3M1"))),t.push(...ge(e.httpProxy,"http")),t}var Ot=6e4,Zo=10,xe=0,Ye=0;function ur(e){return e>=Ye?(xe=0,Ye=e+Ot,!1):xe>=Zo}function fr(e,t,n){if(!n)return!1;let o=(e.headers.get(__sfx("eC1jZnBpbG90LXRva2Vu"))??t.searchParams.get("token")??"").trim();if(!o)return!1;let r=Date.now();return ue(o,n)?(xe=0,!0):(r>=Ye&&(Ye=r+Ot,xe=0),xe+=1,!1)}async function dr(e,t,n){let o=new URL(e.url);if(o.pathname===__sfx("L19fZWRnZV9wcm9iZQ=="))return $e(e);if(o.pathname===Xe||o.pathname===__sfx("L19fdmVyc2lvbg=="))return Ke();if(o.pathname==="/region"&&e.method==="GET"){let{coloToCountry:i}=await Promise.resolve().then(()=>(he(),ht)),a=e.cf?.colo??"",l=a?i(a):"";return new Response(JSON.stringify({ok:!0,colo:a,region:l,timestamp:new Date().toISOString()},null,2),{status:200,headers:{"Content-Type":"application/json; charset=utf-8"}})}let r=await ar(t);if(o.pathname===__sfx("L19fZGlhZw==")){if(ur(Date.now()))return new Response(JSON.stringify({ok:!1,error:"token attempts throttled"},null,2),{status:429,headers:{"Content-Type":"application/json; charset=utf-8","Cache-Control":"no-store","Retry-After":String(Math.ceil(Ot/1e3))}});if(!fr(e,o,r.uuid))return null;let{recentDiagnostics:i,diagnosticCounters:a,recentRoutes:l}=await Promise.resolve().then(()=>(Tt(),Yn)),{[__sfx("cmVjZW50WGh0dHBEaWFnbm9zdGljcw==")]:f}=await Promise.resolve().then(()=>(Ct(),Jn));return new Response(JSON.stringify({ok:!0,impl:"self",build:kt,recent:i(),[__sfx("eGh0dHA=")]:f(),counters:a(),routes:l()},null,2),{status:200,headers:{"Content-Type":"application/json; charset=utf-8","Cache-Control":"no-store"}})}if(o.pathname==="/__unlock_probe"){if(!r.unlockProbe)return null;if(ur(Date.now()))return new Response(JSON.stringify({ok:!1,error:"token attempts throttled"},null,2),{status:429,headers:{"Content-Type":"application/json; charset=utf-8","Cache-Control":"no-store"}});if(!fr(e,o,r.uuid))return null;let{coloToCountry:i}=await Promise.resolve().then(()=>(he(),ht)),{runUnlockProbe:a}=await Promise.resolve().then(()=>(cr(),lr)),l=e.cf?.colo??"",f=l?i(l):"",c=await a(l,f);return new Response(JSON.stringify({ok:!0,...c},null,2),{status:200,headers:{"Content-Type":"application/json; charset=utf-8","Cache-Control":"no-store"}})}let s=e.headers.get("Upgrade")?.toLowerCase();return o.pathname===r.wsPath?s!==__sfx("d2Vic29ja2V0")?null:await ze(e,__sfx("dmxlc3M="),r,Ut(r),n):r[__sfx("ZW5hYmxlVHJvamFu")]&&o.pathname===r[__sfx("dHJvamFuUGF0aA==")]?s!==__sfx("d2Vic29ja2V0")?null:await ze(e,__sfx("dHJvamFu"),r,Ut(r),n):r[__sfx("ZW5hYmxlWGh0dHA=")]&&o.pathname===r[__sfx("eGh0dHBQYXRo")]?e.method!=="POST"?null:await Rt(e,r,Ut(r)):null}vt();var Ma={async fetch(e,t,n){try{return new URL(e.url).pathname===Xe?Ke():await dr(e,t,n)??Lt(200)}catch{return Lt(500)}}};export{Ma as default};
package/assets/worker.js CHANGED
@@ -3,7 +3,7 @@ var zs=Object.defineProperty;var R=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(
3
3
  `))),i){let M=`${v} Trojan`;r.push(M),p.push(M),n.push([` - name: ${Z(M)}`," type: trojan",` password: ${Z(e.config.trojanPassword)}`,` server: ${g.ip}`,` port: ${b}`," network: ws"," tls: true",` sni: ${e.domain}`,` client-fingerprint: ${e.config.clientFingerprint}`,...u()," ws-opts:",` path: ${Z(e.config.trojanPath)}`," headers:",` Host: ${e.domain}`].join(`
4
4
  `))}}});t.push("# CFPilot \u81EA\u52A8\u751F\u6210\u8BA2\u9605"),t.push("mixed-port: 7890"),t.push("allow-lan: false"),t.push("mode: rule"),t.push("log-level: info"),t.push("unified-delay: true"),t.push("tcp-concurrent: true"),t.push(""),t.push("dns:"),t.push(" enable: true"),t.push(" ipv6: false"),t.push(" enhanced-mode: fake-ip"),t.push(" fake-ip-range: 198.18.0.1/16"),t.push(" default-nameserver:"),t.push(" - 223.5.5.5"),t.push(" - 119.29.29.29"),t.push(" nameserver:"),t.push(" - https://223.5.5.5/dns-query"),t.push(" - https://dns.alidns.com/dns-query"),t.push(" fallback:"),t.push(" - 8.8.4.4"),t.push(" - 1.1.1.1"),t.push(" fallback-filter:"),t.push(" geoip: true"),t.push(" geoip-code: CN"),t.push(""),c&&(t.push(" nameserver-policy:"),t.push(` ${Z(f)}: ${l?Z(l):"https://223.5.5.5/dns-query"}`),t.push(""));let d=Pr(e.routeProfile??"",{mainGroup:"CFPilot",autoGroup:"\u81EA\u52A8\u9009\u62E9"});if(t.push("proxies:"),n.length===0?t.push(" []"):t.push(...n),t.push(""),t.push("proxy-groups:"),t.push(' - name: "CFPilot"'),t.push(" type: select"),t.push(" proxies:"),t.push(' - "\u81EA\u52A8\u9009\u62E9"'),t.push(' - "\u6545\u969C\u8F6C\u79FB"'),o.v4.length>0&&t.push(' - "\u4F18\u9009IPv4"'),o.v6.length>0&&t.push(' - "\u4F18\u9009IPv6"'),r.length===0)t.push(" []");else for(let m of r)t.push(` - ${Z(m)}`);if(r.length>0){t.push(""),t.push(' - name: "\u81EA\u52A8\u9009\u62E9"'),t.push(" type: url-test"),t.push(' url: "http://www.gstatic.com/generate_204"'),t.push(" interval: 300"),t.push(" tolerance: 50"),t.push(" proxies:");for(let g of r)t.push(` - ${Z(g)}`);t.push(""),t.push(' - name: "\u6545\u969C\u8F6C\u79FB"'),t.push(" type: fallback"),t.push(' url: "http://www.gstatic.com/generate_204"'),t.push(" interval: 300"),t.push(" proxies:");for(let g of r)t.push(` - ${Z(g)}`);let m=(g,y)=>{t.push(""),t.push(` - name: ${Z(g)}`),t.push(" type: select"),t.push(" proxies:");for(let A of y)t.push(` - ${Z(A)}`)};o.v4.length>0&&m("\u4F18\u9009IPv4",o.v4),o.v6.length>0&&m("\u4F18\u9009IPv6",o.v6)}return d.groups.length>0&&(t.push(""),t.push(...d.groups)),t.push(""),t.push("rules:"),d.rules.length>0?(t.push(...d.rules),d.rules.some(m=>m.includes("MATCH,"))||t.push(" - MATCH,CFPilot")):t.push(...xr("CFPilot")),t.push(""),t.join(`
5
5
  `)}function vi(e){let t=[],n=[],r=_t(e.config.subVariants,e.config,Ur),o=r.some(l=>l==="vless-ws"),s=r.includes("trojan"),a=e.config.ech,i=e.config.echHost.trim()||"cloudflare-ech.com",c=()=>a?{ech:{enabled:!0,query_server_name:i}}:{};for(let l of qt(e)){let u=[];l.entries.forEach((d,m)=>{let g=`${l.name} ${We(d,"vless",m,"")}`;for(let y of en(d,e)){let A=e.ports.length>1?`:${y}`:"",p=`${g}${A}`,b=`${p} Trojan`;o&&u.push(p),s&&u.push(b),o&&t.push({type:"vless",tag:p,server:d.ip,server_port:y,uuid:e.config.uuid,tls:{enabled:!0,server_name:e.domain,insecure:!1,utls:{enabled:!0,fingerprint:e.config.clientFingerprint},...c()},transport:{type:"ws",path:e.config.wsPath,headers:{Host:e.domain}}}),s&&t.push({type:"trojan",tag:b,server:d.ip,server_port:y,password:e.config.trojanPassword,tls:{enabled:!0,server_name:e.domain,insecure:!1,utls:{enabled:!0,fingerprint:e.config.clientFingerprint},...c()},transport:{type:"ws",path:e.config.trojanPath,headers:{Host:e.domain}}})}}),u.length>0&&n.push({tag:l.name,members:u})}t.push({type:"direct",tag:"direct"});for(let l of n)t.push({type:"selector",tag:l.tag,outbounds:l.members,default:l.members[0]});return t.push({type:"selector",tag:"CFPilot",outbounds:n.length>0?n.map(l=>l.tag):["direct"],default:n.length>0?n[0].tag:"direct"}),JSON.stringify({log:{level:"info",timestamp:!0},dns:{servers:[{tag:"dns-out",address:"https://1.1.1.1/dns-query"},{tag:"local",address:"local"}],rules:[{domain_suffix:Nr,server:"local"}]},inbounds:[{type:"mixed",tag:"mixed-in",listen:"127.0.0.1",listen_port:2080}],outbounds:t,route:{rules:[{ip_is_private:!0,outbound:"direct"},{domain_suffix:Nr,outbound:"direct"}],final:"CFPilot",auto_detect_interface:!0}},null,2)}function Ii(e){let t=[],n=_t(e.config.subVariants,e.config);for(let r of qt(e))r.entries.forEach((o,s)=>{let a=We(o,"vless",s,r.name);for(let i of en(o,e)){let c=e.ports.length>1?`:${i}`:"",f=`${a}${c}`,l={...o,port:i};for(let u of n)u==="vless-ws"?t.push(Lr(l,e,"ws",`${f} WS`)):u==="vless-xhttp"?t.push(Lr(l,e,"xhttp",`${f} XHTTP`)):t.push(Ri(l,e,`${f} Trojan`))}});return or(t.join(`
6
- `))}function zr(e,t){let n=$t(t.config.subName);switch(e){case"clash":return{body:ki(t),contentType:"text/yaml; charset=utf-8",fileName:n};case"singbox":return{body:vi(t),contentType:"application/json; charset=utf-8",fileName:n};default:return{body:Ii(t),contentType:"text/plain; charset=utf-8",fileName:n}}}var be,si,ii,Ar,Tr,Cr,ai,li,ci,xi,Si,Ei,ye,Ai,Dr,Ur,Ti,Nr,tn=R(()=>{"use strict";re();ie();Gt();Sr();be=443;si=["ip\u5730\u5740","ip \u5730\u5740","ip","\u5730\u5740","\u670D\u52A1\u5668","server","host"],ii=["\u7AEF\u53E3","port"],Ar=["\u4E0B\u8F7D\u901F\u5EA6","\u901F\u5EA6","speed","download"],Tr=["\u5E73\u5747\u5EF6\u8FDF","\u5EF6\u8FDF","latency","delay","\u54CD\u5E94\u65F6\u95F4","rtt"],Cr=["colo","\u673A\u623F","\u6570\u636E\u4E2D\u5FC3","\u5730\u533A","region"],ai=["\u56FD\u5BB6","country","\u56FD\u522B"],li=["\u57CE\u5E02","city"],ci=["tls","\u662F\u5426\u652F\u6301tls","\u652F\u6301tls"];xi={official:"\u5B98\u65B9\u4F18\u9009IP",domain:"\u4F18\u9009\u57DF\u540D",manual:"\u4F18\u9009",api:"\u8FDC\u7A0BAPI",csv:"\u6D4B\u901FCSV"};Si=12e4,Ei=32,ye=new Map,Ai="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36";Dr=["vless-ws","vless-xhttp","trojan"];Ur=["vless-ws","trojan"];Ti=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;Nr=".cn,qq.com,tencent.com,weixin.qq.com,baidu.com,bdstatic.com,bilibili.com,hdslb.com,taobao.com,tmall.com,jd.com,aliyun.com,alicdn.com,alipay.com,163.com,126.net,zhihu.com,weibo.com,sina.com.cn,youku.com,iqiyi.com,douyin.com,xiaohongshu.com,mi.com,huawei.com,csdn.net,gitee.com,cnblogs.com".split(",")});function Bi(e){let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function Wr(e,t){let n=await crypto.subtle.importKey("raw",Kr.encode(e),{name:"HMAC",hash:"SHA-256"},!1,["sign"]),r=await crypto.subtle.sign("HMAC",n,Kr.encode(t));return Bi(new Uint8Array(r))}async function mt(e){let t=(await e.get(pt))?.trim();if(t)return t;let n=Yr();return e instanceof ue&&await e.put(pt,n),n}async function Gr(e){let t=Yr();return e instanceof ue?await e.put(pt,t):await e.put(pt,t),t}async function Jr(e,t={}){let n=t.ttlDays??0,r=Math.floor((t.now??Date.now())/1e3),o=n>0?r+Math.round(n*86400):0,s=Math.floor(Math.random()*36**8).toString(36).padStart(8,"0"),a=`${on}.${o.toString(36)}.${s}`,i=(await Wr(e,a)).slice(0,sn);return`${a}.${i}`}async function gt(e,t,n=Date.now()){if(!e||!t)return{ok:!1,reason:"format"};let r=t.split(".");if(r.length!==4||r[0]!==on)return{ok:!1,reason:"format"};let o=r[1],s=r[2],a=r[3];if(!o||!s||a.length!==sn)return{ok:!1,reason:"format"};let i=Number.parseInt(o,36);if(!Number.isFinite(i)||i<0)return{ok:!1,reason:"format"};let c=(await Wr(e,`${on}.${o}.${s}`)).slice(0,sn);return ee(a,c)?i>0&&Math.floor(n/1e3)>=i?{ok:!1,reason:"expired",exp:i}:{ok:!0,exp:i}:{ok:!1,reason:"signature"}}var pt,on,sn,Kr,Yr,an=R(()=>{"use strict";rt();ie();pt="SUB_TOKEN_SECRET",on="v1",sn=22,Kr=new TextEncoder;Yr=()=>Q(32)});function Vi(e){let t="";for(let n of e)t+=(n<16?"0":"")+n.toString(16);return t}function ji(e){if(!/^[0-9a-f]*$/.test(e)||e.length%2!==0)return null;let t=new Uint8Array(new ArrayBuffer(e.length/2));for(let n=0;n<t.length;n++)t[n]=Number.parseInt(e.slice(n*2,n*2+2),16);return t}async function to(e,t,n){let r=ji(t);if(!r)return null;let o=await crypto.subtle.importKey("raw",new TextEncoder().encode(e),"PBKDF2",!1,["deriveBits"]),s=await crypto.subtle.deriveBits({name:"PBKDF2",salt:r,iterations:n,hash:"SHA-256"},o,256);return Vi(new Uint8Array(s))}function no(e){if(e.startsWith(`${cn}$`)){let[r,o,s,a]=e.split("$");if(r!==cn||!s||!a)return null;let i=Number.parseInt(o??"",10);return!Number.isFinite(i)||i<1||i>1e6?null:{scheme:"pbkdf2",salt:s,iterations:i,expected:a}}let[t,n]=e.split(":");return!t||!n?null:{scheme:"sha256",salt:t,iterations:0,expected:n}}async function ro(e,t){return e.scheme==="pbkdf2"?await to(t,e.salt,e.iterations):await Vt(`${e.salt}:${t}`)}async function un(e,t){let n=await to(e,t,qr);return n?`${cn}$${qr}$${t}$${n}`:`${t}:${await Vt(`${t}:${e}`)}`}async function Xi(e,t){let n=no(e);if(!n)return!1;let r=await ro(n,t);return r?ee(r,n.expected):!1}function $r(e){return`/${e.trim().replace(/^\/+/,"")}`}async function oo(e,t,n){let r=await e.get(it)??"",o=n&&n.trim()?$r(n):"";o?r!==o&&(r=o,await e.put(it,r)):r||(r=$r(`${lr}-${rr(6)}`),await e.put(it,r));let s=await e.get(Ne)??"",a=null,i=t&&t.trim()?t.trim():"";if(i){if(!s||!await Xi(s,i)){let f=Q(8);s=await un(i,f),await e.put(Ne,s)}await e.get(Ae)&&await e.delete(Ae)}else if(!s){let c=`cfp-${Q(8)}`,f=Q(8);s=await un(c,f),await e.put(Ne,s),a=c,await e.put(Ae,c)}return{panelPath:r,passwordHash:s,generatedPassword:a}}async function so(e,t){let n=no(e.passwordHash);if(!n)return{ok:!1,legacy:!1};let r=await ro(n,t);if(!r)return{ok:!1,legacy:!1};let o=ee(r,n.expected);return{ok:o,legacy:o&&n.scheme==="sha256"}}async function io(e,t){let n=Q(8);await e.put(Ne,await un(t,n))}async function ao(e){await e.get(Ae)&&await e.delete(Ae)}function lo(e){let t=e.headers.get("Cookie")??"",n={};for(let r of t.split(";")){let o=r.indexOf("=");if(o<0)continue;let s=r.slice(0,o).trim(),a=r.slice(o+1).trim();s&&(n[s]=decodeURIComponent(a))}return n}async function co(e){let t=Q(24);return await e.put(`${st}${t}`,JSON.stringify({ua:"",t:Date.now()}),eo),t}async function fn(e,t){let n=lo(t)[yt];return n?!!await e.get(`${st}${n}`):!1}function uo(e,t=eo){return`${yt}=${e}; Path=/; HttpOnly; Secure; SameSite=Strict; Max-Age=${t}`}function fo(){return`${yt}=; Path=/; HttpOnly; Secure; SameSite=Strict; Max-Age=0`}async function po(e,t){let n=lo(t)[yt];n&&await e.delete(`${st}${n}`)}async function mo(e){let t=Q(20);return await e.put(`${ot}${t}`,"1",zi),t}async function go(e,t){if(!t)return!1;let n=await e.get("SCANNER_TOKEN");return n&&ee(n,t)?!0:await e.get(`${ot}${t}`)?(await e.delete(`${ot}${t}`),!0):!1}var yt,eo,zi,qr,cn,dn=R(()=>{"use strict";Be();ie();yt="cfpilot_sess",eo=3600*24,zi=600,qr=3e4,cn="pbkdf2"});function pn(e){return sr(e)}async function bt(e,t){if($.config&&Date.now()-$.configAt<Ki)return $.config;let n=await fr(e,t);return $.config=n,$.configAt=Date.now(),n}function ho(){$.config=null,$.configAt=0}async function mn(e,t){if($.auth&&Date.now()-$.authAt<Wi)return $.auth;let n=await oo(e,t.PANEL_PASSWORD,t.PANEL_PATH);return $.auth=n,$.authAt=Date.now(),n}function gn(e){switch((e??"").toLowerCase()){case"clash":case"mihomo":case"yaml":return"clash";case"singbox":case"sing-box":case"json":return"singbox";case"v2ray":return"v2ray";case"base64":return"base64";default:return"base64"}}function Ye(e){let t=String(e??"").trim();if(!t)return t;t=t.replace(/^[a-zA-Z][a-zA-Z0-9+.-]*:\/\//,""),t=t.replace(/[/?#].*$/,"");let n=t.lastIndexOf("@");if(n>=0&&(t=t.slice(n+1)),t.startsWith("[")){let r=t.indexOf("]");r>0&&(t=t.slice(1,r))}else{let r=t.indexOf(":");r>=0&&t.indexOf(":",r+1)<0&&(t=t.slice(0,r))}return t.trim()}function yo(e){let t=(e??"").toLowerCase();return t?t.includes("clash")||t.includes("mihomo")||t.includes("flclash")||t.includes("clashx")||t.includes("stash")?"clash":t.includes("sing-box")||t.includes("singbox")?"singbox":t.includes("v2ray")||t.includes("v2rayng")||t.includes("shadowrocket")||t.includes("nekobox")||t.includes("surge")||t.includes("loon")||t.includes("quantumult")?"base64":null:null}var Ki,Wi,$,wt=R(()=>{"use strict";rt();Be();dn();Ki=15e3,Wi=6e4,$={config:null,configAt:0,auth:null,authAt:0}});function hn(e,t,n){if(!e){n.push({field:t,message:`${t} \u4E0D\u80FD\u4E3A\u7A7A`});return}if(!e.startsWith("/")){n.push({field:t,message:`${t} \u5FC5\u987B\u4EE5 / \u5F00\u5934`});return}if(e.length>128){n.push({field:t,message:`${t} \u8FC7\u957F\uFF08\u6700\u591A 128 \u5B57\u7B26\uFF09`});return}/[\s\u0000-\u001f]/.test(e)&&n.push({field:t,message:`${t} \u4E0D\u80FD\u5305\u542B\u7A7A\u683C\u6216\u63A7\u5236\u5B57\u7B26`})}function we(e,t,n,r,o){if(!Number.isFinite(e)){o.push({field:t,message:`${t} \u5FC5\u987B\u662F\u6570\u5B57`});return}(e<n||e>r)&&o.push({field:t,message:`${t} \u5FC5\u987B\u5728 ${n} ~ ${r} \u4E4B\u95F4\uFF08\u5F53\u524D ${e}\uFF09`})}function xt(e,t,n){let r=e.split(/\r?\n|,/).map(o=>o.trim()).filter(Boolean);if(r.length>20){n.push({field:t,message:`${t} \u6700\u591A 20 \u6761\uFF08\u5F53\u524D ${r.length}\uFF09`});return}for(let o of r)if(!Gi.test(o)){n.push({field:t,message:`${t} \u91CC\u6709\u65E0\u6CD5\u8BC6\u522B\u7684\u6761\u76EE\uFF1A${o.slice(0,40)}`});return}}function bo(e,t,n){let r=e.split(/\r?\n|,/).map(o=>o.trim()).filter(Boolean);if(r.length>10){n.push({field:t,message:`${t} \u6700\u591A 10 \u6761\uFF08\u5F53\u524D ${r.length}\uFF09`});return}for(let o of r)if(!/^https?:\/\/\S+$/i.test(o)){n.push({field:t,message:`${t} \u5FC5\u987B\u662F http(s) \u5730\u5740\uFF1A${o.slice(0,40)}`});return}}function yn(e){let t=[],n=o=>Object.prototype.hasOwnProperty.call(e,o);n("wsPath")&&hn(String(e.wsPath??""),"wsPath",t),n("trojanPath")&&hn(String(e.trojanPath??""),"trojanPath",t),n("xhttpPath")&&hn(String(e.xhttpPath??""),"xhttpPath",t);let r=["wsPath","trojanPath","xhttpPath"].filter(o=>n(o)).map(o=>`${o}=${String(e[o]??"")}`);if(r.length>=2){let o=r.map(s=>s.slice(s.indexOf("=")+1));new Set(o).size!==o.length&&t.push({field:"paths",message:"wsPath / trojanPath / xhttpPath \u4E0D\u80FD\u91CD\u590D"})}if(n("subDomain")){let o=String(e.subDomain??"").trim();o&&(!Yi.test(o)||o.includes("/"))&&t.push({field:"subDomain",message:"subDomain \u5FC5\u987B\u662F\u5408\u6CD5\u4E3B\u673A\u540D\uFF08\u4E0D\u542B\u534F\u8BAE\u4E0E\u8DEF\u5F84\uFF09"})}if(n("proxyIp")&&xt(String(e.proxyIp??""),"proxyIp",t),n("socks5")&&xt(String(e.socks5??""),"socks5",t),n("httpProxy")&&xt(String(e.httpProxy??""),"httpProxy",t),n("relayPool")&&xt(String(e.relayPool??""),"relayPool",t),n("officialCount")&&we(Number(e.officialCount),"officialCount",1,200,t),n("domainCount")&&we(Number(e.domainCount),"domainCount",1,200,t),n("maxNodes")&&we(Number(e.maxNodes),"maxNodes",0,500,t),n("dls")&&we(Number(e.dls),"dls",0,1e3,t),n("maxLatency")&&we(Number(e.maxLatency),"maxLatency",0,1e4,t),n("dataBudgetMB")&&we(Number(e.dataBudgetMB),"dataBudgetMB",0,102400,t),n("subTokenTtlDays")&&we(Number(e.subTokenTtlDays),"subTokenTtlDays",0,3650,t),n("subPorts")){let o=String(e.subPorts??"").trim();if(o){let s=o.split(/[\n,;\s]+/).filter(Boolean);s.length>6?t.push({field:"subPorts",message:"subPorts \u6700\u591A 6 \u4E2A\u7AEF\u53E3"}):s.every(a=>/^\d{1,5}$/.test(a)&&Number(a)>=1&&Number(a)<=65535)||t.push({field:"subPorts",message:"subPorts \u91CC\u6BCF\u4E2A\u7AEF\u53E3\u90FD\u5FC5\u987B\u662F 1~65535 \u7684\u6570\u5B57"})}}if(n("subName")){let o=String(e.subName??"");o.length>40&&t.push({field:"subName",message:"subName \u6700\u591A 40 \u5B57\u7B26"}),/[\u0000-\u001f]/.test(o)&&t.push({field:"subName",message:"subName \u4E0D\u80FD\u5305\u542B\u63A7\u5236\u5B57\u7B26"})}if(n("addApi")&&bo(String(e.addApi??""),"addApi",t),n("addCsv")&&bo(String(e.addCsv??""),"addCsv",t),n("uuid")){let o=String(e.uuid??"").trim();o&&!/^[0-9a-fA-F]{8}-?[0-9a-fA-F]{4}-?[0-9a-fA-F]{4}-?[0-9a-fA-F]{4}-?[0-9a-fA-F]{12}$/.test(o)&&t.push({field:"uuid",message:"uuid \u5FC5\u987B\u662F\u6807\u51C6 UUID\uFF0836 \u4F4D\uFF0C\u53EF\u5E26\u8FDE\u5B57\u7B26\uFF09"})}if(n("poolCountries")){let o=String(e.poolCountries??"").trim();if(o){let s=o.split(/[\n,;\s]+/).filter(Boolean);s.length>30?t.push({field:"poolCountries",message:"poolCountries \u6700\u591A 30 \u4E2A\u56FD\u5BB6/\u5730\u533A"}):s.every(a=>/^[A-Za-z]{2,3}$/.test(a))||t.push({field:"poolCountries",message:"poolCountries \u53EA\u80FD\u662F 2~3 \u4F4D\u5B57\u6BCD\u4EE3\u7801"})}}if(n("udpDnsEndpoint")){let o=String(e.udpDnsEndpoint??"").trim();o&&!/^https:\/\/\S+$/i.test(o)&&t.push({field:"udpDnsEndpoint",message:"udpDnsEndpoint \u5FC5\u987B\u662F https \u5730\u5740"})}return t}function bn(e){return e.length===0?"":e.length===1?e[0].message:`\u6709 ${e.length} \u9879\u914D\u7F6E\u4E0D\u5408\u6CD5\uFF1A${e.map(t=>t.message).join("\uFF1B")}`}var Yi,Gi,wo=R(()=>{"use strict";Yi=/^(?=.{1,253}$)([A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?)(\.[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?)*$/,Gi=/^(?:(?:socks5|socks|socks5h|http|https):\/\/)?(?:[^\s@/]+@)?(?:\[[0-9a-fA-F:]+\]|[A-Za-z0-9._-]+)(?::\d{1,5})?$/});function So(e,t=Date.now()){let n={};for(let o of Po){let s=e[o];s!==void 0&&(n[o]=s)}let r=Ji.map(o=>({field:o.field,reason:o.reason}));for(let o of["socks5","httpProxy"]){let s=String(e[o]??"");if(!s){n[o]="";continue}if(s.includes("@")){r.push({field:o,reason:"\u542B\u7528\u6237\u540D/\u53E3\u4EE4\uFF0C\u9700\u624B\u5DE5\u91CD\u65B0\u586B\u5199"});continue}n[o]=s}return{schemaVersion:1,exportedAt:new Date(t).toISOString(),config:n,omitted:r}}function Eo(e){let t=new Set([...Po.map(String),"socks5","httpProxy"]),n={};for(let[r,o]of Object.entries(e))t.has(r)&&(n[r]=o);return n}function xo(e){if(e==null)return"\uFF08\u7A7A\uFF09";if(typeof e=="string"){let t=e.replace(/\s+/g," ").trim();return t.length>60?`${t.slice(0,60)}\u2026`:t||"\uFF08\u7A7A\uFF09"}return String(e)}function Ao(e,t){let n=[];for(let[r,o]of Object.entries(t)){let s=e[r];String(s)!==String(o)&&n.push({field:r,from:xo(s),to:xo(o)})}return n}var Po,Ji,To=R(()=>{"use strict";Po=["poolOfficial","officialCount","poolDomain","domainCount","poolManual","poolCountries","add","dls","maxLatency","maxNodes","proxyIp","relayPool","useBuiltinRelay","proxyMode","nat64","concurrentDial","dataBudgetMB","resolvePreferred","aggressiveRedial","enableTrojan","enableXhttp","subProtocol","subTransport","subVariants","subName","subPorts","clientFingerprint","ech","echHost","echDns","tlsFragment","tlsFragmentSize","tlsFragmentDelay","subToken","subTokenTtlDays","unlockProbe","udpDns","udpDnsEndpoint"],Ji=[{field:"uuid",reason:"\u5165\u7AD9\u51ED\u636E"},{field:"trojanPassword",reason:"\u5165\u7AD9\u51ED\u636E"},{field:"wsPath",reason:"\u5B9E\u4F8B\u6807\u8BC6\uFF08\u8BA2\u9605\u94FE\u63A5\u91CC\u53EF\u89C1\uFF0C\u5BFC\u51FA\u5373\u66B4\u9732\u5165\u53E3\uFF09"},{field:"trojanPath",reason:"\u5B9E\u4F8B\u6807\u8BC6"},{field:"xhttpPath",reason:"\u5B9E\u4F8B\u6807\u8BC6"},{field:"subDomain",reason:"\u5B9E\u4F8B\u6807\u8BC6"},{field:"addApi",reason:"URL \u53EF\u80FD\u542B\u79C1\u6709 token"},{field:"addCsv",reason:"URL \u53EF\u80FD\u542B\u79C1\u6709 token"}]});function Ro(){return new Response(JSON.stringify({build:Ge,version:wn,ts:Date.now()}),{status:200,headers:{"Content-Type":"application/json","Cache-Control":"no-store","Access-Control-Allow-Origin":"*"}})}var Ge,wn,Co,xn=R(()=>{"use strict";Ge="86b1357-d5c0a377",wn="0.15.9",Co="/__cfp_version"});var Io={};Le(Io,{API_PREFIX:()=>Pn,getScannerToken:()=>ea,handleApi:()=>ta,pruneLoginFailures:()=>vo});function _i(e){return e.headers.get("CF-Connecting-IP")??e.headers.get("x-forwarded-for")?.split(",")[0]?.trim()??"unknown"}function qi(e,t){let n=ke.get(e);return n?t>=n.resetAt?(ke.delete(e),!1):n.count>=Qi:!1}function vo(e,t,n=Zi){if(!(e.size<n)){for(let[r,o]of e)t>=o.resetAt&&e.delete(r);for(;e.size>=n;){let r=e.keys().next().value;if(r===void 0)break;e.delete(r)}}}function $i(e,t){let n=ke.get(e);if(!n||t>=n.resetAt){vo(ke,t),ke.set(e,{count:1,resetAt:t+ko});return}n.count+=1}function H(e,t=200,n={}){return new Response(JSON.stringify(e),{status:t,headers:{"Content-Type":"application/json; charset=utf-8","Cache-Control":"no-store",...n}})}function K(e,t){return H({ok:!1,error:e},t)}async function ea(e,t){let n=await e.get(Kt);if(n)return n;if(typeof t.SCANNER_TOKEN=="string"&&t.SCANNER_TOKEN)return t.SCANNER_TOKEN;let r=Q(24);return await e.put(Kt,r),r}async function ta(e,t,n){if(!t.pathname.startsWith(Pn))return null;let{store:r,env:o,config:s,auth:a}=n,i=t.pathname.slice(Pn.length)||"/",c=e.method.toUpperCase();if(i==="/session"&&c==="GET"){let l=await fn(r,e);return H({ok:!0,authenticated:l,panelPath:a.panelPath})}if(i==="/login"&&c==="POST"){let l="";try{let y=await e.json();l=String(y.password??"")}catch{return K("\u8BF7\u6C42\u4F53\u89E3\u6790\u5931\u8D25",400)}if(!l)return K("\u8BF7\u8F93\u5165\u5BC6\u7801",400);let u=_i(e),d=Date.now();if(qi(u,d))return new Response(JSON.stringify({ok:!1,error:"\u5C1D\u8BD5\u8FC7\u4E8E\u9891\u7E41\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5"}),{status:429,headers:{"Content-Type":"application/json; charset=utf-8","Cache-Control":"no-store","Retry-After":String(Math.ceil(ko/1e3))}});let m=await so(a,l);if(!m.ok)return $i(u,d),K("\u5BC6\u7801\u9519\u8BEF",401);ke.delete(u),m.legacy&&await io(r,l).catch(()=>{}),await ao(r).catch(()=>{});let g=await co(r);return H({ok:!0},200,{"Set-Cookie":uo(g)})}if(i==="/logout"&&c==="POST")return await po(r,e),H({ok:!0},200,{"Set-Cookie":fo()});if(i==="/preferred-ips"&&c==="POST"){let l=e.headers.get("Authorization")??"",u=l.startsWith("Bearer ")?l.slice(7).trim():l.trim();if(!await go(r,u))return K("Token \u6821\u9A8C\u5931\u8D25",401);let m;try{m=await e.json()}catch{return K("\u8BF7\u6C42\u4F53\u89E3\u6790\u5931\u8D25",400)}let y=(Array.isArray(m.ips)?m.ips.map(L=>String(L)):[]).map(L=>L.trim()).filter(L=>L.length>0),A=m.mode==="append",p=L=>L.split("#")[0].trim().replace(/^\[([^\]]+)\]:(\d+)$/,"$1:$2"),b=await r.get(ne),x,v=y.length;if(A){let L=(b??"").split(`
6
+ `))}function zr(e,t){let n=$t(t.config.subName);switch(e){case"clash":return{body:ki(t),contentType:"text/yaml; charset=utf-8",fileName:n};case"singbox":return{body:vi(t),contentType:"application/json; charset=utf-8",fileName:n};default:return{body:Ii(t),contentType:"text/plain; charset=utf-8",fileName:n}}}var be,si,ii,Ar,Tr,Cr,ai,li,ci,xi,Si,Ei,ye,Ai,Dr,Ur,Ti,Nr,tn=R(()=>{"use strict";re();ie();Gt();Sr();be=443;si=["ip\u5730\u5740","ip \u5730\u5740","ip","\u5730\u5740","\u670D\u52A1\u5668","server","host"],ii=["\u7AEF\u53E3","port"],Ar=["\u4E0B\u8F7D\u901F\u5EA6","\u901F\u5EA6","speed","download"],Tr=["\u5E73\u5747\u5EF6\u8FDF","\u5EF6\u8FDF","latency","delay","\u54CD\u5E94\u65F6\u95F4","rtt"],Cr=["colo","\u673A\u623F","\u6570\u636E\u4E2D\u5FC3","\u5730\u533A","region"],ai=["\u56FD\u5BB6","country","\u56FD\u522B"],li=["\u57CE\u5E02","city"],ci=["tls","\u662F\u5426\u652F\u6301tls","\u652F\u6301tls"];xi={official:"\u5B98\u65B9\u4F18\u9009IP",domain:"\u4F18\u9009\u57DF\u540D",manual:"\u4F18\u9009",api:"\u8FDC\u7A0BAPI",csv:"\u6D4B\u901FCSV"};Si=12e4,Ei=32,ye=new Map,Ai="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36";Dr=["vless-ws","vless-xhttp","trojan"];Ur=["vless-ws","trojan"];Ti=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;Nr=".cn,qq.com,tencent.com,weixin.qq.com,baidu.com,bdstatic.com,bilibili.com,hdslb.com,taobao.com,tmall.com,jd.com,aliyun.com,alicdn.com,alipay.com,163.com,126.net,zhihu.com,weibo.com,sina.com.cn,youku.com,iqiyi.com,douyin.com,xiaohongshu.com,mi.com,huawei.com,csdn.net,gitee.com,cnblogs.com".split(",")});function Bi(e){let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function Wr(e,t){let n=await crypto.subtle.importKey("raw",Kr.encode(e),{name:"HMAC",hash:"SHA-256"},!1,["sign"]),r=await crypto.subtle.sign("HMAC",n,Kr.encode(t));return Bi(new Uint8Array(r))}async function mt(e){let t=(await e.get(pt))?.trim();if(t)return t;let n=Yr();return e instanceof ue&&await e.put(pt,n),n}async function Gr(e){let t=Yr();return e instanceof ue?await e.put(pt,t):await e.put(pt,t),t}async function Jr(e,t={}){let n=t.ttlDays??0,r=Math.floor((t.now??Date.now())/1e3),o=n>0?r+Math.round(n*86400):0,s=Math.floor(Math.random()*36**8).toString(36).padStart(8,"0"),a=`${on}.${o.toString(36)}.${s}`,i=(await Wr(e,a)).slice(0,sn);return`${a}.${i}`}async function gt(e,t,n=Date.now()){if(!e||!t)return{ok:!1,reason:"format"};let r=t.split(".");if(r.length!==4||r[0]!==on)return{ok:!1,reason:"format"};let o=r[1],s=r[2],a=r[3];if(!o||!s||a.length!==sn)return{ok:!1,reason:"format"};let i=Number.parseInt(o,36);if(!Number.isFinite(i)||i<0)return{ok:!1,reason:"format"};let c=(await Wr(e,`${on}.${o}.${s}`)).slice(0,sn);return ee(a,c)?i>0&&Math.floor(n/1e3)>=i?{ok:!1,reason:"expired",exp:i}:{ok:!0,exp:i}:{ok:!1,reason:"signature"}}var pt,on,sn,Kr,Yr,an=R(()=>{"use strict";rt();ie();pt="SUB_TOKEN_SECRET",on="v1",sn=22,Kr=new TextEncoder;Yr=()=>Q(32)});function Vi(e){let t="";for(let n of e)t+=(n<16?"0":"")+n.toString(16);return t}function ji(e){if(!/^[0-9a-f]*$/.test(e)||e.length%2!==0)return null;let t=new Uint8Array(new ArrayBuffer(e.length/2));for(let n=0;n<t.length;n++)t[n]=Number.parseInt(e.slice(n*2,n*2+2),16);return t}async function to(e,t,n){let r=ji(t);if(!r)return null;let o=await crypto.subtle.importKey("raw",new TextEncoder().encode(e),"PBKDF2",!1,["deriveBits"]),s=await crypto.subtle.deriveBits({name:"PBKDF2",salt:r,iterations:n,hash:"SHA-256"},o,256);return Vi(new Uint8Array(s))}function no(e){if(e.startsWith(`${cn}$`)){let[r,o,s,a]=e.split("$");if(r!==cn||!s||!a)return null;let i=Number.parseInt(o??"",10);return!Number.isFinite(i)||i<1||i>1e6?null:{scheme:"pbkdf2",salt:s,iterations:i,expected:a}}let[t,n]=e.split(":");return!t||!n?null:{scheme:"sha256",salt:t,iterations:0,expected:n}}async function ro(e,t){return e.scheme==="pbkdf2"?await to(t,e.salt,e.iterations):await Vt(`${e.salt}:${t}`)}async function un(e,t){let n=await to(e,t,qr);return n?`${cn}$${qr}$${t}$${n}`:`${t}:${await Vt(`${t}:${e}`)}`}async function Xi(e,t){let n=no(e);if(!n)return!1;let r=await ro(n,t);return r?ee(r,n.expected):!1}function $r(e){return`/${e.trim().replace(/^\/+/,"")}`}async function oo(e,t,n){let r=await e.get(it)??"",o=n&&n.trim()?$r(n):"";o?r!==o&&(r=o,await e.put(it,r)):r||(r=$r(`${lr}-${rr(6)}`),await e.put(it,r));let s=await e.get(Ne)??"",a=null,i=t&&t.trim()?t.trim():"";if(i){if(!s||!await Xi(s,i)){let f=Q(8);s=await un(i,f),await e.put(Ne,s)}await e.get(Ae)&&await e.delete(Ae)}else if(!s){let c=`cfp-${Q(8)}`,f=Q(8);s=await un(c,f),await e.put(Ne,s),a=c,await e.put(Ae,c)}return{panelPath:r,passwordHash:s,generatedPassword:a}}async function so(e,t){let n=no(e.passwordHash);if(!n)return{ok:!1,legacy:!1};let r=await ro(n,t);if(!r)return{ok:!1,legacy:!1};let o=ee(r,n.expected);return{ok:o,legacy:o&&n.scheme==="sha256"}}async function io(e,t){let n=Q(8);await e.put(Ne,await un(t,n))}async function ao(e){await e.get(Ae)&&await e.delete(Ae)}function lo(e){let t=e.headers.get("Cookie")??"",n={};for(let r of t.split(";")){let o=r.indexOf("=");if(o<0)continue;let s=r.slice(0,o).trim(),a=r.slice(o+1).trim();s&&(n[s]=decodeURIComponent(a))}return n}async function co(e){let t=Q(24);return await e.put(`${st}${t}`,JSON.stringify({ua:"",t:Date.now()}),eo),t}async function fn(e,t){let n=lo(t)[yt];return n?!!await e.get(`${st}${n}`):!1}function uo(e,t=eo){return`${yt}=${e}; Path=/; HttpOnly; Secure; SameSite=Strict; Max-Age=${t}`}function fo(){return`${yt}=; Path=/; HttpOnly; Secure; SameSite=Strict; Max-Age=0`}async function po(e,t){let n=lo(t)[yt];n&&await e.delete(`${st}${n}`)}async function mo(e){let t=Q(20);return await e.put(`${ot}${t}`,"1",zi),t}async function go(e,t){if(!t)return!1;let n=await e.get("SCANNER_TOKEN");return n&&ee(n,t)?!0:await e.get(`${ot}${t}`)?(await e.delete(`${ot}${t}`),!0):!1}var yt,eo,zi,qr,cn,dn=R(()=>{"use strict";Be();ie();yt="cfpilot_sess",eo=3600*24,zi=600,qr=3e4,cn="pbkdf2"});function pn(e){return sr(e)}async function bt(e,t){if($.config&&Date.now()-$.configAt<Ki)return $.config;let n=await fr(e,t);return $.config=n,$.configAt=Date.now(),n}function ho(){$.config=null,$.configAt=0}async function mn(e,t){if($.auth&&Date.now()-$.authAt<Wi)return $.auth;let n=await oo(e,t.PANEL_PASSWORD,t.PANEL_PATH);return $.auth=n,$.authAt=Date.now(),n}function gn(e){switch((e??"").toLowerCase()){case"clash":case"mihomo":case"yaml":return"clash";case"singbox":case"sing-box":case"json":return"singbox";case"v2ray":return"v2ray";case"base64":return"base64";default:return"base64"}}function Ye(e){let t=String(e??"").trim();if(!t)return t;t=t.replace(/^[a-zA-Z][a-zA-Z0-9+.-]*:\/\//,""),t=t.replace(/[/?#].*$/,"");let n=t.lastIndexOf("@");if(n>=0&&(t=t.slice(n+1)),t.startsWith("[")){let r=t.indexOf("]");r>0&&(t=t.slice(1,r))}else{let r=t.indexOf(":");r>=0&&t.indexOf(":",r+1)<0&&(t=t.slice(0,r))}return t.trim()}function yo(e){let t=(e??"").toLowerCase();return t?t.includes("clash")||t.includes("mihomo")||t.includes("flclash")||t.includes("clashx")||t.includes("stash")?"clash":t.includes("sing-box")||t.includes("singbox")?"singbox":t.includes("v2ray")||t.includes("v2rayng")||t.includes("shadowrocket")||t.includes("nekobox")||t.includes("surge")||t.includes("loon")||t.includes("quantumult")?"base64":null:null}var Ki,Wi,$,wt=R(()=>{"use strict";rt();Be();dn();Ki=15e3,Wi=6e4,$={config:null,configAt:0,auth:null,authAt:0}});function hn(e,t,n){if(!e){n.push({field:t,message:`${t} \u4E0D\u80FD\u4E3A\u7A7A`});return}if(!e.startsWith("/")){n.push({field:t,message:`${t} \u5FC5\u987B\u4EE5 / \u5F00\u5934`});return}if(e.length>128){n.push({field:t,message:`${t} \u8FC7\u957F\uFF08\u6700\u591A 128 \u5B57\u7B26\uFF09`});return}/[\s\u0000-\u001f]/.test(e)&&n.push({field:t,message:`${t} \u4E0D\u80FD\u5305\u542B\u7A7A\u683C\u6216\u63A7\u5236\u5B57\u7B26`})}function we(e,t,n,r,o){if(!Number.isFinite(e)){o.push({field:t,message:`${t} \u5FC5\u987B\u662F\u6570\u5B57`});return}(e<n||e>r)&&o.push({field:t,message:`${t} \u5FC5\u987B\u5728 ${n} ~ ${r} \u4E4B\u95F4\uFF08\u5F53\u524D ${e}\uFF09`})}function xt(e,t,n){let r=e.split(/\r?\n|,/).map(o=>o.trim()).filter(Boolean);if(r.length>20){n.push({field:t,message:`${t} \u6700\u591A 20 \u6761\uFF08\u5F53\u524D ${r.length}\uFF09`});return}for(let o of r)if(!Gi.test(o)){n.push({field:t,message:`${t} \u91CC\u6709\u65E0\u6CD5\u8BC6\u522B\u7684\u6761\u76EE\uFF1A${o.slice(0,40)}`});return}}function bo(e,t,n){let r=e.split(/\r?\n|,/).map(o=>o.trim()).filter(Boolean);if(r.length>10){n.push({field:t,message:`${t} \u6700\u591A 10 \u6761\uFF08\u5F53\u524D ${r.length}\uFF09`});return}for(let o of r)if(!/^https?:\/\/\S+$/i.test(o)){n.push({field:t,message:`${t} \u5FC5\u987B\u662F http(s) \u5730\u5740\uFF1A${o.slice(0,40)}`});return}}function yn(e){let t=[],n=o=>Object.prototype.hasOwnProperty.call(e,o);n("wsPath")&&hn(String(e.wsPath??""),"wsPath",t),n("trojanPath")&&hn(String(e.trojanPath??""),"trojanPath",t),n("xhttpPath")&&hn(String(e.xhttpPath??""),"xhttpPath",t);let r=["wsPath","trojanPath","xhttpPath"].filter(o=>n(o)).map(o=>`${o}=${String(e[o]??"")}`);if(r.length>=2){let o=r.map(s=>s.slice(s.indexOf("=")+1));new Set(o).size!==o.length&&t.push({field:"paths",message:"wsPath / trojanPath / xhttpPath \u4E0D\u80FD\u91CD\u590D"})}if(n("subDomain")){let o=String(e.subDomain??"").trim();o&&(!Yi.test(o)||o.includes("/"))&&t.push({field:"subDomain",message:"subDomain \u5FC5\u987B\u662F\u5408\u6CD5\u4E3B\u673A\u540D\uFF08\u4E0D\u542B\u534F\u8BAE\u4E0E\u8DEF\u5F84\uFF09"})}if(n("proxyIp")&&xt(String(e.proxyIp??""),"proxyIp",t),n("socks5")&&xt(String(e.socks5??""),"socks5",t),n("httpProxy")&&xt(String(e.httpProxy??""),"httpProxy",t),n("relayPool")&&xt(String(e.relayPool??""),"relayPool",t),n("officialCount")&&we(Number(e.officialCount),"officialCount",1,200,t),n("domainCount")&&we(Number(e.domainCount),"domainCount",1,200,t),n("maxNodes")&&we(Number(e.maxNodes),"maxNodes",0,500,t),n("dls")&&we(Number(e.dls),"dls",0,1e3,t),n("maxLatency")&&we(Number(e.maxLatency),"maxLatency",0,1e4,t),n("dataBudgetMB")&&we(Number(e.dataBudgetMB),"dataBudgetMB",0,102400,t),n("subTokenTtlDays")&&we(Number(e.subTokenTtlDays),"subTokenTtlDays",0,3650,t),n("subPorts")){let o=String(e.subPorts??"").trim();if(o){let s=o.split(/[\n,;\s]+/).filter(Boolean);s.length>6?t.push({field:"subPorts",message:"subPorts \u6700\u591A 6 \u4E2A\u7AEF\u53E3"}):s.every(a=>/^\d{1,5}$/.test(a)&&Number(a)>=1&&Number(a)<=65535)||t.push({field:"subPorts",message:"subPorts \u91CC\u6BCF\u4E2A\u7AEF\u53E3\u90FD\u5FC5\u987B\u662F 1~65535 \u7684\u6570\u5B57"})}}if(n("subName")){let o=String(e.subName??"");o.length>40&&t.push({field:"subName",message:"subName \u6700\u591A 40 \u5B57\u7B26"}),/[\u0000-\u001f]/.test(o)&&t.push({field:"subName",message:"subName \u4E0D\u80FD\u5305\u542B\u63A7\u5236\u5B57\u7B26"})}if(n("addApi")&&bo(String(e.addApi??""),"addApi",t),n("addCsv")&&bo(String(e.addCsv??""),"addCsv",t),n("uuid")){let o=String(e.uuid??"").trim();o&&!/^[0-9a-fA-F]{8}-?[0-9a-fA-F]{4}-?[0-9a-fA-F]{4}-?[0-9a-fA-F]{4}-?[0-9a-fA-F]{12}$/.test(o)&&t.push({field:"uuid",message:"uuid \u5FC5\u987B\u662F\u6807\u51C6 UUID\uFF0836 \u4F4D\uFF0C\u53EF\u5E26\u8FDE\u5B57\u7B26\uFF09"})}if(n("poolCountries")){let o=String(e.poolCountries??"").trim();if(o){let s=o.split(/[\n,;\s]+/).filter(Boolean);s.length>30?t.push({field:"poolCountries",message:"poolCountries \u6700\u591A 30 \u4E2A\u56FD\u5BB6/\u5730\u533A"}):s.every(a=>/^[A-Za-z]{2,3}$/.test(a))||t.push({field:"poolCountries",message:"poolCountries \u53EA\u80FD\u662F 2~3 \u4F4D\u5B57\u6BCD\u4EE3\u7801"})}}if(n("udpDnsEndpoint")){let o=String(e.udpDnsEndpoint??"").trim();o&&!/^https:\/\/\S+$/i.test(o)&&t.push({field:"udpDnsEndpoint",message:"udpDnsEndpoint \u5FC5\u987B\u662F https \u5730\u5740"})}return t}function bn(e){return e.length===0?"":e.length===1?e[0].message:`\u6709 ${e.length} \u9879\u914D\u7F6E\u4E0D\u5408\u6CD5\uFF1A${e.map(t=>t.message).join("\uFF1B")}`}var Yi,Gi,wo=R(()=>{"use strict";Yi=/^(?=.{1,253}$)([A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?)(\.[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?)*$/,Gi=/^(?:(?:socks5|socks|socks5h|http|https):\/\/)?(?:[^\s@/]+@)?(?:\[[0-9a-fA-F:]+\]|[A-Za-z0-9._-]+)(?::\d{1,5})?$/});function So(e,t=Date.now()){let n={};for(let o of Po){let s=e[o];s!==void 0&&(n[o]=s)}let r=Ji.map(o=>({field:o.field,reason:o.reason}));for(let o of["socks5","httpProxy"]){let s=String(e[o]??"");if(!s){n[o]="";continue}if(s.includes("@")){r.push({field:o,reason:"\u542B\u7528\u6237\u540D/\u53E3\u4EE4\uFF0C\u9700\u624B\u5DE5\u91CD\u65B0\u586B\u5199"});continue}n[o]=s}return{schemaVersion:1,exportedAt:new Date(t).toISOString(),config:n,omitted:r}}function Eo(e){let t=new Set([...Po.map(String),"socks5","httpProxy"]),n={};for(let[r,o]of Object.entries(e))t.has(r)&&(n[r]=o);return n}function xo(e){if(e==null)return"\uFF08\u7A7A\uFF09";if(typeof e=="string"){let t=e.replace(/\s+/g," ").trim();return t.length>60?`${t.slice(0,60)}\u2026`:t||"\uFF08\u7A7A\uFF09"}return String(e)}function Ao(e,t){let n=[];for(let[r,o]of Object.entries(t)){let s=e[r];String(s)!==String(o)&&n.push({field:r,from:xo(s),to:xo(o)})}return n}var Po,Ji,To=R(()=>{"use strict";Po=["poolOfficial","officialCount","poolDomain","domainCount","poolManual","poolCountries","add","dls","maxLatency","maxNodes","proxyIp","relayPool","useBuiltinRelay","proxyMode","nat64","concurrentDial","dataBudgetMB","resolvePreferred","aggressiveRedial","enableTrojan","enableXhttp","subProtocol","subTransport","subVariants","subName","subPorts","clientFingerprint","ech","echHost","echDns","tlsFragment","tlsFragmentSize","tlsFragmentDelay","subToken","subTokenTtlDays","unlockProbe","udpDns","udpDnsEndpoint"],Ji=[{field:"uuid",reason:"\u5165\u7AD9\u51ED\u636E"},{field:"trojanPassword",reason:"\u5165\u7AD9\u51ED\u636E"},{field:"wsPath",reason:"\u5B9E\u4F8B\u6807\u8BC6\uFF08\u8BA2\u9605\u94FE\u63A5\u91CC\u53EF\u89C1\uFF0C\u5BFC\u51FA\u5373\u66B4\u9732\u5165\u53E3\uFF09"},{field:"trojanPath",reason:"\u5B9E\u4F8B\u6807\u8BC6"},{field:"xhttpPath",reason:"\u5B9E\u4F8B\u6807\u8BC6"},{field:"subDomain",reason:"\u5B9E\u4F8B\u6807\u8BC6"},{field:"addApi",reason:"URL \u53EF\u80FD\u542B\u79C1\u6709 token"},{field:"addCsv",reason:"URL \u53EF\u80FD\u542B\u79C1\u6709 token"}]});function Ro(){return new Response(JSON.stringify({build:Ge,version:wn,ts:Date.now()}),{status:200,headers:{"Content-Type":"application/json","Cache-Control":"no-store","Access-Control-Allow-Origin":"*"}})}var Ge,wn,Co,xn=R(()=>{"use strict";Ge="2c7b165-d5c0a377",wn="0.16.0",Co="/__cfp_version"});var Io={};Le(Io,{API_PREFIX:()=>Pn,getScannerToken:()=>ea,handleApi:()=>ta,pruneLoginFailures:()=>vo});function _i(e){return e.headers.get("CF-Connecting-IP")??e.headers.get("x-forwarded-for")?.split(",")[0]?.trim()??"unknown"}function qi(e,t){let n=ke.get(e);return n?t>=n.resetAt?(ke.delete(e),!1):n.count>=Qi:!1}function vo(e,t,n=Zi){if(!(e.size<n)){for(let[r,o]of e)t>=o.resetAt&&e.delete(r);for(;e.size>=n;){let r=e.keys().next().value;if(r===void 0)break;e.delete(r)}}}function $i(e,t){let n=ke.get(e);if(!n||t>=n.resetAt){vo(ke,t),ke.set(e,{count:1,resetAt:t+ko});return}n.count+=1}function H(e,t=200,n={}){return new Response(JSON.stringify(e),{status:t,headers:{"Content-Type":"application/json; charset=utf-8","Cache-Control":"no-store",...n}})}function K(e,t){return H({ok:!1,error:e},t)}async function ea(e,t){let n=await e.get(Kt);if(n)return n;if(typeof t.SCANNER_TOKEN=="string"&&t.SCANNER_TOKEN)return t.SCANNER_TOKEN;let r=Q(24);return await e.put(Kt,r),r}async function ta(e,t,n){if(!t.pathname.startsWith(Pn))return null;let{store:r,env:o,config:s,auth:a}=n,i=t.pathname.slice(Pn.length)||"/",c=e.method.toUpperCase();if(i==="/session"&&c==="GET"){let l=await fn(r,e);return H({ok:!0,authenticated:l,panelPath:a.panelPath})}if(i==="/login"&&c==="POST"){let l="";try{let y=await e.json();l=String(y.password??"")}catch{return K("\u8BF7\u6C42\u4F53\u89E3\u6790\u5931\u8D25",400)}if(!l)return K("\u8BF7\u8F93\u5165\u5BC6\u7801",400);let u=_i(e),d=Date.now();if(qi(u,d))return new Response(JSON.stringify({ok:!1,error:"\u5C1D\u8BD5\u8FC7\u4E8E\u9891\u7E41\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5"}),{status:429,headers:{"Content-Type":"application/json; charset=utf-8","Cache-Control":"no-store","Retry-After":String(Math.ceil(ko/1e3))}});let m=await so(a,l);if(!m.ok)return $i(u,d),K("\u5BC6\u7801\u9519\u8BEF",401);ke.delete(u),m.legacy&&await io(r,l).catch(()=>{}),await ao(r).catch(()=>{});let g=await co(r);return H({ok:!0},200,{"Set-Cookie":uo(g)})}if(i==="/logout"&&c==="POST")return await po(r,e),H({ok:!0},200,{"Set-Cookie":fo()});if(i==="/preferred-ips"&&c==="POST"){let l=e.headers.get("Authorization")??"",u=l.startsWith("Bearer ")?l.slice(7).trim():l.trim();if(!await go(r,u))return K("Token \u6821\u9A8C\u5931\u8D25",401);let m;try{m=await e.json()}catch{return K("\u8BF7\u6C42\u4F53\u89E3\u6790\u5931\u8D25",400)}let y=(Array.isArray(m.ips)?m.ips.map(L=>String(L)):[]).map(L=>L.trim()).filter(L=>L.length>0),A=m.mode==="append",p=L=>L.split("#")[0].trim().replace(/^\[([^\]]+)\]:(\d+)$/,"$1:$2"),b=await r.get(ne),x,v=y.length;if(A){let L=(b??"").split(`
7
7
  `).map(S=>S.trim()).filter(S=>S.length>0),I=new Set(L.map(p)),z=y.filter(S=>{let k=p(S);return I.has(k)?!1:(I.add(k),!0)});v=z.length,x=[...L,...z].join(`
8
8
  `)}else x=y.join(`
9
9
  `);b!==x&&await r.put(ne,x);let T={};!A&&(s.add??"").trim()!==""&&(T.add=""),s.poolManual||(T.poolManual=!0);let P=!1;return Object.keys(T).length>0&&(await Oe(r,Ue(s,T)),n.onConfigChanged(),P=T.add!==void 0),H({ok:!0,mode:A?"append":"replace",count:y.length,added:v,clearedManual:P,enabledManual:T.poolManual===!0})}if(!await fn(r,e))return K("\u672A\u767B\u5F55\u6216\u4F1A\u8BDD\u5DF2\u8FC7\u671F",401);if(i==="/status"&&c==="GET"){let l=await Me(r),u=Ke(l),d=Ye(s.subDomain||o.DATA_HOST||t.hostname);return H({ok:!0,panelPath:a.panelPath,domain:t.hostname,nodeDomain:d,dataHost:o.DATA_HOST??"",colo:e.cf?.colo??"UNK",coloLabel:je(e.cf?.colo??""),localIps:u.length,generatedPassword:a.generatedPassword,version:Ge,pkgVersion:wn,readAt:Date.now()})}if(i==="/config"&&c==="GET")return H({ok:!0,config:s});if(i==="/config"&&c==="PUT"){let l;try{l=await e.json()}catch{return K("\u8BF7\u6C42\u4F53\u89E3\u6790\u5931\u8D25",400)}if(!l.config||typeof l.config!="object")return K("\u7F3A\u5C11\u914D\u7F6E\u5BF9\u8C61",400);let u=yn(l.config);if(u.length>0)return K(bn(u),400);let d=Ue(s,l.config);return await Oe(r,d),n.onConfigChanged(),H({ok:!0,config:d})}if(i==="/config/export"&&c==="GET")return H({ok:!0,...So(s)});if(i==="/config/import"&&c==="POST"){let l;try{l=await e.json()}catch{return K("\u8BF7\u6C42\u4F53\u89E3\u6790\u5931\u8D25",400)}if(!l.config||typeof l.config!="object")return K("\u7F3A\u5C11\u914D\u7F6E\u5BF9\u8C61",400);let u=Eo(l.config);if(Object.keys(u).length===0)return K("\u6CA1\u6709\u53EF\u5BFC\u5165\u7684\u5B57\u6BB5\uFF08\u786E\u8BA4\u662F\u672C\u9879\u76EE\u5BFC\u51FA\u7684\u914D\u7F6E\u6587\u4EF6\uFF1F\uFF09",400);let d=yn(u);if(d.length>0)return K(bn(d),400);let m=Ao(s,u);if(l.dryRun)return H({ok:!0,dryRun:!0,diff:m,count:m.length});if(m.length===0)return H({ok:!0,applied:0,diff:[],config:s});let g=Ue(s,u);return await Oe(r,g),n.onConfigChanged(),H({ok:!0,applied:m.length,diff:m,config:g})}if(i==="/ips"&&c==="GET"){let l=await Me(r),u=Ke(l);return H({ok:!0,raw:l,count:u.length,entries:u})}if(i==="/ips"&&c==="DELETE")return await r.delete(ne),H({ok:!0});if(i==="/ips"&&c==="PUT"){let l;try{l=await e.json()}catch{return K("\u8BF7\u6C42\u4F53\u89E3\u6790\u5931\u8D25",400)}if(typeof l.raw!="string")return K("\u7F3A\u5C11 raw \u5B57\u6BB5",400);let u=l.raw.split(/\r?\n/).map(d=>d.trim()).filter(d=>d.length>0).join(`
package/dist/cli.js CHANGED
@@ -87,7 +87,7 @@ var VERSION, NAME;
87
87
  var init_version = __esm({
88
88
  "src/shared/version.ts"() {
89
89
  "use strict";
90
- VERSION = "0.15.9";
90
+ VERSION = "0.16.0";
91
91
  NAME = "cfpilot";
92
92
  }
93
93
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cfpilot",
3
- "version": "0.15.9",
3
+ "version": "0.16.0",
4
4
  "description": "CFPilot —— Cloudflare Pages 代理部署与优选工具(交互菜单 + 子命令)",
5
5
  "type": "module",
6
6
  "license": "AGPL-3.0-only",