cfpilot 0.15.4 → 0.15.5

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 H=""+k+__sfx("IFRyb2phbg==");r.push(H),N.push(H),n.push([__sfx("ICAtIG5hbWU6IA==")+B(H)+"",__sfx("ICAgIHR5cGU6IHRyb2phbg=="),__sfx("ICAgIHBhc3N3b3JkOiA=")+B(t.config.trojanPassword)+"",__sfx("ICAgIHNlcnZlcjog")+g.ip+"",__sfx("ICAgIHBvcnQ6IA==")+A+"",__sfx("ICAgIG5ldHdvcms6IHdz"),__sfx("ICAgIHRsczogdHJ1ZQ=="),__sfx("ICAgIHNuaTog")+t.domain+"",__sfx("ICAgIGNsaWVudC1maW5nZXJwcmludDog")+t.config.clientFingerprint+"",...u()," ws-opts:",__sfx("ICAgICAgcGF0aDog")+B(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(""),c&&(e.push(" nameserver-policy:"),e.push(` ${B(p)}: ${l?B(l):"https://223.5.5.5/dns-query"}`),e.push(""));let f=Mt(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(` - ${B(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(` - ${B(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(` - ${B(g)}`);let d=(g,h)=>{e.push(""),e.push(__sfx("ICAtIG5hbWU6IA==")+B(g)+""),e.push(__sfx("ICAgIHR5cGU6IHNlbGVjdA==")),e.push(" proxies:");for(let R of h)e.push(` - ${B(R)}`)};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(...Ft(__sfx("Q0ZQaWxvdA=="))),e.push(""),e.join(`
5
5
  `)}function Ur(t){let e=[],n=[],r=We(t.config.subVariants,t.config,qt),o=r.some(l=>l===__sfx("dmxlc3Mtd3M=")),s=r.includes(__sfx("dHJvamFu")),a=t.config.ech,i=t.config.echHost.trim()||__sfx("Y2xvdWRmbGFyZS1lY2guY29t"),c=()=>a?{ech:{enabled:!0,query_server_name:i}}:{};for(let l of Ze(t)){let u=[];l.entries.forEach((f,d)=>{let g=`${l.name} ${he(f,"vless",d,"")}`;for(let h of qe(f,t)){let R=t.ports.length>1?`:${h}`:"",N=`${g}${R}`,A=""+N+__sfx("IFRyb2phbg==");o&&u.push(N),s&&u.push(A),o&&e.push({type:__sfx("dmxlc3M="),tag:N,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},...c()},transport:{type:"ws",path:t.config.wsPath,headers:{Host:t.domain}}}),s&&e.push({type:__sfx("dHJvamFu"),tag:A,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},...c()},transport:{type:"ws",path:t.config.trojanPath,headers:{Host:t.domain}}})}}),u.length>0&&n.push({tag:l.name,members:u})}e.push({type:"direct",tag:"direct"});for(let l of n)e.push({type:"selector",tag:l.tag,outbounds:l.members,default:l.members[0]});return e.push({type:"selector",tag:__sfx("Q0ZQaWxvdA=="),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:Qt,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:Qt,outbound:"direct"}],final:__sfx("Q0ZQaWxvdA=="),auto_detect_interface:!0}},null,2)}function jr(t){let e=[],n=We(t.config.subVariants,t.config);for(let r of Ze(t))r.entries.forEach((o,s)=>{let a=he(o,__sfx("dmxlc3M="),s,r.name);for(let i of qe(o,t)){let c=t.ports.length>1?`:${i}`:"",p=`${a}${c}`,l={...o,port:i};for(let u of n)u===__sfx("dmxlc3Mtd3M=")?e.push(Zt(l,t,"ws",`${p} WS`)):u===__sfx("dmxlc3MteGh0dHA=")?e.push(Zt(l,t,__sfx("eGh0dHA="),""+p+__sfx("IFhIVFRQ"))):e.push(Mr(l,t,""+p+__sfx("IFRyb2phbg==")))}});return Pt(e.join(`
6
- `))}function nn(t,e){let n=Qe(e.config.subName);switch(t){case __sfx("Y2xhc2g="):return{body:Br(e),contentType:"text/yaml; charset=utf-8",fileName:n};case"singbox":return{body:Ur(e),contentType:"application/json; charset=utf-8",fileName:n};default:return{body:jr(e),contentType:"text/plain; charset=utf-8",fileName:n}}}var ee,mr,hr,jt,Yt,Kt,br,yr,wr,Dr,Rr,Lr,$,kr,Wt,qt,Hr,Qt,Je=O(()=>{"use strict";Dt();X();Ge();Bt();ee=443;mr=[__sfx("aXDlnLDlnYA="),__sfx("aXAg5Zyw5Z2A"),"ip",__sfx("5Zyw5Z2A"),__sfx("5pyN5Yqh5Zmo"),"server","host"],hr=[__sfx("56uv5Y+j"),"port"],jt=[__sfx("5LiL6L296YCf5bqm"),__sfx("6YCf5bqm"),"speed","download"],Yt=[__sfx("5bmz5Z2H5bu26L+f"),__sfx("5bu26L+f"),"latency","delay",__sfx("5ZON5bqU5pe26Ze0"),"rtt"],Kt=["colo",__sfx("5py65oi/"),__sfx("5pWw5o2u5Lit5b+D"),__sfx("5Zyw5Yy6"),"region"],br=[__sfx("5Zu95a62"),"country",__sfx("5Zu95Yir")],yr=[__sfx("5Z+O5biC"),"city"],wr=["tls",__sfx("5piv5ZCm5pSv5oyBdGxz"),__sfx("5pSv5oyBdGxz")];Dr={official:__sfx("5a6Y5pa55LyY6YCJSVA="),domain:__sfx("5LyY6YCJ5Z+f5ZCN"),manual:__sfx("5LyY6YCJ"),api:__sfx("6L+c56iLQVBJ"),csv:__sfx("5rWL6YCfQ1NW")};Rr=12e4,Lr=32,$=new Map,kr="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36";Wt=[__sfx("dmxlc3Mtd3M="),__sfx("dmxlc3MteGh0dHA="),__sfx("dHJvamFu")];qt=[__sfx("dmxlc3Mtd3M="),__sfx("dHJvamFu")];Hr=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;Qt=".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 Zr(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 ln(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 Zr(new Uint8Array(r))}async function ve(t){let e=(await t.get(Ne))?.trim();if(e)return e;let n=cn();return t instanceof W&&await t.put(Ne,n),n}async function fn(t){let e=cn();return t instanceof W?await t.put(Ne,e):await t.put(Ne,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=`${et}.${o.toString(36)}.${s}`,i=(await ln(t,a)).slice(0,tt);return`${a}.${i}`}async function Ie(t,e,n=Date.now()){if(!t||!e)return{ok:!1,reason:"format"};let r=e.split(".");if(r.length!==4||r[0]!==et)return{ok:!1,reason:"format"};let o=r[1],s=r[2],a=r[3];if(!o||!s||a.length!==tt)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 ln(t,`${et}.${o}.${s}`)).slice(0,tt);return z(a,c)?i>0&&Math.floor(n/1e3)>=i?{ok:!1,reason:"expired",exp:i}:{ok:!0,exp:i}:{ok:!1,reason:"signature"}}var Ne,et,tt,un,cn,nt=O(()=>{"use strict";ye();X();Ne="SUB_TOKEN_SECRET",et="v1",tt=22,un=new TextEncoder;cn=()=>M(32)});function Jr(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 wn(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 Jr(new Uint8Array(s))}function En(t){if(t.startsWith(`${ot}$`)){let[r,o,s,a]=t.split("$");if(r!==ot||!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 Pn(t,e){return t.scheme==="pbkdf2"?await wn(e,t.salt,t.iterations):await Me(`${t.salt}:${e}`)}async function st(t,e){let n=await wn(t,e,hn);return n?`${ot}$${hn}$${e}$${n}`:`${e}:${await Me(`${e}:${t}`)}`}async function $r(t,e){let n=En(t);if(!n)return!1;let r=await Pn(n,e);return r?z(r,n.expected):!1}function bn(t){return`/${t.trim().replace(/^\/+/,"")}`}async function Sn(t,e,n){let r=await t.get(Pe)??"",o=n&&n.trim()?bn(n):"";o?r!==o&&(r=o,await t.put(Pe,r)):r||(r=bn(`${xt}-${Et(6)}`),await t.put(Pe,r));let s=await t.get(ie)??"",a=null,i=e&&e.trim()?e.trim():"";if(i){if(!s||!await $r(s,i)){let p=M(8);s=await st(i,p),await t.put(ie,s)}await t.get(re)&&await t.delete(re)}else if(!s){let c=`cfp-${M(8)}`,p=M(8);s=await st(c,p),await t.put(ie,s),a=c,await t.put(re,c)}return{panelPath:r,passwordHash:s,generatedPassword:a}}async function Cn(t,e){let n=En(t.passwordHash);if(!n)return{ok:!1,legacy:!1};let r=await Pn(n,e);if(!r)return{ok:!1,legacy:!1};let o=z(r,n.expected);return{ok:o,legacy:o&&n.scheme==="sha256"}}async function An(t,e){let n=M(8);await t.put(ie,await st(e,n))}async function xn(t){await t.get(re)&&await t.delete(re)}function Tn(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 Nn(t){let e=M(24);return await t.put(`${Ee}${e}`,JSON.stringify({ua:"",t:Date.now()}),yn),e}async function it(t,e){let n=Tn(e)[Oe];return n?!!await t.get(`${Ee}${n}`):!1}function vn(t,e=yn){return`${Oe}=${t}; Path=/; HttpOnly; Secure; SameSite=Strict; Max-Age=${e}`}function In(){return`${Oe}=; Path=/; HttpOnly; Secure; SameSite=Strict; Max-Age=0`}async function Dn(t,e){let n=Tn(e)[Oe];n&&await t.delete(`${Ee}${n}`)}async function On(t){let e=M(20);return await t.put(`${we}${e}`,"1",qr),e}async function Rn(t,e){if(!e)return!1;let n=await t.get("SCANNER_TOKEN");return n&&z(n,e)?!0:await t.get(`${we}${e}`)?(await t.delete(`${we}${e}`),!0):!1}var Oe,yn,qr,hn,ot,at=O(()=>{"use strict";fe();X();Oe=__sfx("Y2ZwaWxvdF9zZXNz"),yn=3600*24,qr=600,hn=3e4,ot="pbkdf2"});function Ln(t){return St(t)}async function ut(t,e){if(U.config&&Date.now()-U.configAt<eo)return U.config;let n=await vt(t,e);return U.config=n,U.configAt=Date.now(),n}function kn(){U.config=null,U.configAt=0}async function lt(t,e){if(U.auth&&Date.now()-U.authAt<to)return U.auth;let n=await Sn(t,e.PANEL_PASSWORD,e.PANEL_PATH);return U.auth=n,U.authAt=Date.now(),n}function ct(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 be(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 Hn(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 eo,to,U,Re=O(()=>{"use strict";ye();fe();at();eo=15e3,to=6e4,U={config:null,configAt:0,auth:null,authAt:0}});function ft(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 te(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 Le(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 Fn(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 pt(t){let e=[],n=o=>Object.prototype.hasOwnProperty.call(t,o);n("wsPath")&&ft(String(t.wsPath??""),"wsPath",e),n(__sfx("dHJvamFuUGF0aA=="))&&ft(String(t.trojanPath??""),__sfx("dHJvamFuUGF0aA=="),e),n(__sfx("eGh0dHBQYXRo"))&&ft(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=="))&&Le(String(t.proxyIp??""),__sfx("cHJveHlJcA=="),e),n(__sfx("c29ja3M1"))&&Le(String(t.socks5??""),__sfx("c29ja3M1"),e),n("httpProxy")&&Le(String(t.httpProxy??""),"httpProxy",e),n("relayPool")&&Le(String(t.relayPool??""),"relayPool",e),n("officialCount")&&te(Number(t.officialCount),"officialCount",1,200,e),n("domainCount")&&te(Number(t.domainCount),"domainCount",1,200,e),n("maxNodes")&&te(Number(t.maxNodes),"maxNodes",0,500,e),n("dls")&&te(Number(t.dls),"dls",0,1e3,e),n("maxLatency")&&te(Number(t.maxLatency),"maxLatency",0,1e4,e),n("dataBudgetMB")&&te(Number(t.dataBudgetMB),"dataBudgetMB",0,102400,e),n("subTokenTtlDays")&&te(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")&&Fn(String(t.addApi??""),"addApi",e),n("addCsv")&&Fn(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 dt(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=O(()=>{"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 jn(t,e=Date.now()){let n={};for(let o of Un){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 Yn(t){let e=new Set([...Un.map(String),__sfx("c29ja3M1"),"httpProxy"]),n={};for(let[r,o]of Object.entries(t))e.has(r)&&(n[r]=o);return n}function Bn(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 Kn(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:Bn(s),to:Bn(o)})}return n}var Un,oo,Gn=O(()=>{"use strict";Un=["poolOfficial","officialCount","poolDomain","domainCount","poolManual","poolCountries","add","dls","maxLatency","maxNodes",__sfx("cHJveHlJcA=="),"relayPool","useBuiltinRelay","proxyMode","nat64","concurrentDial","dataBudgetMB","resolvePreferred",__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 Vn(){return new Response(JSON.stringify({build:gt,version:mt,ts:Date.now()}),{status:200,headers:{"Content-Type":"application/json","Cache-Control":"no-store","Access-Control-Allow-Origin":"*"}})}var gt,mt,zn,ht=O(()=>{"use strict";gt="b0b7d2f-547f9c43",mt=__sfx("MC4xNS40"),zn=__sfx("L19fY2ZwX3ZlcnNpb24=")});var Zn={};tr(Zn,{API_PREFIX:()=>bt,getScannerToken:()=>lo,handleApi:()=>co});function io(t){return t.headers.get("CF-Connecting-IP")??t.headers.get("x-forwarded-for")?.split(",")[0]?.trim()??"unknown"}function ao(t,e){let n=G.get(t);return n?e>=n.resetAt?(G.delete(t),!1):n.count>=so:!1}function uo(t,e){let n=G.get(t);if(!n||e>=n.resetAt){if(G.size>=Xn){for(let[r,o]of G)e>=o.resetAt&&G.delete(r);G.size>=Xn&&G.clear()}G.set(t,{count:1,resetAt:e+Wn});return}n.count+=1}function C(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 T(t,e){return C({ok:!1,error:t},e)}async function lo(t,e){let n=await t.get(je);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(je,r),r}async function co(t,e,n){if(!e.pathname.startsWith(bt))return null;let{store:r,env:o,config:s,auth:a}=n,i=e.pathname.slice(bt.length)||"/",c=t.method.toUpperCase();if(i==="/session"&&c==="GET"){let l=await it(r,t);return C({ok:!0,authenticated:l,panelPath:a.panelPath})}if(i==="/login"&&c==="POST"){let l="";try{let h=await t.json();l=String(h.password??"")}catch{return T(__sfx("6K+35rGC5L2T6Kej5p6Q5aSx6LSl"),400)}if(!l)return T(__sfx("6K+36L6T5YWl5a+G56CB"),400);let u=io(t),f=Date.now();if(ao(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 Cn(a,l);if(!d.ok)return uo(u,f),T(__sfx("5a+G56CB6ZSZ6K+v"),401);G.delete(u),d.legacy&&await An(r,l).catch(()=>{}),await xn(r).catch(()=>{});let g=await Nn(r);return C({ok:!0},200,{"Set-Cookie":vn(g)})}if(i==="/logout"&&c==="POST")return await Dn(r,t),C({ok:!0},200,{"Set-Cookie":In()});if(i==="/preferred-ips"&&c==="POST"){let l=t.headers.get("Authorization")??"",u=l.startsWith("Bearer ")?l.slice(7).trim():l.trim();if(!await Rn(r,u))return T(__sfx("VG9rZW4g5qCh6aqM5aSx6LSl"),401);let d;try{d=await t.json()}catch{return T(__sfx("6K+35rGC5L2T6Kej5p6Q5aSx6LSl"),400)}let h=(Array.isArray(d.ips)?d.ips.map(P=>String(P)):[]).map(P=>P.trim()).filter(P=>P.length>0),R=d.mode==="append",N=P=>P.split("#")[0].trim().replace(/^\[([^\]]+)\]:(\d+)$/,"$1:$2"),A=await r.get(K),L,k=h.length;if(R){let P=(A??"").split(`
6
+ `))}function nn(t,e){let n=Qe(e.config.subName);switch(t){case __sfx("Y2xhc2g="):return{body:Br(e),contentType:"text/yaml; charset=utf-8",fileName:n};case"singbox":return{body:Ur(e),contentType:"application/json; charset=utf-8",fileName:n};default:return{body:jr(e),contentType:"text/plain; charset=utf-8",fileName:n}}}var ee,mr,hr,jt,Yt,Kt,br,yr,wr,Dr,Rr,Lr,$,kr,Wt,qt,Hr,Qt,Je=O(()=>{"use strict";Dt();X();Ge();Bt();ee=443;mr=[__sfx("aXDlnLDlnYA="),__sfx("aXAg5Zyw5Z2A"),"ip",__sfx("5Zyw5Z2A"),__sfx("5pyN5Yqh5Zmo"),"server","host"],hr=[__sfx("56uv5Y+j"),"port"],jt=[__sfx("5LiL6L296YCf5bqm"),__sfx("6YCf5bqm"),"speed","download"],Yt=[__sfx("5bmz5Z2H5bu26L+f"),__sfx("5bu26L+f"),"latency","delay",__sfx("5ZON5bqU5pe26Ze0"),"rtt"],Kt=["colo",__sfx("5py65oi/"),__sfx("5pWw5o2u5Lit5b+D"),__sfx("5Zyw5Yy6"),"region"],br=[__sfx("5Zu95a62"),"country",__sfx("5Zu95Yir")],yr=[__sfx("5Z+O5biC"),"city"],wr=["tls",__sfx("5piv5ZCm5pSv5oyBdGxz"),__sfx("5pSv5oyBdGxz")];Dr={official:__sfx("5a6Y5pa55LyY6YCJSVA="),domain:__sfx("5LyY6YCJ5Z+f5ZCN"),manual:__sfx("5LyY6YCJ"),api:__sfx("6L+c56iLQVBJ"),csv:__sfx("5rWL6YCfQ1NW")};Rr=12e4,Lr=32,$=new Map,kr="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36";Wt=[__sfx("dmxlc3Mtd3M="),__sfx("dmxlc3MteGh0dHA="),__sfx("dHJvamFu")];qt=[__sfx("dmxlc3Mtd3M="),__sfx("dHJvamFu")];Hr=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;Qt=".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 Zr(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 ln(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 Zr(new Uint8Array(r))}async function ve(t){let e=(await t.get(Ne))?.trim();if(e)return e;let n=cn();return t instanceof W&&await t.put(Ne,n),n}async function fn(t){let e=cn();return t instanceof W?await t.put(Ne,e):await t.put(Ne,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=`${et}.${o.toString(36)}.${s}`,i=(await ln(t,a)).slice(0,tt);return`${a}.${i}`}async function Ie(t,e,n=Date.now()){if(!t||!e)return{ok:!1,reason:"format"};let r=e.split(".");if(r.length!==4||r[0]!==et)return{ok:!1,reason:"format"};let o=r[1],s=r[2],a=r[3];if(!o||!s||a.length!==tt)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 ln(t,`${et}.${o}.${s}`)).slice(0,tt);return z(a,c)?i>0&&Math.floor(n/1e3)>=i?{ok:!1,reason:"expired",exp:i}:{ok:!0,exp:i}:{ok:!1,reason:"signature"}}var Ne,et,tt,un,cn,nt=O(()=>{"use strict";ye();X();Ne="SUB_TOKEN_SECRET",et="v1",tt=22,un=new TextEncoder;cn=()=>M(32)});function Jr(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 wn(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 Jr(new Uint8Array(s))}function En(t){if(t.startsWith(`${ot}$`)){let[r,o,s,a]=t.split("$");if(r!==ot||!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 Pn(t,e){return t.scheme==="pbkdf2"?await wn(e,t.salt,t.iterations):await Me(`${t.salt}:${e}`)}async function st(t,e){let n=await wn(t,e,hn);return n?`${ot}$${hn}$${e}$${n}`:`${e}:${await Me(`${e}:${t}`)}`}async function $r(t,e){let n=En(t);if(!n)return!1;let r=await Pn(n,e);return r?z(r,n.expected):!1}function bn(t){return`/${t.trim().replace(/^\/+/,"")}`}async function Sn(t,e,n){let r=await t.get(Pe)??"",o=n&&n.trim()?bn(n):"";o?r!==o&&(r=o,await t.put(Pe,r)):r||(r=bn(`${xt}-${Et(6)}`),await t.put(Pe,r));let s=await t.get(ie)??"",a=null,i=e&&e.trim()?e.trim():"";if(i){if(!s||!await $r(s,i)){let p=M(8);s=await st(i,p),await t.put(ie,s)}await t.get(re)&&await t.delete(re)}else if(!s){let c=`cfp-${M(8)}`,p=M(8);s=await st(c,p),await t.put(ie,s),a=c,await t.put(re,c)}return{panelPath:r,passwordHash:s,generatedPassword:a}}async function Cn(t,e){let n=En(t.passwordHash);if(!n)return{ok:!1,legacy:!1};let r=await Pn(n,e);if(!r)return{ok:!1,legacy:!1};let o=z(r,n.expected);return{ok:o,legacy:o&&n.scheme==="sha256"}}async function An(t,e){let n=M(8);await t.put(ie,await st(e,n))}async function xn(t){await t.get(re)&&await t.delete(re)}function Tn(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 Nn(t){let e=M(24);return await t.put(`${Ee}${e}`,JSON.stringify({ua:"",t:Date.now()}),yn),e}async function it(t,e){let n=Tn(e)[Oe];return n?!!await t.get(`${Ee}${n}`):!1}function vn(t,e=yn){return`${Oe}=${t}; Path=/; HttpOnly; Secure; SameSite=Strict; Max-Age=${e}`}function In(){return`${Oe}=; Path=/; HttpOnly; Secure; SameSite=Strict; Max-Age=0`}async function Dn(t,e){let n=Tn(e)[Oe];n&&await t.delete(`${Ee}${n}`)}async function On(t){let e=M(20);return await t.put(`${we}${e}`,"1",qr),e}async function Rn(t,e){if(!e)return!1;let n=await t.get("SCANNER_TOKEN");return n&&z(n,e)?!0:await t.get(`${we}${e}`)?(await t.delete(`${we}${e}`),!0):!1}var Oe,yn,qr,hn,ot,at=O(()=>{"use strict";fe();X();Oe=__sfx("Y2ZwaWxvdF9zZXNz"),yn=3600*24,qr=600,hn=3e4,ot="pbkdf2"});function Ln(t){return St(t)}async function ut(t,e){if(U.config&&Date.now()-U.configAt<eo)return U.config;let n=await vt(t,e);return U.config=n,U.configAt=Date.now(),n}function kn(){U.config=null,U.configAt=0}async function lt(t,e){if(U.auth&&Date.now()-U.authAt<to)return U.auth;let n=await Sn(t,e.PANEL_PASSWORD,e.PANEL_PATH);return U.auth=n,U.authAt=Date.now(),n}function ct(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 be(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 Hn(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 eo,to,U,Re=O(()=>{"use strict";ye();fe();at();eo=15e3,to=6e4,U={config:null,configAt:0,auth:null,authAt:0}});function ft(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 te(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 Le(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 Fn(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 pt(t){let e=[],n=o=>Object.prototype.hasOwnProperty.call(t,o);n("wsPath")&&ft(String(t.wsPath??""),"wsPath",e),n(__sfx("dHJvamFuUGF0aA=="))&&ft(String(t.trojanPath??""),__sfx("dHJvamFuUGF0aA=="),e),n(__sfx("eGh0dHBQYXRo"))&&ft(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=="))&&Le(String(t.proxyIp??""),__sfx("cHJveHlJcA=="),e),n(__sfx("c29ja3M1"))&&Le(String(t.socks5??""),__sfx("c29ja3M1"),e),n("httpProxy")&&Le(String(t.httpProxy??""),"httpProxy",e),n("relayPool")&&Le(String(t.relayPool??""),"relayPool",e),n("officialCount")&&te(Number(t.officialCount),"officialCount",1,200,e),n("domainCount")&&te(Number(t.domainCount),"domainCount",1,200,e),n("maxNodes")&&te(Number(t.maxNodes),"maxNodes",0,500,e),n("dls")&&te(Number(t.dls),"dls",0,1e3,e),n("maxLatency")&&te(Number(t.maxLatency),"maxLatency",0,1e4,e),n("dataBudgetMB")&&te(Number(t.dataBudgetMB),"dataBudgetMB",0,102400,e),n("subTokenTtlDays")&&te(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")&&Fn(String(t.addApi??""),"addApi",e),n("addCsv")&&Fn(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 dt(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=O(()=>{"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 jn(t,e=Date.now()){let n={};for(let o of Un){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 Yn(t){let e=new Set([...Un.map(String),__sfx("c29ja3M1"),"httpProxy"]),n={};for(let[r,o]of Object.entries(t))e.has(r)&&(n[r]=o);return n}function Bn(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 Kn(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:Bn(s),to:Bn(o)})}return n}var Un,oo,Gn=O(()=>{"use strict";Un=["poolOfficial","officialCount","poolDomain","domainCount","poolManual","poolCountries","add","dls","maxLatency","maxNodes",__sfx("cHJveHlJcA=="),"relayPool","useBuiltinRelay","proxyMode","nat64","concurrentDial","dataBudgetMB","resolvePreferred",__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 Vn(){return new Response(JSON.stringify({build:gt,version:mt,ts:Date.now()}),{status:200,headers:{"Content-Type":"application/json","Cache-Control":"no-store","Access-Control-Allow-Origin":"*"}})}var gt,mt,zn,ht=O(()=>{"use strict";gt="435b64e-547f9c43",mt=__sfx("MC4xNS41"),zn=__sfx("L19fY2ZwX3ZlcnNpb24=")});var Zn={};tr(Zn,{API_PREFIX:()=>bt,getScannerToken:()=>lo,handleApi:()=>co});function io(t){return t.headers.get("CF-Connecting-IP")??t.headers.get("x-forwarded-for")?.split(",")[0]?.trim()??"unknown"}function ao(t,e){let n=G.get(t);return n?e>=n.resetAt?(G.delete(t),!1):n.count>=so:!1}function uo(t,e){let n=G.get(t);if(!n||e>=n.resetAt){if(G.size>=Xn){for(let[r,o]of G)e>=o.resetAt&&G.delete(r);G.size>=Xn&&G.clear()}G.set(t,{count:1,resetAt:e+Wn});return}n.count+=1}function C(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 T(t,e){return C({ok:!1,error:t},e)}async function lo(t,e){let n=await t.get(je);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(je,r),r}async function co(t,e,n){if(!e.pathname.startsWith(bt))return null;let{store:r,env:o,config:s,auth:a}=n,i=e.pathname.slice(bt.length)||"/",c=t.method.toUpperCase();if(i==="/session"&&c==="GET"){let l=await it(r,t);return C({ok:!0,authenticated:l,panelPath:a.panelPath})}if(i==="/login"&&c==="POST"){let l="";try{let h=await t.json();l=String(h.password??"")}catch{return T(__sfx("6K+35rGC5L2T6Kej5p6Q5aSx6LSl"),400)}if(!l)return T(__sfx("6K+36L6T5YWl5a+G56CB"),400);let u=io(t),f=Date.now();if(ao(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 Cn(a,l);if(!d.ok)return uo(u,f),T(__sfx("5a+G56CB6ZSZ6K+v"),401);G.delete(u),d.legacy&&await An(r,l).catch(()=>{}),await xn(r).catch(()=>{});let g=await Nn(r);return C({ok:!0},200,{"Set-Cookie":vn(g)})}if(i==="/logout"&&c==="POST")return await Dn(r,t),C({ok:!0},200,{"Set-Cookie":In()});if(i==="/preferred-ips"&&c==="POST"){let l=t.headers.get("Authorization")??"",u=l.startsWith("Bearer ")?l.slice(7).trim():l.trim();if(!await Rn(r,u))return T(__sfx("VG9rZW4g5qCh6aqM5aSx6LSl"),401);let d;try{d=await t.json()}catch{return T(__sfx("6K+35rGC5L2T6Kej5p6Q5aSx6LSl"),400)}let h=(Array.isArray(d.ips)?d.ips.map(P=>String(P)):[]).map(P=>P.trim()).filter(P=>P.length>0),R=d.mode==="append",N=P=>P.split("#")[0].trim().replace(/^\[([^\]]+)\]:(\d+)$/,"$1:$2"),A=await r.get(K),L,k=h.length;if(R){let P=(A??"").split(`
7
7
  `).map(b=>b.trim()).filter(b=>b.length>0),V=new Set(P.map(N)),Y=h.filter(b=>{let E=N(b);return V.has(E)?!1:(V.add(E),!0)});k=Y.length,L=[...P,...Y].join(`
8
8
  `)}else L=h.join(`
9
9
  `);A!==L&&await r.put(K,L);let w={};!R&&(s.add??"").trim()!==""&&(w.add=""),s.poolManual||(w.poolManual=!0);let m=!1;return Object.keys(w).length>0&&(await ue(r,ae(s,w)),n.onConfigChanged(),m=w.add!==void 0),C({ok:!0,mode:R?"append":"replace",count:h.length,added:k,clearedManual:m,enabledManual:w.poolManual===!0})}if(!await it(r,t))return T(__sfx("5pyq55m75b2V5oiW5Lya6K+d5bey6L+H5pyf"),401);if(i==="/status"&&c==="GET"){let l=await le(r),u=me(l),f=be(s.subDomain||o.DATA_HOST||e.hostname);return C({ok:!0,panelPath:a.panelPath,domain:e.hostname,nodeDomain:f,dataHost:o.DATA_HOST??"",colo:t.cf?.colo??"UNK",coloLabel:de(t.cf?.colo??""),localIps:u.length,generatedPassword:a.generatedPassword,version:gt,pkgVersion:mt,readAt:Date.now()})}if(i==="/config"&&c==="GET")return C({ok:!0,config:s});if(i==="/config"&&c==="PUT"){let l;try{l=await t.json()}catch{return T(__sfx("6K+35rGC5L2T6Kej5p6Q5aSx6LSl"),400)}if(!l.config||typeof l.config!="object")return T(__sfx("57y65bCR6YWN572u5a+56LGh"),400);let u=pt(l.config);if(u.length>0)return T(dt(u),400);let f=ae(s,l.config);return await ue(r,f),n.onConfigChanged(),C({ok:!0,config:f})}if(i==="/config/export"&&c==="GET")return C({ok:!0,...jn(s)});if(i==="/config/import"&&c==="POST"){let l;try{l=await t.json()}catch{return T(__sfx("6K+35rGC5L2T6Kej5p6Q5aSx6LSl"),400)}if(!l.config||typeof l.config!="object")return T(__sfx("57y65bCR6YWN572u5a+56LGh"),400);let u=Yn(l.config);if(Object.keys(u).length===0)return T(__sfx("5rKh5pyJ5Y+v5a+85YWl55qE5a2X5q6177yI56Gu6K6k5piv5pys6aG555uu5a+85Ye655qE6YWN572u5paH5Lu277yf77yJ"),400);let f=pt(u);if(f.length>0)return T(dt(f),400);let d=Kn(s,u);if(l.dryRun)return C({ok:!0,dryRun:!0,diff:d,count:d.length});if(d.length===0)return C({ok:!0,applied:0,diff:[],config:s});let g=ae(s,u);return await ue(r,g),n.onConfigChanged(),C({ok:!0,applied:d.length,diff:d,config:g})}if(i==="/ips"&&c==="GET"){let l=await le(r),u=me(l);return C({ok:!0,raw:l,count:u.length,entries:u})}if(i==="/ips"&&c==="DELETE")return await r.delete(K),C({ok:!0});if(i==="/ips"&&c==="PUT"){let l;try{l=await t.json()}catch{return T(__sfx("6K+35rGC5L2T6Kej5p6Q5aSx6LSl"),400)}if(typeof l.raw!="string")return T(__sfx("57y65bCRIHJhdyDlrZfmrrU="),400);let u=l.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()+Qe,u="";for(;;){let T=s.peek(),C=Er(T);if(C>=0){u=new TextDecoder().decode(T.subarray(0,C)),s.skip(C+4);break}if(T.byteLength>8192)throw new Error(__sfx("SFRUUCDku6PnkIblk43lupTlpLTotoXov4cgODE5MiDlrZfoioI="));let d=c-Date.now();if(d<=0)throw new Error(__sfx("SFRUUCDku6PnkIbmj6HmiYvotoXml7bvvIg=")+Qe+__sfx("bXMg5peg5ZON5bqU77yJ"));let w=null,A;try{A=await Promise.race([s.fill(),new Promise(U=>{w=setTimeout(()=>U("timeout"),d)})])}finally{w&&clearTimeout(w)}if(A==="timeout")throw new Error(__sfx("SFRUUCDku6PnkIbmj6HmiYvotoXml7bvvIg=")+Qe+__sfx("bXMg5peg5ZON5bqU77yJ"));if(A===null)throw new Error(__sfx("SFRUUCDku6PnkIblk43lupTkuI3lrozmlbTvvIjov57mjqXooqvmj5DliY3lhbPpl63vvIk="))}let g=u.split(`\r
3
3
  `)[0]??"",y=/^HTTP\/1\.[01]\s+(\d{3})/.exec(g);if(!y)throw new Error(__sfx("SFRUUCDku6PnkIblk43lupTpnZ7ms5U="));if(y[1]!=="200")throw new Error(__sfx("SFRUUCDku6PnkIYgQ09OTkVDVCDlpLHotKXvvJo=")+y[1]+"");return s.release()}finally{try{i.releaseLock()}catch{}}}var xr,Qe,Jt=x(()=>{"use strict";ae();xr=[13,10,13,10];Qe=6e3});function Je(e){if(e instanceof Z||(e instanceof Error?e.message:String(e)).includes($t))return!0;let n=e instanceof Error?e.cause:void 0;return n!==void 0&&n!==e&&Je(n)}function _t(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 Ae(e){let t=_t(e);if(t===null)return null;for(let[n,o,r,s]of Ar){let i=_t(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 qe(e){let t=e[6]??0,n=e[7]??0;return`${t>>>8}.${t&255}.${n>>>8}.${n&255}`}function Sr(e){let t=(e.split("%")[0]??"").toLowerCase();if(!t.includes(":"))return null;let n=ie(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 Ae(qe(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 Ae(qe(n))??null;if(n[0]===100&&n[1]===65435&&n[2]===0&&n[3]===0&&n[4]===0&&n[5]===0){let s=Ae(qe(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 _e(e){let t=e.trim().toLowerCase().replace(/^\[|\]$/g,"");if(t==="")return null;if(t.includes(":"))return Sr(t);if(/^\d{1,3}(?:\.\d{1,3}){3}$/.test(t))return Ae(t);if(t==="localhost"||t.endsWith(".localhost"))return{kind:"loopback",reason:__sfx("546v5Zue5Li75py65ZCN")};for(let n of Pr)if(t.endsWith(n))return{kind:"internal-name",reason:__sfx("5YaF572R5Z+f5ZCN5ZCO57yA")};return null}var $t,en,Z,Ar,Pr,$e=x(()=>{"use strict";G();$t=__sfx("55uu5qCH5Zyw5Z2A6KKr562W55Wl5oum5oiq"),en={kind:"ipv6-direct-unsupported",reason:__sfx("55u06L+e5LiO5Y+N5Luj6YCa6YGT5LiN5pSv5oyBIElQdjYg55uu5qCH77yM5Y+v5pS555So6JC95Zyw5Luj55CG6L2s5Y+R")},Z=class extends Error{kind;constructor(t,n){super(`${$t}\uFF1A${t}\uFF08${n.reason}\uFF09`),this.name="TargetBlockedError",this.kind=n.kind}};Ar=[[__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")]];Pr=[".local",".internal"]});function vr(e){return/^\d{1,3}(\.\d{1,3}){3}$/.test(e)?!0:e.includes(":")&&/^[0-9a-fA-F:.]+$/.test(e)}function et(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 Rr(e,t,n,o=on){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[];let i=await s.json();if(!i||i.Status!==0||!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[]}}async function nn(e,t,n={}){for(let o of Tr){if(n.deadline!==void 0&&Date.now()>=n.deadline)break;let r=n.timeoutMs??on,s=n.deadline!==void 0?n.deadline-Date.now():Number[__sfx("UE9TSVRJVkVfSU5GSU5JVFk=")],i=Math.max(50,Math.min(r,s)),a=await Rr(o,e,t,i);if(a.length>0)return a}return[]}function Dr(e,t){let n=[],o=String(e).replace(/^"|"$/g,"").replace(/\\010/g,",").replace(/\\n/g,",").trim();if(!o||o===rn)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}=et(i,t);if(!O(a)&&!V(a))return[];n.push({hostname:a,port:l})}return n}async function Se(e,t,n={}){let o=e.trim();if(!o)return[];if(vr(o))return[{hostname:o,port:t}];let r=`${o}:${t}`,s=tn.get(r);if(s&&Date.now()-s.at<Cr)return s.ips;let i=[],[a,l]=await Promise.all([n.skipTxt?Promise.resolve([]):nn(o,"TXT",n),nn(o,"A",n)]);if(!n.skipTxt)for(let u of a){let p=Dr(u,t);if(p.length>0){i.push(...p);break}if(String(u).replace(/^"|"$/g,"").replace(/\\010/g,",").trim()===rn)break}if(i.length===0)for(let u of l)O(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))}return f.length>0&&tn.set(r,{at:Date.now(),ips:f}),f}var rn,Tr,on,Cr,tn,Pe=x(()=>{"use strict";G();rn=__sfx("QGVkZ2V0dW5uZWw="),Tr=["https://cloudflare-dns.com/dns-query","https://dns.alidns.com/resolve","https://doh.pub/dns-query"],on=4e3,Cr=300*1e3,tn=new Map});var at={};ye(at,{[__sfx("QlVJTFRJTl9SRUxBWV9ET01BSU5T")]:()=>cn,[__sfx("QlVJTFRJTl9SRUxBWV9SRUdJT04=")]:()=>Ce,[__sfx("Q09MT19UT19DT1VOVFJZ")]:()=>un,[__sfx("UkVHSU9OX0FESkFDRU5DWQ==")]:()=>an,[__sfx("UkVHSU9OX09SREVS")]:()=>nt,[__sfx("UkVMQVlfQkFUQ0hfU0laRQ==")]:()=>J,[__sfx("UkVMQVlfRE9NQUlOX0xJTUlU")]:()=>it,[__sfx("VU5LTk9XTl9SRUdJT04=")]:()=>sn,clearRelayCache:()=>kr,collectRelayEndpoints:()=>le,coloToCountry:()=>Te,rankRegions:()=>st,regionOfEntry:()=>tt,resolveRelayEntry:()=>ot,selectRelayDomains:()=>dn,sortEndpointsByRegion:()=>ln});function tt(e,t=Ce){let o=e.trim().toLowerCase().replace(/:\d{1,5}$/,"");return t[o]??sn}function st(e){let t=(e??"").trim().toUpperCase();if(!t)return[...nt];let n=an[t]??[],o=nt.filter(r=>r!==t&&!n.includes(r));return[t,...n,...o]}function ln(e,t){let n=st(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 Te(e){let t=String(e??"").toUpperCase();return t?un[t]??(/^[A-Z]{2}$/.test(t)?t:"US"):"US"}async function ot(e,t=443,n=fn,o={}){let r=e.trim();if(!r)return[];let s=`${r}:${t}:${n}`,i=rt.get(s);if(i&&Date.now()-i.at<Nr)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(O(a)||V(a))c=[{ip:a,port:Number.isInteger(l)&&l>0?l:t,label:r,regionCode:tt(r)}];else try{c=(await Se(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:tt(r)}))}catch{c=[]}return c.length>0&&rt.set(s,{at:Date.now(),ips:c}),c}function dn(e,t=it,n=cn,o=Ce){let r=Te(e),s=st(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 le(e={}){let t=e.perDomain??fn,n=[],o=new Set,r=d=>{for(let w of d){let A=`${w.ip}:${w.port}`;o.has(A)||(o.add(A),n.push(w))}},s=(e.userEntries??"").trim(),i=s?s.split(/[\n,;]+/).map(d=>d.trim()).filter(Boolean):[],a=e.domainLimit??it,l=e.useBuiltin!==!1?dn(e.colo,a):[],f=d=>e.perDomain!==void 0?t:Ce[d]===Te(e.colo)?Ir:Lr,c=await Promise.all([...i.map(d=>ot(d,443,t,{deadline:e.deadline,timeoutMs:e.timeoutMs})),...l.map(d=>ot(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),y=g.reduce((d,w)=>Math.max(d,w.length),0);for(let d=0;d<y;d++)for(let w of g)d<w.length&&r([w[d]]);let T=n.slice(0,p),C=ln(n.slice(p),Te(e.colo));return[...T,...C]}function kr(){rt.clear()}var sn,an,nt,Ce,cn,un,fn,J,it,Ir,Lr,Nr,rt,ce=x(()=>{"use strict";G();Pe();sn="??";an={[__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"]},nt=["US","SG","JP","KR","DE","SE","NL","FI","GB"];Ce={},cn=[__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")],un={[__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"};fn=4,J=6,it=6,Ir=2,Lr=1,Nr=30*1e3,rt=new Map});function pn(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 _(e){let t=pn(e);if(t===null)return!1;for(let[n,o]of Ur){let r=pn(n);if(r===null)continue;let s=o===0?0:4294967295<<32-o>>>0;if((t&s)===(r&s))return!0}return!1}function mn(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=_(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=>!_(c.ip)),l=i.filter(c=>_(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 hn(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 gn(e,t){let n=e instanceof Error?e.message:String(e);return Je(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 yn(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 Ur,lt=x(()=>{"use strict";$e();Ur=[[__sfx("MTA0LjE2LjAuMA=="),13],[__sfx("MTA0LjI0LjAuMA=="),14],[__sfx("MTA0LjMxLjAuMA=="),15],[__sfx("MTcyLjY0LjAuMA=="),13],[__sfx("MTYyLjE1OC4wLjA="),15],[__sfx("MTg4LjExNC45Ni4w"),20],[__sfx("MTQxLjEwMS42NC4w"),18],[__sfx("MTA4LjE2Mi4xOTIuMA=="),18],[__sfx("MTAzLjIxLjI0NC4w"),22],[__sfx("MTAzLjIyLjIwMC4w"),22],[__sfx("MTAzLjMxLjQuMA=="),22],[__sfx("MTMxLjAuNzIuMA=="),22],[__sfx("MTk3LjIzNC4yNDAuMA=="),22],[__sfx("MTk4LjQxLjEyOC4w"),17],[__sfx("MTkyLjAuMC4w"),24],[__sfx("MTkyLjAuMi4w"),24],[__sfx("MTkyLjg4Ljk5LjA="),24],[__sfx("MTk5LjI3LjEyOC4w"),21],[__sfx("MjIzLjUuNS4w"),24],[__sfx("MS4wLjAuMA=="),24],[__sfx("MS4xLjEuMA=="),24]]});function bn(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}=et(r,0);return!c||!Number.isInteger(u)||u<=0||u>65535?null:(!l&&o==="https"&&!Or(c)&&(l=c),{host:c,port:u,kind:o,...a,...l?{serverName:l}:{}})}function Or(e){return/^\d{1,3}(\.\d{1,3}){3}$/.test(e)}function ue(e,t="direct"){let n=[];for(let o of e.split(/[\n,;]+/)){let r=o.trim();if(!r)continue;let s=bn(r,t);s&&n.push(s)}return n}var ct=x(()=>{"use strict";Pe()});async function Mr(){return ut||(ut=(async()=>(await import("cloudflare:sockets")).connect)()),await ut}function Hr(e,t){if(!O(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 ve(e,t,n,o,r){let i=(await Mr())({hostname:e,port:t},o?{secureTransport:o}:void 0),a=async(f,c)=>{let u,p=new Promise((g,y)=>{u=setTimeout(()=>y(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 Fr(e){let t=e.timeoutMs??pt;try{let n=await ve(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&&O(e.hostname)){let o=Hr(e.hostname,e.nat64);if(o){let r=await ve(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 Kr(e){return e.includes(":")}function Gr(e){return e.source==="proxy"&&e.via!==void 0&&e.via.kind!=="direct"}async function jr(e,t){let n=e.timeoutMs??pt;if(t.kind==="direct"){let s=await ve(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 ve(t.host,t.port,n,o,t.kind==="https"?t.serverName:void 0);try{return t.kind==="http"||t.kind==="https"?{readable:await qt(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 Zt(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 xn(e){return e instanceof Error?e.message:typeof e=="string"?e:String(e)}function zr(e){if(e.length===0)return __sfx("5pyq55+l5Y6f5Zug");let t=e.map(xn),n=t.slice(-Yr),o=t.length-n.length;return`${o>0?`\uFF08\u5171 ${t.length} \u6761\uFF0C\u7701\u7565\u524D ${o} \u6761\uFF09`:""}${n.join("\uFF1B")}`}function Wr(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{a.writable.getWriter().close()}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==")+zr(s)+"")))})})}async function dt(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+=ft){let i=e.slice(s,s+ft);try{return await Wr(i)}catch(a){o=a,n.push(xn(a))}}throw new Error(__sfx("5YWo6YOoIA==")+e.length+__sfx("IOS4quWAmemAieWdh+Wksei0pe+8iOWIhiA=")+n.length+__sfx("IOaJue+8jOavj+aJueacgOWkmiA=")+ft+__sfx("IOS4quW5tuWPke+8ie+8mgo=")+n.join(`
4
4
  `),{cause:o})}async function wn(e,t){let n=[...e];if(!t)return n;try{let o=await le(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 Xr(e,t,n){if(e.length===0)return null;for(let o=0;o<e.length;o+=J){let s=e.slice(o,o+J).map(i=>t({source:"relay",host:i.ip,port:i.port,label:__sfx("5Y+N5LujIA==")+i.label+""}));try{return await dt(s,n)}catch{}}return null}async function fe(e){let t=e.proxies??[],n=e.concurrent??!0;if(!e.skipTargetPolicy&&t.length===0){let h=_e(e.hostname);if(h)throw new Z(e.hostname,h)}let o=e.budgetMs??Br,r=Date.now()+o,s=[...e.optimizedIps??[]],i=!1;if(e.resolvePreferred)try{let h=await Se(e.hostname,e.port,{deadline:r});if(h.length>0){i=!0;for(let S of h)s.push({ip:S.hostname,port:S.port})}}catch{}let a=_(e.hostname),l=i&&s.length>0&&s.every(h=>_(h.ip)),f=[...e.relay??[]],c=l||a;c&&e.relayPool&&(f=await wn(f,{...e.relayPool,deadline:r}));let u=c?f.slice(0,J):[],p=c?f.slice(J):[],g=mn({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 y=h=>async()=>{let S=r-Date.now();if(S<=0)throw new Error(__sfx("5ouo5Y+36aKE566X5bey55So5bC977yI")+o+"ms):"+e.hostname+":"+e.port+"");let L=Math.max(200,Math.min(e.timeoutMs??pt,S)),oe={...e,timeoutMs:L};try{if(!Gr(h)&&Kr(e.hostname))throw new Z(e.hostname,en);if(!e.skipTargetPolicy&&h.source!=="proxy"&&h.source!=="relay"){let M=_e(h.host);if(M)throw new Z(h.host,M)}return h.source==="proxy"&&h.via?await jr(oe,{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 Fr({...oe,hostname:h.host,port:h.port})}catch(M){let me=gn(M,h.label);throw e.onFailure?.(me),M}},T=hn(g),{landing:C,[__sfx("cHJveHlJcA==")]:d,direct:w,fallback:A}=T,U=C.length>0||d.length>0,R=async()=>{if(C.length===0)throw new Error(__sfx("5pyq6YWN572u6JC95Zyw5Luj55CG"));let h;for(let S of C)try{return await y(S)()}catch(L){h=L}throw h??new Error(__sfx("6JC95Zyw5Luj55CG5YWo6YOo5aSx6LSl"))},W=async()=>{if(d.length===0)throw new Error(__sfx("5pyq6YWN572uIFByb3h5SVA="));return await dt(d.map(y),!0)},N=async()=>{let h;if(C.length>0)try{return await R()}catch(S){h=S}if(d.length>0)try{return await W()}catch(S){h=S}throw h??new Error(__sfx("5rKh5pyJ5Y+v55So55qE5Luj55CG"))},q=async()=>await dt(w.map(y),n),X=async()=>{let h=p;return h.length===0&&e.relayPool&&(h=await wn([],{...e.relayPool,deadline:r})),await Xr(h,y,n)},K=async()=>{for(let h of A)try{return await y(h)()}catch{}return null};if(!U)try{return await q()}catch(h){let S=await X();if(S)return S;let L=await K();if(L)return L;throw h}let H=e.proxyMode??"only",re=a||l;if(H==="only")try{return await N()}catch(h){let S=await X();if(S)return S;let L=await K();if(L)return L;throw h}if(H==="global"||H==="smart"&&re)try{return await N()}catch(h){if(H==="global")try{return await q()}catch{}let S=await X();if(S)return S;let L=await K();if(L)return L;throw h}try{return await q()}catch(h){try{return await N()}catch{}let S=await X();if(S)return S;let L=await K();if(L)return L;throw h}}var ut,pt,Br,ft,Yr,mt=x(()=>{"use strict";Qt();Jt();$e();G();Pe();ce();lt();ct();ut=null;pt=8e3,Br=15e3;ft=6,Yr=8});async function En(e,t,n,o=!0,r){let s=e.getReader(),i=t.getWriter();try{for(;!n?.exhausted;){let{done:a,value:l}=await s.read();if(a)break;if(!(!l||l.byteLength===0)){if(r?.(l.byteLength))break;await i.write(l)}}}catch{}finally{if(o)try{await i.close()}catch{}else try{i.releaseLock()}catch{}try{s.releaseLock()}catch{}}}var $,Re=x(()=>{"use strict";$=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 Rn={};ye(Rn,{[__sfx("aGFuZGxlV2ViU29ja2V0")]:()=>Le,recentDiagnostics:()=>Qr,recordDiagnostics:()=>ee,truncateCloseReason:()=>vn});function vn(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 ee(e,t,n){Ie.unshift({at:Date.now(),target:e,failures:t,summary:n}),Ie.length>Cn&&(Ie.length=Cn)}function Qr(){return Ie}function Jr(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 Le(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=Jr(e.headers.get(__sfx("c2VjLXdlYnNvY2tldC1wcm90b2NvbA=="))),f=!1,c=null,u=null,p=new Ee,g=null,y=null,T=!1,C=!1,d=null,w=null,A=m=>{try{a.send(m)}catch{}},U=m=>{let b=new Uint8Array(2+m.byteLength);b[0]=0,b[1]=m.byteLength,b.set(m,2),A(b)},R=(m,b)=>{T=!0;try{a.close(m,vn(b))}catch{}W()},W=()=>{if(!C){if(C=!0,h(),g&&(clearTimeout(g),g=null),N&&(clearTimeout(N),N=null),y){let m=y;y=null;try{m.cancel()}catch{}}if(c){let m=c.close;if(m)try{m()}catch{}else try{c.writable.close()}catch{}}}},N=null,q=new Set,X=0,K=[],H=0,re=m=>{if(!(m.byteLength===0||M>0)){if(H+m.byteLength>Tn){R(1009,__sfx("5pyq56Gu6K6k6YCa6Lev55qE5LiK6KGM5pWw5o2u6L+H5aSa"));return}if(De+m.byteLength>Zr){R(1009,__sfx("5a6e5L6L5YaF5a2Y6aKE566X5bey5ruh77yM6K+36YeN6K+V"));return}K.push(m),H+=m.byteLength,De+=m.byteLength}},h=()=>{De=Math.max(0,De-H),K=[],H=0},S=0,L=()=>{S+=1},oe=async()=>{if(!c)return;let m=++S,b=c.readable.getReader();y=b,N&&clearTimeout(N);let P=setTimeout(()=>{N===P&&(N=null),!(M>0)&&H!==0&&(ee(`${d.hostname}:${d.port}`,[],__sfx("55u06L+eIA==")+Sn+__sfx("bXMg5peg5LiL6KGM5pWw5o2u77yM5pS56LWw5Y+N5Luj5YWl5Y+j")),_n())},Sn);N=P;try{for(;;){let{done:k,value:D}=await b.read();if(k)break;if(D&&D.byteLength>0){let I=M===0;if(M+=D.byteLength,I&&h(),me.add(D.byteLength)){Tt();return}await Xt(a),A(D)}}}catch{}finally{try{b.releaseLock()}catch{}clearTimeout(P),N===P&&(N=null),y===b&&(y=null),m===S&&!T&&R(1e3,"done")}},M=0,me=new $((n.dataBudgetMB||0)*1024*1024),Tt=()=>{let m=__sfx("5Y2V6L+e5o6l5rWB6YeP6LaF6L+HIA==")+n.dataBudgetMB+__sfx("TUIg5LiK6ZmQ");ee(d?`${d.hostname}:${d.port}`:__sfx("5pyq5bu656uL5Ye656uZ"),[],m),R(1009,m)},Ct=async m=>{let b=u;if(b)try{await p.write(()=>u===b?b:null,m)}catch{W()}},Qn=async m=>{if(l.byteLength===0)return;let b=l;l=new Uint8Array(0),re(b),await m.write(b)},vt=m=>{if(t===__sfx("dmxlc3M=")){let P=Bt(m,n.uuid);return P?{command:P.header.command,port:P.header.port,hostname:P.header.hostname,headerLength:P.consumed}:null}let b=Yt(m,n[__sfx("dHJvamFuUGFzc3dvcmQ=")]);return b?{command:b.header.command,port:b.header.port,hostname:b.header.hostname,headerLength:b.consumed}:null},qn=()=>{g&&(clearTimeout(g),g=null)},Jn=async()=>{if(!(T||f)){if(vt(l)){await Fe();return}R(1008,l.byteLength===0?__sfx("5o+h5omL6LaF5pe277ya5pyq5pS25Yiw5Y2P6K6u5aS0"):__sfx("5o+h5omL6LaF5pe277ya5Y2P6K6u5aS05LiN5a6M5pW05oiW6K6k6K+B5aSx6LSl"))}},Fe=async()=>{if(T||f)return;let m=vt(l);if(!m){l.byteLength>0&&!g&&(g=setTimeout(()=>{g=null,Jn().catch(I=>R(1011,String(I)))},qr));return}if(qn(),f)return;f=!0,d=m;let b=t===__sfx("dmxlc3M=")?Ut:jt;if(m.command===b){if(t===__sfx("dmxlc3M=")&&n.udpDns==="doh"&&m.port===53){U(new Uint8Array(0)),w=new xe({endpoint:n.udpDnsEndpoint,send:A});let I=l.subarray(m.headerLength);I.byteLength>0&&w.push(I);return}R(1002,n.udpDns==="doh"?__sfx("VURQIOS7heaUr+aMgSBETlPvvIg1MyDnq6/lj6PvvIk="):__sfx("VURQIOacquWQr+eUqO+8iOmdouadv+WPr+W8gOWQryBETlMgb3ZlciBEb0jvvIk="));return}t===__sfx("dmxlc3M=")&&U(new Uint8Array(0));let P=[],k=null;try{c=await fe({hostname:m.hostname,port:m.port,proxies:o,timeoutMs:An,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:I=>{P.push(I),s?.failures.push(I)}})}catch(I){k=I}if(!c){let I=P.length>0?P.map(he=>yn(he)).join(`
5
- `):__sfx("5Ye656uZ6L+e5o6l5aSx6LSl77ya")+String(k)+"";ee(`${m.hostname}:${m.port}`,P,I),R(1011,I);return}u=c.writable.getWriter();let D=l.byteLength>m.headerLength?l.subarray(m.headerLength):new Uint8Array(0);D.byteLength>0&&(re(D),await Ct(D)),l=new Uint8Array(0),r?.waitUntil(oe())},_n=async()=>{let m=d;if(!m){R(1011,__sfx("5Ye656uZ5peg5pWw5o2u77ya55uu5qCH5pyq6Kej5p6Q"));return}if(X>=Pn){R(1011,__sfx("5Ye656uZ5peg5pWw5o2u77ya55u06L+e5LiO5Y+N5Luj5YWl5Y+j5Z2H5peg5ZON5bqU"));return}X++;let b=[];try{b=await le({userEntries:n.relayPool||void 0,useBuiltin:n.useBuiltinRelay,colo:typeof e.cf?.colo=="string"?e.cf.colo:void 0})}catch{b=[]}let P=b.filter(k=>!q.has(`${k.ip}:${k.port}`));if(P.length===0){R(1011,__sfx("5Ye656uZ5peg5pWw5o2u77ya5peg5Y+N5Luj5YWl5Y+j5Y+v55So"));return}for(let k of P.slice(0,Pn)){if(q.add(`${k.ip}:${k.port}`),L(),c){let D=c;if(D.close)try{D.close()}catch{}}u=null,M=0;try{let D=await fe({hostname:k.ip,port:k.port,timeoutMs:An,resolvePreferred:!1,skipTargetPolicy:!0});if(!D)continue;c=D;let I=D.writable.getWriter();u=I;let he=0;for(let ge of K)he+=ge.byteLength;let Ke=new Uint8Array(he),Dt=0;for(let ge of K)Ke.set(ge,Dt),Dt+=ge.byteLength;await p.run(async()=>{Ke.byteLength>0&&await I.write(Ke),await Qn(I)}),ee(`${m.hostname}:${m.port}`,[],__sfx("5bey5YiH5o2i5Y+N5Luj5YWl5Y+jIA==")+k.ip+":"+k.port+""),r?.waitUntil(oe());return}catch(D){ee(`${m.hostname}:${m.port}`,[],__sfx("5Y+N5Luj5YWl5Y+jIA==")+k.ip+":"+k.port+__sfx("IOWksei0pe+8mg==")+String(D)+"")}}R(1011,__sfx("5Ye656uZ5peg5pWw5o2u77ya5omA5pyJ5Y+N5Luj5YWl5Y+j5Z2H5aSx6LSl"))};a.addEventListener("message",m=>{(async()=>{let b=m.data,P=typeof b=="string"?new TextEncoder().encode(b):new Uint8Array(b);if(P.byteLength!==0){if(me.add(P.byteLength)){Tt();return}if(!f){if(l=Ze(l,P),l.byteLength>Vr){R(1009,__sfx("5o+h5omL5aS06LaF6L+HIDY0S0I="));return}await Fe();return}if(w){w.push(P);return}if(!u){if(l=Ze(l,P),l.byteLength>Tn){R(1009,__sfx("5ouo5Y+35pyf6Ze05pWw5o2u6L+H5aSa"));return}return}re(P),await Ct(P)}})()});let Rt=()=>{W()};a.addEventListener("close",Rt),a.addEventListener("error",Rt),l.byteLength>0&&Fe().catch(m=>R(1011,String(m)));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 An,Sn,Pn,Vr,Tn,Zr,De,Ie,Cn,qr,ht=x(()=>{"use strict";Xe();zt();Wt();ae();Vt();mt();Re();lt();ce();An=5e3,Sn=2500,Pn=2,Vr=64*1024,Tn=8*1024*1024,Zr=32*1024*1024,De=0;Ie=[],Cn=20;qr=2e3});var Dn={};ye(Dn,{[__sfx("aGFuZGxlWGh0dHA=")]:()=>gt,[__sfx("cmVjZW50WGh0dHBEaWFnbm9zdGljcw==")]:()=>eo,[__sfx("cmVjb3JkWGh0dHBEaWFnbm9zdGljcw==")]:()=>ke});function $r(e,t){return new Promise(n=>{let o=setTimeout(()=>n(null),t);e.then(r=>{clearTimeout(o),n(r)},()=>{clearTimeout(o),n(null)})})}function ke(e,t,n){Ne.unshift({at:Date.now(),target:e,...t,summary:n}),Ne.length>20&&(Ne.length=20)}function eo(){return Ne}async function gt(e,t,n){let o=e.body;if(!o)return new Response(__sfx("57y65bCR6K+35rGC5L2T"),{status:400});let r=new Y(o),s=await $r(Mt(r,t.uuid),_r);if(!s)return await r.cancel("header timeout"),new Response(__sfx("VkxFU1Mg5aS06Kej5p6Q5aSx6LSl"),{status:400});if(s.header.command!==kt)return await s.payload.cancel("unsupported UDP"),new Response(__sfx("WEhUVFAg5pqC5LiN5pSv5oyBIFVEUA=="),{status:400});let i;try{i=await fe({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},onFailure:d=>{ke(`${s.header.hostname}:${s.header.port}`,d,__sfx("WEhUVFAg5Ye656uZ5aSx6LSl77yI")+d.candidate+"):"+d.message+"")}})}catch(d){ke(`${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 $((t.dataBudgetMB||0)*1024*1024),g=null,y=()=>{if(u)return;u=!0;let d=__sfx("5Y2V6L+e5o6l5rWB6YeP6LaF6L+HIA==")+t.dataBudgetMB+__sfx("TUIg5LiK6ZmQ");if(ke(`${s.header.hostname}:${s.header.port}`,{kind:"budget",message:d,candidate:"traffic"},d),i.close)try{i.close()}catch{}try{g?.close()}catch{}},T=d=>p.add(d)?(y(),!0):!1;En(s.payload,i.writable,void 0,!1,T).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:A}=await c.read();if(u)return;if(w){if(i.close)try{i.close()}catch{}d.close();return}if(A&&A.byteLength>0){if(p.add(A.byteLength)){y();return}d.enqueue(A)}}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 _r,Ne,yt=x(()=>{"use strict";ae();Xe();Re();mt();_r=2e3;Ne=[]});function Oe(){return new Response(JSON.stringify({build:bt,version:to,ts:Date.now()}),{status:200,headers:{"Content-Type":"application/json","Cache-Control":"no-store","Access-Control-Allow-Origin":"*"}})}var bt,to,Ue,wt=x(()=>{"use strict";bt="b0b7d2f-547f9c43",to=__sfx("MC4xNS40"),Ue=__sfx("L19fY2ZwX3ZlcnNpb24=")});function In(e){return e[__sfx("S1Y=")]?new te(e[__sfx("S1Y=")]):new xt}var te,xt,Me=x(()=>{"use strict";te=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}},xt=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 Q(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 B(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 Nn(e){return e.trim().toLowerCase()==="signed"?"signed":"legacy"}function kn(e){return e.trim().toLowerCase()==="doh"?"doh":"off"}function v(e,t){return e==null?t:String(e)}function ro(e){return{uuid:v(e[__sfx("VVVJRA==")],""),[__sfx("dHJvamFuUGFzc3dvcmQ=")]:v(e[__sfx("VFJPSkFOX1BBU1NXT1JE")],""),wsPath:v(e[__sfx("V1NfUEFUSA==")]||e[__sfx("UEFUSA==")],E.wsPath),[__sfx("dHJvamFuUGF0aA==")]:E[__sfx("dHJvamFuUGF0aA==")],[__sfx("eGh0dHBQYXRo")]:E[__sfx("eGh0dHBQYXRo")],add:v(e[__sfx("QURE")],""),addApi:v(e[__sfx("QUREQVBJ")],""),addCsv:v(e[__sfx("QUREX0NTVg==")],""),poolOfficial:B(e[__sfx("T0ZGSUNJQUxfSVA=")],E.poolOfficial),officialCount:Q(e[__sfx("T0ZGSUNJQUxfSVBfQ09VTlQ=")],E.officialCount),poolDomain:B(e[__sfx("UFJFRkVSUkVEX0RPTUFJTg==")],E.poolDomain),domainCount:Q(e[__sfx("UFJFRkVSUkVEX0RPTUFJTl9DT1VOVA==")],E.domainCount),poolManual:B(e[__sfx("TUFOVUFMX0lQ")],E.poolManual),poolCountries:v(e[__sfx("UE9PTF9DT1VOVFJJRVM=")],E.poolCountries),dls:Q(e[__sfx("RExT")],0),maxLatency:Q(e[__sfx("TUFYX0xBVEVOQ1k=")],0),maxNodes:0,[__sfx("cHJveHlJcA==")]:v(e[__sfx("UFJPWFlJUA==")],""),[__sfx("c29ja3M1")]:v(e[__sfx("U09DS1M1")],""),httpProxy:v(e[__sfx("SFRUUF9QUk9YWQ==")],""),proxyMode:no(v(e[__sfx("UFJPWFlfTU9ERQ==")],"")),nat64:v(e[__sfx("TkFUNjQ=")],""),concurrentDial:B(e[__sfx("VENQX0NPTkNVUlJFTlRfRElBTA==")],!0),dataBudgetMB:Q(e[__sfx("REFUQV9CVURHRVRfTUI=")],E.dataBudgetMB),resolvePreferred:B(e[__sfx("UkVTT0xWRV9QUkVGRVJSRUQ=")],E.resolvePreferred),relayPool:v(e[__sfx("UkVMQVlfUE9PTA==")],""),useBuiltinRelay:B(e[__sfx("VVNFX0JVSUxUSU5fUkVMQVk=")],E.useBuiltinRelay),[__sfx("ZW5hYmxlVHJvamFu")]:B(e[__sfx("RU5BQkxFX1RST0pBTg==")]??e[__sfx("VFJPSkFO")],E[__sfx("ZW5hYmxlVHJvamFu")]),[__sfx("ZW5hYmxlWGh0dHA=")]:B(e[__sfx("RU5BQkxFX1hIVFRQ")]??e[__sfx("WEhUVFA=")],E[__sfx("ZW5hYmxlWGh0dHA=")]),subDomain:"",subProtocol:"both",subTransport:"both",subVariants:v(e[__sfx("U1VCX1ZBUklBTlRT")],E.subVariants),subName:v(e[__sfx("U1VCX05BTUU=")],E.subName).trim()||E.subName,subPorts:v(e[__sfx("U1VCX1BPUlRT")],E.subPorts),clientFingerprint:E.clientFingerprint,ech:B(e[__sfx("RUNI")],E.ech),echHost:v(e[__sfx("RUNIX0hPU1Q=")],E.echHost),echDns:v(e[__sfx("RUNIX0ROUw==")],E.echDns),tlsFragment:!1,tlsFragmentSize:E.tlsFragmentSize,tlsFragmentDelay:E.tlsFragmentDelay,subToken:Nn(v(e[__sfx("U1VCX1RPS0VOX01PREU=")],"")),subTokenTtlDays:Q(e[__sfx("U1VCX1RPS0VOX1RUTF9EQVlT")],E.subTokenTtlDays),unlockProbe:B(e[__sfx("VU5MT0NLX1BST0JF")],E.unlockProbe),udpDns:kn(v(e[__sfx("VURQX0ROUw==")],"")),udpDnsEndpoint:v(e[__sfx("VURQX0ROU19FTkRQT0lOVA==")],E.udpDnsEndpoint)}}function oo(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]=Q(r,0);else if(o==="concurrentDial"||o==="resolvePreferred"||o==="useBuiltinRelay"||o===__sfx("ZW5hYmxlVHJvamFu")||o===__sfx("ZW5hYmxlWGh0dHA=")||o==="tlsFragment"||o==="ech"||o==="poolOfficial"||o==="poolDomain"||o==="poolManual"||o==="unlockProbe")n[o]=B(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]=Nn(String(r)):o==="udpDns"?n[o]=kn(String(r)):n[o]=String(r);return n}async function Un(e,t){let n=ro(t),o=await e.get(Ln),r={};if(o)try{r=JSON.parse(o)}catch{r={}}let s=oo(n,r),i=!1,a=e instanceof te;return!s.uuid&&a&&(s.uuid=Ge(),i=!0),!s[__sfx("dHJvamFuUGFzc3dvcmQ=")]&&a&&(s[__sfx("dHJvamFuUGFzc3dvcmQ=")]=Ge().replace(/-/g,"").slice(0,16),i=!0),s.officialCount<1&&(s.officialCount=E.officialCount,i=!0),s.domainCount<1&&(s.domainCount=E.domainCount,i=!0),i&&await so(e,s),s}async function so(e,t){await e.put(Ln,JSON.stringify(t))}var Ln,E,Be=x(()=>{"use strict";j();Me();Ln="CONFIG",E={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,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 On,io,Ps,ao,Ts,Mn=x(()=>{"use strict";On={[__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"]},io=__sfx("SEtH6aaZ5rivLFRQReWPsOWMlyxOUlTkuJzkuqwsS0lY5aSn6ZiqLElDTummluWwlCxTSU7mlrDliqDlnaEsS1VM5ZCJ6ZqG5Z2hLEJLS+abvOiwtyxTR07og6Hlv5fmmI7luIIsTU5M6ams5bC85ouJLFNZROaCieWwvCxNRUzloqjlsJTmnKwsTEFY5rSb5p2J55+2LFNKQ+Wco+S9leWhnixTRUHopb/pm4Xlm74sT1JE6Iqd5Yqg5ZOlLElBROWNjuebm+mhvyxFV1Lnur3nk6blhYssWVla5aSa5Lym5aSaLFlWUua4qeWTpeWNjixMSFLkvKbmlaYsRlJB5rOV5YWw5YWL56aPLENER+W3tOm7jixBTVPpmL/lp4bmlq/nibnkuLksTUFE6ams5b636YeMLEFSTuaWr+W+t+WTpeWwlOaRqSxJU1TkvIrmlq/lnabluIPlsJQsRFhC6L+q5ouc"),Ps=(()=>{let e={};for(let t of io.split(","))t.length>3&&(e[t.slice(0,3)]=t.slice(3));return e})(),ao=new Map;for(let[e,t]of Object.entries(On))for(let n of t)ao.set(n,e);Ts=Object.keys(On)});var Bn=x(()=>{"use strict"});var Gs,Hn=x(()=>{"use strict";G();j();Mn();Bn();Gs=".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 Ws,Fn=x(()=>{"use strict";Me();j();Ws=new TextEncoder});var li,Kn=x(()=>{"use strict";Be();j();li=3600*24});function Gn(e){return In(e)}async function jn(e,t){if(de.config&&Date.now()-de.configAt<lo)return de.config;let n=await Un(e,t);return de.config=n,de.configAt=Date.now(),n}var lo,de,At=x(()=>{"use strict";Me();Be();Kn();lo=15e3,de={config:null,configAt:0,auth:null,authAt:0}});var zn={};ye(zn,{clearUnlockCache:()=>bo,runUnlockProbe:()=>yo});function ho(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(),fo);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:ho(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 yo(e,t){let n=e||"UNK",o=Date.now(),r=ne.get(n);if(r&&o-r.at<po)return{...r.data,cached:!0};let s=await Promise.all(uo.map(a=>go(a))),i={colo:n,region:t,cached:!1,at:o,targets:s};if(ne.size>=mo){let a="",l=Number[__sfx("UE9TSVRJVkVfSU5GSU5JVFk=")];for(let[f,c]of ne)c.at<l&&(l=c.at,a=f);a&&ne.delete(a)}return ne.set(n,{at:o,data:i}),i}function bo(){ne.clear()}var uo,fo,po,mo,ne,Wn=x(()=>{"use strict";uo=[{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"}],fo=4e3,po=600*1e3,mo=16,ne=new Map});j();var er=8*1024*1024,tr=2*1024*1024,Lt=600*1e3,nr=6*1024*1024*1024,je=Date.now(),Ye=0;function Nt(e){e-je>=Lt&&(je=e,Ye=0)}function rr(e,t=Date.now()){Nt(t),Ye+=e}function It(e){return Nt(e),nr-Ye}var or=(()=>{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})(),sr=5e3;function ir(e,t=sr){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 ze(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=ir((g,y)=>u.close(g,y));return u.addEventListener("message",g=>{let y=typeof g.data=="string"?g.data:"";if(y==="PING"||y==="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,er):tr,s=Date.now();if(It(s)<=0){let f=Math.max(1e3,je+Lt-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=or,a=0,l=new ReadableStream({pull(f){let c=It(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,rr(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":we(4)}})}ht();yt();ct();wt();j();Be();Re();Hn();Fn();j();function Et(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"}})}At();At();async function Yn(e){let t=Gn(e);return await jn(t,e)}function St(e){let t=[];return t.push(...ue(e[__sfx("cHJveHlJcA==")],"direct")),t.push(...ue(e[__sfx("c29ja3M1")],__sfx("c29ja3M1"))),t.push(...ue(e.httpProxy,"http")),t}var Pt=6e4,wo=10,pe=0,He=0;function Xn(e){return e>=He?(pe=0,He=e+Pt,!1):pe>=wo}function Vn(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 se(o,n)?(pe=0,!0):(r>=He&&(He=r+Pt,pe=0),pe+=1,!1)}async function Zn(e,t,n){let o=new URL(e.url);if(o.pathname===__sfx("L19fZWRnZV9wcm9iZQ=="))return ze(e);if(o.pathname===Ue||o.pathname===__sfx("L19fdmVyc2lvbg=="))return Oe();if(o.pathname==="/region"&&e.method==="GET"){let{coloToCountry:i,rankRegions:a}=await Promise.resolve().then(()=>(ce(),at)),l=e.cf?.colo??"",f=l?i(l):"";return new Response(JSON.stringify({ok:!0,colo:l,region:f,relayPreference:f?a(f):[],timestamp:new Date().toISOString()},null,2),{status:200,headers:{"Content-Type":"application/json; charset=utf-8"}})}let r=await Yn(t);if(o.pathname===__sfx("L19fZGlhZw==")){if(Xn(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(Pt/1e3))}});if(!Vn(e,o,r.uuid))return null;let{recentDiagnostics:i}=await Promise.resolve().then(()=>(ht(),Rn)),{[__sfx("cmVjZW50WGh0dHBEaWFnbm9zdGljcw==")]:a}=await Promise.resolve().then(()=>(yt(),Dn));return new Response(JSON.stringify({ok:!0,impl:"self",build:bt,recent:i(),[__sfx("eGh0dHA=")]:a()},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(Xn(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(!Vn(e,o,r.uuid))return null;let{coloToCountry:i}=await Promise.resolve().then(()=>(ce(),at)),{runUnlockProbe:a}=await Promise.resolve().then(()=>(Wn(),zn)),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 Le(e,__sfx("dmxlc3M="),r,St(r),n):r[__sfx("ZW5hYmxlVHJvamFu")]&&o.pathname===r[__sfx("dHJvamFuUGF0aA==")]?s!==__sfx("d2Vic29ja2V0")?null:await Le(e,__sfx("dHJvamFu"),r,St(r),n):r[__sfx("ZW5hYmxlWGh0dHA=")]&&o.pathname===r[__sfx("eGh0dHBQYXRo")]?e.method!=="POST"?null:await gt(e,r,St(r)):null}wt();var ea={async fetch(e,t,n){try{return new URL(e.url).pathname===Ue?Oe():await Zn(e,t,n)??Et(200)}catch{return Et(500)}}};export{ea as default};
5
+ `):__sfx("5Ye656uZ6L+e5o6l5aSx6LSl77ya")+String(k)+"";ee(`${m.hostname}:${m.port}`,P,I),R(1011,I);return}u=c.writable.getWriter();let D=l.byteLength>m.headerLength?l.subarray(m.headerLength):new Uint8Array(0);D.byteLength>0&&(re(D),await Ct(D)),l=new Uint8Array(0),r?.waitUntil(oe())},_n=async()=>{let m=d;if(!m){R(1011,__sfx("5Ye656uZ5peg5pWw5o2u77ya55uu5qCH5pyq6Kej5p6Q"));return}if(X>=Pn){R(1011,__sfx("5Ye656uZ5peg5pWw5o2u77ya55u06L+e5LiO5Y+N5Luj5YWl5Y+j5Z2H5peg5ZON5bqU"));return}X++;let b=[];try{b=await le({userEntries:n.relayPool||void 0,useBuiltin:n.useBuiltinRelay,colo:typeof e.cf?.colo=="string"?e.cf.colo:void 0})}catch{b=[]}let P=b.filter(k=>!q.has(`${k.ip}:${k.port}`));if(P.length===0){R(1011,__sfx("5Ye656uZ5peg5pWw5o2u77ya5peg5Y+N5Luj5YWl5Y+j5Y+v55So"));return}for(let k of P.slice(0,Pn)){if(q.add(`${k.ip}:${k.port}`),L(),c){let D=c;if(D.close)try{D.close()}catch{}}u=null,M=0;try{let D=await fe({hostname:k.ip,port:k.port,timeoutMs:An,resolvePreferred:!1,skipTargetPolicy:!0});if(!D)continue;c=D;let I=D.writable.getWriter();u=I;let he=0;for(let ge of K)he+=ge.byteLength;let Ke=new Uint8Array(he),Dt=0;for(let ge of K)Ke.set(ge,Dt),Dt+=ge.byteLength;await p.run(async()=>{Ke.byteLength>0&&await I.write(Ke),await Qn(I)}),ee(`${m.hostname}:${m.port}`,[],__sfx("5bey5YiH5o2i5Y+N5Luj5YWl5Y+jIA==")+k.ip+":"+k.port+""),r?.waitUntil(oe());return}catch(D){ee(`${m.hostname}:${m.port}`,[],__sfx("5Y+N5Luj5YWl5Y+jIA==")+k.ip+":"+k.port+__sfx("IOWksei0pe+8mg==")+String(D)+"")}}R(1011,__sfx("5Ye656uZ5peg5pWw5o2u77ya5omA5pyJ5Y+N5Luj5YWl5Y+j5Z2H5aSx6LSl"))};a.addEventListener("message",m=>{(async()=>{let b=m.data,P=typeof b=="string"?new TextEncoder().encode(b):new Uint8Array(b);if(P.byteLength!==0){if(me.add(P.byteLength)){Tt();return}if(!f){if(l=Ze(l,P),l.byteLength>Vr){R(1009,__sfx("5o+h5omL5aS06LaF6L+HIDY0S0I="));return}await Fe();return}if(w){w.push(P);return}if(!u){if(l=Ze(l,P),l.byteLength>Tn){R(1009,__sfx("5ouo5Y+35pyf6Ze05pWw5o2u6L+H5aSa"));return}return}re(P),await Ct(P)}})()});let Rt=()=>{W()};a.addEventListener("close",Rt),a.addEventListener("error",Rt),l.byteLength>0&&Fe().catch(m=>R(1011,String(m)));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 An,Sn,Pn,Vr,Tn,Zr,De,Ie,Cn,qr,ht=x(()=>{"use strict";Xe();zt();Wt();ae();Vt();mt();Re();lt();ce();An=5e3,Sn=2500,Pn=2,Vr=64*1024,Tn=8*1024*1024,Zr=32*1024*1024,De=0;Ie=[],Cn=20;qr=2e3});var Dn={};ye(Dn,{[__sfx("aGFuZGxlWGh0dHA=")]:()=>gt,[__sfx("cmVjZW50WGh0dHBEaWFnbm9zdGljcw==")]:()=>eo,[__sfx("cmVjb3JkWGh0dHBEaWFnbm9zdGljcw==")]:()=>ke});function $r(e,t){return new Promise(n=>{let o=setTimeout(()=>n(null),t);e.then(r=>{clearTimeout(o),n(r)},()=>{clearTimeout(o),n(null)})})}function ke(e,t,n){Ne.unshift({at:Date.now(),target:e,...t,summary:n}),Ne.length>20&&(Ne.length=20)}function eo(){return Ne}async function gt(e,t,n){let o=e.body;if(!o)return new Response(__sfx("57y65bCR6K+35rGC5L2T"),{status:400});let r=new Y(o),s=await $r(Mt(r,t.uuid),_r);if(!s)return await r.cancel("header timeout"),new Response(__sfx("VkxFU1Mg5aS06Kej5p6Q5aSx6LSl"),{status:400});if(s.header.command!==kt)return await s.payload.cancel("unsupported UDP"),new Response(__sfx("WEhUVFAg5pqC5LiN5pSv5oyBIFVEUA=="),{status:400});let i;try{i=await fe({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},onFailure:d=>{ke(`${s.header.hostname}:${s.header.port}`,d,__sfx("WEhUVFAg5Ye656uZ5aSx6LSl77yI")+d.candidate+"):"+d.message+"")}})}catch(d){ke(`${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 $((t.dataBudgetMB||0)*1024*1024),g=null,y=()=>{if(u)return;u=!0;let d=__sfx("5Y2V6L+e5o6l5rWB6YeP6LaF6L+HIA==")+t.dataBudgetMB+__sfx("TUIg5LiK6ZmQ");if(ke(`${s.header.hostname}:${s.header.port}`,{kind:"budget",message:d,candidate:"traffic"},d),i.close)try{i.close()}catch{}try{g?.close()}catch{}},T=d=>p.add(d)?(y(),!0):!1;En(s.payload,i.writable,void 0,!1,T).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:A}=await c.read();if(u)return;if(w){if(i.close)try{i.close()}catch{}d.close();return}if(A&&A.byteLength>0){if(p.add(A.byteLength)){y();return}d.enqueue(A)}}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 _r,Ne,yt=x(()=>{"use strict";ae();Xe();Re();mt();_r=2e3;Ne=[]});function Oe(){return new Response(JSON.stringify({build:bt,version:to,ts:Date.now()}),{status:200,headers:{"Content-Type":"application/json","Cache-Control":"no-store","Access-Control-Allow-Origin":"*"}})}var bt,to,Ue,wt=x(()=>{"use strict";bt="435b64e-547f9c43",to=__sfx("MC4xNS41"),Ue=__sfx("L19fY2ZwX3ZlcnNpb24=")});function In(e){return e[__sfx("S1Y=")]?new te(e[__sfx("S1Y=")]):new xt}var te,xt,Me=x(()=>{"use strict";te=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}},xt=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 Q(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 B(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 Nn(e){return e.trim().toLowerCase()==="signed"?"signed":"legacy"}function kn(e){return e.trim().toLowerCase()==="doh"?"doh":"off"}function v(e,t){return e==null?t:String(e)}function ro(e){return{uuid:v(e[__sfx("VVVJRA==")],""),[__sfx("dHJvamFuUGFzc3dvcmQ=")]:v(e[__sfx("VFJPSkFOX1BBU1NXT1JE")],""),wsPath:v(e[__sfx("V1NfUEFUSA==")]||e[__sfx("UEFUSA==")],E.wsPath),[__sfx("dHJvamFuUGF0aA==")]:E[__sfx("dHJvamFuUGF0aA==")],[__sfx("eGh0dHBQYXRo")]:E[__sfx("eGh0dHBQYXRo")],add:v(e[__sfx("QURE")],""),addApi:v(e[__sfx("QUREQVBJ")],""),addCsv:v(e[__sfx("QUREX0NTVg==")],""),poolOfficial:B(e[__sfx("T0ZGSUNJQUxfSVA=")],E.poolOfficial),officialCount:Q(e[__sfx("T0ZGSUNJQUxfSVBfQ09VTlQ=")],E.officialCount),poolDomain:B(e[__sfx("UFJFRkVSUkVEX0RPTUFJTg==")],E.poolDomain),domainCount:Q(e[__sfx("UFJFRkVSUkVEX0RPTUFJTl9DT1VOVA==")],E.domainCount),poolManual:B(e[__sfx("TUFOVUFMX0lQ")],E.poolManual),poolCountries:v(e[__sfx("UE9PTF9DT1VOVFJJRVM=")],E.poolCountries),dls:Q(e[__sfx("RExT")],0),maxLatency:Q(e[__sfx("TUFYX0xBVEVOQ1k=")],0),maxNodes:0,[__sfx("cHJveHlJcA==")]:v(e[__sfx("UFJPWFlJUA==")],""),[__sfx("c29ja3M1")]:v(e[__sfx("U09DS1M1")],""),httpProxy:v(e[__sfx("SFRUUF9QUk9YWQ==")],""),proxyMode:no(v(e[__sfx("UFJPWFlfTU9ERQ==")],"")),nat64:v(e[__sfx("TkFUNjQ=")],""),concurrentDial:B(e[__sfx("VENQX0NPTkNVUlJFTlRfRElBTA==")],!0),dataBudgetMB:Q(e[__sfx("REFUQV9CVURHRVRfTUI=")],E.dataBudgetMB),resolvePreferred:B(e[__sfx("UkVTT0xWRV9QUkVGRVJSRUQ=")],E.resolvePreferred),relayPool:v(e[__sfx("UkVMQVlfUE9PTA==")],""),useBuiltinRelay:B(e[__sfx("VVNFX0JVSUxUSU5fUkVMQVk=")],E.useBuiltinRelay),[__sfx("ZW5hYmxlVHJvamFu")]:B(e[__sfx("RU5BQkxFX1RST0pBTg==")]??e[__sfx("VFJPSkFO")],E[__sfx("ZW5hYmxlVHJvamFu")]),[__sfx("ZW5hYmxlWGh0dHA=")]:B(e[__sfx("RU5BQkxFX1hIVFRQ")]??e[__sfx("WEhUVFA=")],E[__sfx("ZW5hYmxlWGh0dHA=")]),subDomain:"",subProtocol:"both",subTransport:"both",subVariants:v(e[__sfx("U1VCX1ZBUklBTlRT")],E.subVariants),subName:v(e[__sfx("U1VCX05BTUU=")],E.subName).trim()||E.subName,subPorts:v(e[__sfx("U1VCX1BPUlRT")],E.subPorts),clientFingerprint:E.clientFingerprint,ech:B(e[__sfx("RUNI")],E.ech),echHost:v(e[__sfx("RUNIX0hPU1Q=")],E.echHost),echDns:v(e[__sfx("RUNIX0ROUw==")],E.echDns),tlsFragment:!1,tlsFragmentSize:E.tlsFragmentSize,tlsFragmentDelay:E.tlsFragmentDelay,subToken:Nn(v(e[__sfx("U1VCX1RPS0VOX01PREU=")],"")),subTokenTtlDays:Q(e[__sfx("U1VCX1RPS0VOX1RUTF9EQVlT")],E.subTokenTtlDays),unlockProbe:B(e[__sfx("VU5MT0NLX1BST0JF")],E.unlockProbe),udpDns:kn(v(e[__sfx("VURQX0ROUw==")],"")),udpDnsEndpoint:v(e[__sfx("VURQX0ROU19FTkRQT0lOVA==")],E.udpDnsEndpoint)}}function oo(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]=Q(r,0);else if(o==="concurrentDial"||o==="resolvePreferred"||o==="useBuiltinRelay"||o===__sfx("ZW5hYmxlVHJvamFu")||o===__sfx("ZW5hYmxlWGh0dHA=")||o==="tlsFragment"||o==="ech"||o==="poolOfficial"||o==="poolDomain"||o==="poolManual"||o==="unlockProbe")n[o]=B(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]=Nn(String(r)):o==="udpDns"?n[o]=kn(String(r)):n[o]=String(r);return n}async function Un(e,t){let n=ro(t),o=await e.get(Ln),r={};if(o)try{r=JSON.parse(o)}catch{r={}}let s=oo(n,r),i=!1,a=e instanceof te;return!s.uuid&&a&&(s.uuid=Ge(),i=!0),!s[__sfx("dHJvamFuUGFzc3dvcmQ=")]&&a&&(s[__sfx("dHJvamFuUGFzc3dvcmQ=")]=Ge().replace(/-/g,"").slice(0,16),i=!0),s.officialCount<1&&(s.officialCount=E.officialCount,i=!0),s.domainCount<1&&(s.domainCount=E.domainCount,i=!0),i&&await so(e,s),s}async function so(e,t){await e.put(Ln,JSON.stringify(t))}var Ln,E,Be=x(()=>{"use strict";j();Me();Ln="CONFIG",E={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,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 On,io,Ps,ao,Ts,Mn=x(()=>{"use strict";On={[__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"]},io=__sfx("SEtH6aaZ5rivLFRQReWPsOWMlyxOUlTkuJzkuqwsS0lY5aSn6ZiqLElDTummluWwlCxTSU7mlrDliqDlnaEsS1VM5ZCJ6ZqG5Z2hLEJLS+abvOiwtyxTR07og6Hlv5fmmI7luIIsTU5M6ams5bC85ouJLFNZROaCieWwvCxNRUzloqjlsJTmnKwsTEFY5rSb5p2J55+2LFNKQ+Wco+S9leWhnixTRUHopb/pm4Xlm74sT1JE6Iqd5Yqg5ZOlLElBROWNjuebm+mhvyxFV1Lnur3nk6blhYssWVla5aSa5Lym5aSaLFlWUua4qeWTpeWNjixMSFLkvKbmlaYsRlJB5rOV5YWw5YWL56aPLENER+W3tOm7jixBTVPpmL/lp4bmlq/nibnkuLksTUFE6ams5b636YeMLEFSTuaWr+W+t+WTpeWwlOaRqSxJU1TkvIrmlq/lnabluIPlsJQsRFhC6L+q5ouc"),Ps=(()=>{let e={};for(let t of io.split(","))t.length>3&&(e[t.slice(0,3)]=t.slice(3));return e})(),ao=new Map;for(let[e,t]of Object.entries(On))for(let n of t)ao.set(n,e);Ts=Object.keys(On)});var Bn=x(()=>{"use strict"});var Gs,Hn=x(()=>{"use strict";G();j();Mn();Bn();Gs=".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 Ws,Fn=x(()=>{"use strict";Me();j();Ws=new TextEncoder});var li,Kn=x(()=>{"use strict";Be();j();li=3600*24});function Gn(e){return In(e)}async function jn(e,t){if(de.config&&Date.now()-de.configAt<lo)return de.config;let n=await Un(e,t);return de.config=n,de.configAt=Date.now(),n}var lo,de,At=x(()=>{"use strict";Me();Be();Kn();lo=15e3,de={config:null,configAt:0,auth:null,authAt:0}});var zn={};ye(zn,{clearUnlockCache:()=>bo,runUnlockProbe:()=>yo});function ho(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(),fo);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:ho(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 yo(e,t){let n=e||"UNK",o=Date.now(),r=ne.get(n);if(r&&o-r.at<po)return{...r.data,cached:!0};let s=await Promise.all(uo.map(a=>go(a))),i={colo:n,region:t,cached:!1,at:o,targets:s};if(ne.size>=mo){let a="",l=Number[__sfx("UE9TSVRJVkVfSU5GSU5JVFk=")];for(let[f,c]of ne)c.at<l&&(l=c.at,a=f);a&&ne.delete(a)}return ne.set(n,{at:o,data:i}),i}function bo(){ne.clear()}var uo,fo,po,mo,ne,Wn=x(()=>{"use strict";uo=[{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"}],fo=4e3,po=600*1e3,mo=16,ne=new Map});j();var er=8*1024*1024,tr=2*1024*1024,Lt=600*1e3,nr=6*1024*1024*1024,je=Date.now(),Ye=0;function Nt(e){e-je>=Lt&&(je=e,Ye=0)}function rr(e,t=Date.now()){Nt(t),Ye+=e}function It(e){return Nt(e),nr-Ye}var or=(()=>{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})(),sr=5e3;function ir(e,t=sr){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 ze(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=ir((g,y)=>u.close(g,y));return u.addEventListener("message",g=>{let y=typeof g.data=="string"?g.data:"";if(y==="PING"||y==="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,er):tr,s=Date.now();if(It(s)<=0){let f=Math.max(1e3,je+Lt-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=or,a=0,l=new ReadableStream({pull(f){let c=It(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,rr(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":we(4)}})}ht();yt();ct();wt();j();Be();Re();Hn();Fn();j();function Et(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"}})}At();At();async function Yn(e){let t=Gn(e);return await jn(t,e)}function St(e){let t=[];return t.push(...ue(e[__sfx("cHJveHlJcA==")],"direct")),t.push(...ue(e[__sfx("c29ja3M1")],__sfx("c29ja3M1"))),t.push(...ue(e.httpProxy,"http")),t}var Pt=6e4,wo=10,pe=0,He=0;function Xn(e){return e>=He?(pe=0,He=e+Pt,!1):pe>=wo}function Vn(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 se(o,n)?(pe=0,!0):(r>=He&&(He=r+Pt,pe=0),pe+=1,!1)}async function Zn(e,t,n){let o=new URL(e.url);if(o.pathname===__sfx("L19fZWRnZV9wcm9iZQ=="))return ze(e);if(o.pathname===Ue||o.pathname===__sfx("L19fdmVyc2lvbg=="))return Oe();if(o.pathname==="/region"&&e.method==="GET"){let{coloToCountry:i,rankRegions:a}=await Promise.resolve().then(()=>(ce(),at)),l=e.cf?.colo??"",f=l?i(l):"";return new Response(JSON.stringify({ok:!0,colo:l,region:f,relayPreference:f?a(f):[],timestamp:new Date().toISOString()},null,2),{status:200,headers:{"Content-Type":"application/json; charset=utf-8"}})}let r=await Yn(t);if(o.pathname===__sfx("L19fZGlhZw==")){if(Xn(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(Pt/1e3))}});if(!Vn(e,o,r.uuid))return null;let{recentDiagnostics:i}=await Promise.resolve().then(()=>(ht(),Rn)),{[__sfx("cmVjZW50WGh0dHBEaWFnbm9zdGljcw==")]:a}=await Promise.resolve().then(()=>(yt(),Dn));return new Response(JSON.stringify({ok:!0,impl:"self",build:bt,recent:i(),[__sfx("eGh0dHA=")]:a()},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(Xn(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(!Vn(e,o,r.uuid))return null;let{coloToCountry:i}=await Promise.resolve().then(()=>(ce(),at)),{runUnlockProbe:a}=await Promise.resolve().then(()=>(Wn(),zn)),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 Le(e,__sfx("dmxlc3M="),r,St(r),n):r[__sfx("ZW5hYmxlVHJvamFu")]&&o.pathname===r[__sfx("dHJvamFuUGF0aA==")]?s!==__sfx("d2Vic29ja2V0")?null:await Le(e,__sfx("dHJvamFu"),r,St(r),n):r[__sfx("ZW5hYmxlWGh0dHA=")]&&o.pathname===r[__sfx("eGh0dHBQYXRo")]?e.method!=="POST"?null:await gt(e,r,St(r)):null}wt();var ea={async fetch(e,t,n){try{return new URL(e.url).pathname===Ue?Oe():await Zn(e,t,n)??Et(200)}catch{return Et(500)}}};export{ea as default};
package/assets/worker.js CHANGED
@@ -3,7 +3,7 @@ var As=Object.defineProperty;var D=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(
3
3
  `))),a){let R=`${N} Trojan`;r.push(R),p.push(R),n.push([` - name: ${J(R)}`," type: trojan",` password: ${J(e.config.trojanPassword)}`,` server: ${g.ip}`,` port: ${x}`," network: ws"," tls: true",` sni: ${e.domain}`,` client-fingerprint: ${e.config.clientFingerprint}`,...u()," ws-opts:",` path: ${J(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(""),l&&(t.push(" nameserver-policy:"),t.push(` ${J(f)}: ${c?J(c):"https://223.5.5.5/dns-query"}`),t.push(""));let d=lr(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(` - ${J(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(` - ${J(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(` - ${J(g)}`);let m=(g,y)=>{t.push(""),t.push(` - name: ${J(g)}`),t.push(" type: select"),t.push(" proxies:");for(let S of y)t.push(` - ${J(S)}`)};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(...ar("CFPilot")),t.push(""),t.join(`
5
5
  `)}function li(e){let t=[],n=[],r=zt(e.config.subVariants,e.config,Er),o=r.some(c=>c==="vless-ws"),s=r.includes("trojan"),i=e.config.ech,a=e.config.echHost.trim()||"cloudflare-ech.com",l=()=>i?{ech:{enabled:!0,query_server_name:a}}:{};for(let c of Yt(e)){let u=[];c.entries.forEach((d,m)=>{let g=`${c.name} ${Ke(d,"vless",m,"")}`;for(let y of Wt(d,e)){let S=e.ports.length>1?`:${y}`:"",p=`${g}${S}`,x=`${p} Trojan`;o&&u.push(p),s&&u.push(x),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},...l()},transport:{type:"ws",path:e.config.wsPath,headers:{Host:e.domain}}}),s&&t.push({type:"trojan",tag:x,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},...l()},transport:{type:"ws",path:e.config.trojanPath,headers:{Host:e.domain}}})}}),u.length>0&&n.push({tag:c.name,members:u})}t.push({type:"direct",tag:"direct"});for(let c of n)t.push({type:"selector",tag:c.tag,outbounds:c.members,default:c.members[0]});return t.push({type:"selector",tag:"CFPilot",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:xr,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:xr,outbound:"direct"}],final:"CFPilot",auto_detect_interface:!0}},null,2)}function ci(e){let t=[],n=zt(e.config.subVariants,e.config);for(let r of Yt(e))r.entries.forEach((o,s)=>{let i=Ke(o,"vless",s,r.name);for(let a of Wt(o,e)){let l=e.ports.length>1?`:${a}`:"",f=`${i}${l}`,c={...o,port:a};for(let u of n)u==="vless-ws"?t.push(wr(c,e,"ws",`${f} WS`)):u==="vless-xhttp"?t.push(wr(c,e,"xhttp",`${f} XHTTP`)):t.push(ii(c,e,`${f} Trojan`))}});return Wn(t.join(`
6
- `))}function Rr(e,t){let n=Xt(t.config.subName);switch(e){case"clash":return{body:ai(t),contentType:"text/yaml; charset=utf-8",fileName:n};case"singbox":return{body:li(t),contentType:"application/json; charset=utf-8",fileName:n};default:return{body:ci(t),contentType:"text/plain; charset=utf-8",fileName:n}}}var pe,Hs,Fs,fr,dr,pr,Ks,js,Gs,$s,ti,ni,de,ri,br,Er,oi,xr,Vt=D(()=>{"use strict";se();oe();Ft();cr();pe=443;Hs=["ip\u5730\u5740","ip \u5730\u5740","ip","\u5730\u5740","\u670D\u52A1\u5668","server","host"],Fs=["\u7AEF\u53E3","port"],fr=["\u4E0B\u8F7D\u901F\u5EA6","\u901F\u5EA6","speed","download"],dr=["\u5E73\u5747\u5EF6\u8FDF","\u5EF6\u8FDF","latency","delay","\u54CD\u5E94\u65F6\u95F4","rtt"],pr=["colo","\u673A\u623F","\u6570\u636E\u4E2D\u5FC3","\u5730\u533A","region"],Ks=["\u56FD\u5BB6","country","\u56FD\u522B"],js=["\u57CE\u5E02","city"],Gs=["tls","\u662F\u5426\u652F\u6301tls","\u652F\u6301tls"];$s={official:"\u5B98\u65B9\u4F18\u9009IP",domain:"\u4F18\u9009\u57DF\u540D",manual:"\u4F18\u9009",api:"\u8FDC\u7A0BAPI",csv:"\u6D4B\u901FCSV"};ti=12e4,ni=32,de=new Map,ri="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36";br=["vless-ws","vless-xhttp","trojan"];Er=["vless-ws","trojan"];oi=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;xr=".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 yi(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 Nr(e,t){let n=await crypto.subtle.importKey("raw",Ir.encode(e),{name:"HMAC",hash:"SHA-256"},!1,["sign"]),r=await crypto.subtle.sign("HMAC",n,Ir.encode(t));return yi(new Uint8Array(r))}async function ct(e){let t=(await e.get(lt))?.trim();if(t)return t;let n=Lr();return e instanceof ie&&await e.put(lt,n),n}async function Or(e){let t=Lr();return e instanceof ie?await e.put(lt,t):await e.put(lt,t),t}async function Ur(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"),i=`${qt}.${o.toString(36)}.${s}`,a=(await Nr(e,i)).slice(0,Jt);return`${i}.${a}`}async function ut(e,t,n=Date.now()){if(!e||!t)return{ok:!1,reason:"format"};let r=t.split(".");if(r.length!==4||r[0]!==qt)return{ok:!1,reason:"format"};let o=r[1],s=r[2],i=r[3];if(!o||!s||i.length!==Jt)return{ok:!1,reason:"format"};let a=Number.parseInt(o,36);if(!Number.isFinite(a)||a<0)return{ok:!1,reason:"format"};let l=(await Nr(e,`${qt}.${o}.${s}`)).slice(0,Jt);return $(i,l)?a>0&&Math.floor(n/1e3)>=a?{ok:!1,reason:"expired",exp:a}:{ok:!0,exp:a}:{ok:!1,reason:"signature"}}var lt,qt,Jt,Ir,Lr,_t=D(()=>{"use strict";_e();oe();lt="SUB_TOKEN_SECRET",qt="v1",Jt=22,Ir=new TextEncoder;Lr=()=>Q(32)});function xi(e){let t="";for(let n of e)t+=(n<16?"0":"")+n.toString(16);return t}function Ei(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 Gr(e,t,n){let r=Ei(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 xi(new Uint8Array(s))}function zr(e){if(e.startsWith(`${en}$`)){let[r,o,s,i]=e.split("$");if(r!==en||!s||!i)return null;let a=Number.parseInt(o??"",10);return!Number.isFinite(a)||a<1||a>1e6?null:{scheme:"pbkdf2",salt:s,iterations:a,expected:i}}let[t,n]=e.split(":");return!t||!n?null:{scheme:"sha256",salt:t,iterations:0,expected:n}}async function Yr(e,t){return e.scheme==="pbkdf2"?await Gr(t,e.salt,e.iterations):await Lt(`${e.salt}:${t}`)}async function tn(e,t){let n=await Gr(e,t,Fr);return n?`${en}$${Fr}$${t}$${n}`:`${t}:${await Lt(`${t}:${e}`)}`}async function Ai(e,t){let n=zr(e);if(!n)return!1;let r=await Yr(n,t);return r?$(r,n.expected):!1}function Kr(e){return`/${e.trim().replace(/^\/+/,"")}`}async function Xr(e,t,n){let r=await e.get(tt)??"",o=n&&n.trim()?Kr(n):"";o?r!==o&&(r=o,await e.put(tt,r)):r||(r=Kr(`${qn}-${Xn(6)}`),await e.put(tt,r));let s=await e.get(ve)??"",i=null,a=t&&t.trim()?t.trim():"";if(a){if(!s||!await Ai(s,a)){let f=Q(8);s=await tn(a,f),await e.put(ve,s)}await e.get(be)&&await e.delete(be)}else if(!s){let l=`cfp-${Q(8)}`,f=Q(8);s=await tn(l,f),await e.put(ve,s),i=l,await e.put(be,l)}return{panelPath:r,passwordHash:s,generatedPassword:i}}async function Wr(e,t){let n=zr(e.passwordHash);if(!n)return{ok:!1,legacy:!1};let r=await Yr(n,t);if(!r)return{ok:!1,legacy:!1};let o=$(r,n.expected);return{ok:o,legacy:o&&n.scheme==="sha256"}}async function Vr(e,t){let n=Q(8);await e.put(ve,await tn(t,n))}async function Zr(e){await e.get(be)&&await e.delete(be)}function Qr(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(),i=r.slice(o+1).trim();s&&(n[s]=decodeURIComponent(i))}return n}async function qr(e){let t=Q(24);return await e.put(`${et}${t}`,JSON.stringify({ua:"",t:Date.now()}),jr),t}async function nn(e,t){let n=Qr(t)[dt];return n?!!await e.get(`${et}${n}`):!1}function Jr(e,t=jr){return`${dt}=${e}; Path=/; HttpOnly; Secure; SameSite=Strict; Max-Age=${t}`}function _r(){return`${dt}=; Path=/; HttpOnly; Secure; SameSite=Strict; Max-Age=0`}async function $r(e,t){let n=Qr(t)[dt];n&&await e.delete(`${et}${n}`)}async function eo(e){let t=Q(20);return await e.put(`${$e}${t}`,"1",wi),t}async function to(e,t){if(!t)return!1;let n=await e.get("SCANNER_TOKEN");return n&&$(n,t)?!0:await e.get(`${$e}${t}`)?(await e.delete(`${$e}${t}`),!0):!1}var dt,jr,wi,Fr,en,rn=D(()=>{"use strict";Le();oe();dt="cfpilot_sess",jr=3600*24,wi=600,Fr=3e4,en="pbkdf2"});function on(e){return Vn(e)}async function pt(e,t){if(_.config&&Date.now()-_.configAt<Si)return _.config;let n=await $n(e,t);return _.config=n,_.configAt=Date.now(),n}function no(){_.config=null,_.configAt=0}async function sn(e,t){if(_.auth&&Date.now()-_.authAt<Pi)return _.auth;let n=await Xr(e,t.PANEL_PASSWORD,t.PANEL_PATH);return _.auth=n,_.authAt=Date.now(),n}function an(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 je(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 ro(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 Si,Pi,_,mt=D(()=>{"use strict";_e();Le();rn();Si=15e3,Pi=6e4,_={config:null,configAt:0,auth:null,authAt:0}});function ln(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 me(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 gt(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(!Ci.test(o)){n.push({field:t,message:`${t} \u91CC\u6709\u65E0\u6CD5\u8BC6\u522B\u7684\u6761\u76EE\uFF1A${o.slice(0,40)}`});return}}function oo(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 cn(e){let t=[],n=o=>Object.prototype.hasOwnProperty.call(e,o);n("wsPath")&&ln(String(e.wsPath??""),"wsPath",t),n("trojanPath")&&ln(String(e.trojanPath??""),"trojanPath",t),n("xhttpPath")&&ln(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&&(!Ti.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")&&gt(String(e.proxyIp??""),"proxyIp",t),n("socks5")&&gt(String(e.socks5??""),"socks5",t),n("httpProxy")&&gt(String(e.httpProxy??""),"httpProxy",t),n("relayPool")&&gt(String(e.relayPool??""),"relayPool",t),n("officialCount")&&me(Number(e.officialCount),"officialCount",1,200,t),n("domainCount")&&me(Number(e.domainCount),"domainCount",1,200,t),n("maxNodes")&&me(Number(e.maxNodes),"maxNodes",0,500,t),n("dls")&&me(Number(e.dls),"dls",0,1e3,t),n("maxLatency")&&me(Number(e.maxLatency),"maxLatency",0,1e4,t),n("dataBudgetMB")&&me(Number(e.dataBudgetMB),"dataBudgetMB",0,102400,t),n("subTokenTtlDays")&&me(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(i=>/^\d{1,5}$/.test(i)&&Number(i)>=1&&Number(i)<=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")&&oo(String(e.addApi??""),"addApi",t),n("addCsv")&&oo(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(i=>/^[A-Za-z]{2,3}$/.test(i))||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 un(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 Ti,Ci,so=D(()=>{"use strict";Ti=/^(?=.{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])?)*$/,Ci=/^(?:(?:socks5|socks|socks5h|http|https):\/\/)?(?:[^\s@/]+@)?(?:\[[0-9a-fA-F:]+\]|[A-Za-z0-9._-]+)(?::\d{1,5})?$/});function lo(e,t=Date.now()){let n={};for(let o of ao){let s=e[o];s!==void 0&&(n[o]=s)}let r=Ri.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 co(e){let t=new Set([...ao.map(String),"socks5","httpProxy"]),n={};for(let[r,o]of Object.entries(e))t.has(r)&&(n[r]=o);return n}function io(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 uo(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:io(s),to:io(o)})}return n}var ao,Ri,fo=D(()=>{"use strict";ao=["poolOfficial","officialCount","poolDomain","domainCount","poolManual","poolCountries","add","dls","maxLatency","maxNodes","proxyIp","relayPool","useBuiltinRelay","proxyMode","nat64","concurrentDial","dataBudgetMB","resolvePreferred","enableTrojan","enableXhttp","subProtocol","subTransport","subVariants","subName","subPorts","clientFingerprint","ech","echHost","echDns","tlsFragment","tlsFragmentSize","tlsFragmentDelay","subToken","subTokenTtlDays","unlockProbe","udpDns","udpDnsEndpoint"],Ri=[{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 mo(){return new Response(JSON.stringify({build:Ge,version:fn,ts:Date.now()}),{status:200,headers:{"Content-Type":"application/json","Cache-Control":"no-store","Access-Control-Allow-Origin":"*"}})}var Ge,fn,po,dn=D(()=>{"use strict";Ge="b0b7d2f-547f9c43",fn="0.15.4",po="/__cfp_version"});var yo={};Re(yo,{API_PREFIX:()=>pn,getScannerToken:()=>Ni,handleApi:()=>Li});function Di(e){return e.headers.get("CF-Connecting-IP")??e.headers.get("x-forwarded-for")?.split(",")[0]?.trim()??"unknown"}function ki(e,t){let n=ne.get(e);return n?t>=n.resetAt?(ne.delete(e),!1):n.count>=vi:!1}function Ii(e,t){let n=ne.get(e);if(!n||t>=n.resetAt){if(ne.size>=go){for(let[r,o]of ne)t>=o.resetAt&&ne.delete(r);ne.size>=go&&ne.clear()}ne.set(e,{count:1,resetAt:t+ho});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 Y(e,t){return H({ok:!1,error:e},t)}async function Ni(e,t){let n=await e.get(Mt);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(Mt,r),r}async function Li(e,t,n){if(!t.pathname.startsWith(pn))return null;let{store:r,env:o,config:s,auth:i}=n,a=t.pathname.slice(pn.length)||"/",l=e.method.toUpperCase();if(a==="/session"&&l==="GET"){let c=await nn(r,e);return H({ok:!0,authenticated:c,panelPath:i.panelPath})}if(a==="/login"&&l==="POST"){let c="";try{let y=await e.json();c=String(y.password??"")}catch{return Y("\u8BF7\u6C42\u4F53\u89E3\u6790\u5931\u8D25",400)}if(!c)return Y("\u8BF7\u8F93\u5165\u5BC6\u7801",400);let u=Di(e),d=Date.now();if(ki(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(ho/1e3))}});let m=await Wr(i,c);if(!m.ok)return Ii(u,d),Y("\u5BC6\u7801\u9519\u8BEF",401);ne.delete(u),m.legacy&&await Vr(r,c).catch(()=>{}),await Zr(r).catch(()=>{});let g=await qr(r);return H({ok:!0},200,{"Set-Cookie":Jr(g)})}if(a==="/logout"&&l==="POST")return await $r(r,e),H({ok:!0},200,{"Set-Cookie":_r()});if(a==="/preferred-ips"&&l==="POST"){let c=e.headers.get("Authorization")??"",u=c.startsWith("Bearer ")?c.slice(7).trim():c.trim();if(!await to(r,u))return Y("Token \u6821\u9A8C\u5931\u8D25",401);let m;try{m=await e.json()}catch{return Y("\u8BF7\u6C42\u4F53\u89E3\u6790\u5931\u8D25",400)}let y=(Array.isArray(m.ips)?m.ips.map(I=>String(I)):[]).map(I=>I.trim()).filter(I=>I.length>0),S=m.mode==="append",p=I=>I.split("#")[0].trim().replace(/^\[([^\]]+)\]:(\d+)$/,"$1:$2"),x=await r.get(te),E,N=y.length;if(S){let I=(x??"").split(`
6
+ `))}function Rr(e,t){let n=Xt(t.config.subName);switch(e){case"clash":return{body:ai(t),contentType:"text/yaml; charset=utf-8",fileName:n};case"singbox":return{body:li(t),contentType:"application/json; charset=utf-8",fileName:n};default:return{body:ci(t),contentType:"text/plain; charset=utf-8",fileName:n}}}var pe,Hs,Fs,fr,dr,pr,Ks,js,Gs,$s,ti,ni,de,ri,br,Er,oi,xr,Vt=D(()=>{"use strict";se();oe();Ft();cr();pe=443;Hs=["ip\u5730\u5740","ip \u5730\u5740","ip","\u5730\u5740","\u670D\u52A1\u5668","server","host"],Fs=["\u7AEF\u53E3","port"],fr=["\u4E0B\u8F7D\u901F\u5EA6","\u901F\u5EA6","speed","download"],dr=["\u5E73\u5747\u5EF6\u8FDF","\u5EF6\u8FDF","latency","delay","\u54CD\u5E94\u65F6\u95F4","rtt"],pr=["colo","\u673A\u623F","\u6570\u636E\u4E2D\u5FC3","\u5730\u533A","region"],Ks=["\u56FD\u5BB6","country","\u56FD\u522B"],js=["\u57CE\u5E02","city"],Gs=["tls","\u662F\u5426\u652F\u6301tls","\u652F\u6301tls"];$s={official:"\u5B98\u65B9\u4F18\u9009IP",domain:"\u4F18\u9009\u57DF\u540D",manual:"\u4F18\u9009",api:"\u8FDC\u7A0BAPI",csv:"\u6D4B\u901FCSV"};ti=12e4,ni=32,de=new Map,ri="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36";br=["vless-ws","vless-xhttp","trojan"];Er=["vless-ws","trojan"];oi=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;xr=".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 yi(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 Nr(e,t){let n=await crypto.subtle.importKey("raw",Ir.encode(e),{name:"HMAC",hash:"SHA-256"},!1,["sign"]),r=await crypto.subtle.sign("HMAC",n,Ir.encode(t));return yi(new Uint8Array(r))}async function ct(e){let t=(await e.get(lt))?.trim();if(t)return t;let n=Lr();return e instanceof ie&&await e.put(lt,n),n}async function Or(e){let t=Lr();return e instanceof ie?await e.put(lt,t):await e.put(lt,t),t}async function Ur(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"),i=`${qt}.${o.toString(36)}.${s}`,a=(await Nr(e,i)).slice(0,Jt);return`${i}.${a}`}async function ut(e,t,n=Date.now()){if(!e||!t)return{ok:!1,reason:"format"};let r=t.split(".");if(r.length!==4||r[0]!==qt)return{ok:!1,reason:"format"};let o=r[1],s=r[2],i=r[3];if(!o||!s||i.length!==Jt)return{ok:!1,reason:"format"};let a=Number.parseInt(o,36);if(!Number.isFinite(a)||a<0)return{ok:!1,reason:"format"};let l=(await Nr(e,`${qt}.${o}.${s}`)).slice(0,Jt);return $(i,l)?a>0&&Math.floor(n/1e3)>=a?{ok:!1,reason:"expired",exp:a}:{ok:!0,exp:a}:{ok:!1,reason:"signature"}}var lt,qt,Jt,Ir,Lr,_t=D(()=>{"use strict";_e();oe();lt="SUB_TOKEN_SECRET",qt="v1",Jt=22,Ir=new TextEncoder;Lr=()=>Q(32)});function xi(e){let t="";for(let n of e)t+=(n<16?"0":"")+n.toString(16);return t}function Ei(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 Gr(e,t,n){let r=Ei(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 xi(new Uint8Array(s))}function zr(e){if(e.startsWith(`${en}$`)){let[r,o,s,i]=e.split("$");if(r!==en||!s||!i)return null;let a=Number.parseInt(o??"",10);return!Number.isFinite(a)||a<1||a>1e6?null:{scheme:"pbkdf2",salt:s,iterations:a,expected:i}}let[t,n]=e.split(":");return!t||!n?null:{scheme:"sha256",salt:t,iterations:0,expected:n}}async function Yr(e,t){return e.scheme==="pbkdf2"?await Gr(t,e.salt,e.iterations):await Lt(`${e.salt}:${t}`)}async function tn(e,t){let n=await Gr(e,t,Fr);return n?`${en}$${Fr}$${t}$${n}`:`${t}:${await Lt(`${t}:${e}`)}`}async function Ai(e,t){let n=zr(e);if(!n)return!1;let r=await Yr(n,t);return r?$(r,n.expected):!1}function Kr(e){return`/${e.trim().replace(/^\/+/,"")}`}async function Xr(e,t,n){let r=await e.get(tt)??"",o=n&&n.trim()?Kr(n):"";o?r!==o&&(r=o,await e.put(tt,r)):r||(r=Kr(`${qn}-${Xn(6)}`),await e.put(tt,r));let s=await e.get(ve)??"",i=null,a=t&&t.trim()?t.trim():"";if(a){if(!s||!await Ai(s,a)){let f=Q(8);s=await tn(a,f),await e.put(ve,s)}await e.get(be)&&await e.delete(be)}else if(!s){let l=`cfp-${Q(8)}`,f=Q(8);s=await tn(l,f),await e.put(ve,s),i=l,await e.put(be,l)}return{panelPath:r,passwordHash:s,generatedPassword:i}}async function Wr(e,t){let n=zr(e.passwordHash);if(!n)return{ok:!1,legacy:!1};let r=await Yr(n,t);if(!r)return{ok:!1,legacy:!1};let o=$(r,n.expected);return{ok:o,legacy:o&&n.scheme==="sha256"}}async function Vr(e,t){let n=Q(8);await e.put(ve,await tn(t,n))}async function Zr(e){await e.get(be)&&await e.delete(be)}function Qr(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(),i=r.slice(o+1).trim();s&&(n[s]=decodeURIComponent(i))}return n}async function qr(e){let t=Q(24);return await e.put(`${et}${t}`,JSON.stringify({ua:"",t:Date.now()}),jr),t}async function nn(e,t){let n=Qr(t)[dt];return n?!!await e.get(`${et}${n}`):!1}function Jr(e,t=jr){return`${dt}=${e}; Path=/; HttpOnly; Secure; SameSite=Strict; Max-Age=${t}`}function _r(){return`${dt}=; Path=/; HttpOnly; Secure; SameSite=Strict; Max-Age=0`}async function $r(e,t){let n=Qr(t)[dt];n&&await e.delete(`${et}${n}`)}async function eo(e){let t=Q(20);return await e.put(`${$e}${t}`,"1",wi),t}async function to(e,t){if(!t)return!1;let n=await e.get("SCANNER_TOKEN");return n&&$(n,t)?!0:await e.get(`${$e}${t}`)?(await e.delete(`${$e}${t}`),!0):!1}var dt,jr,wi,Fr,en,rn=D(()=>{"use strict";Le();oe();dt="cfpilot_sess",jr=3600*24,wi=600,Fr=3e4,en="pbkdf2"});function on(e){return Vn(e)}async function pt(e,t){if(_.config&&Date.now()-_.configAt<Si)return _.config;let n=await $n(e,t);return _.config=n,_.configAt=Date.now(),n}function no(){_.config=null,_.configAt=0}async function sn(e,t){if(_.auth&&Date.now()-_.authAt<Pi)return _.auth;let n=await Xr(e,t.PANEL_PASSWORD,t.PANEL_PATH);return _.auth=n,_.authAt=Date.now(),n}function an(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 je(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 ro(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 Si,Pi,_,mt=D(()=>{"use strict";_e();Le();rn();Si=15e3,Pi=6e4,_={config:null,configAt:0,auth:null,authAt:0}});function ln(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 me(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 gt(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(!Ci.test(o)){n.push({field:t,message:`${t} \u91CC\u6709\u65E0\u6CD5\u8BC6\u522B\u7684\u6761\u76EE\uFF1A${o.slice(0,40)}`});return}}function oo(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 cn(e){let t=[],n=o=>Object.prototype.hasOwnProperty.call(e,o);n("wsPath")&&ln(String(e.wsPath??""),"wsPath",t),n("trojanPath")&&ln(String(e.trojanPath??""),"trojanPath",t),n("xhttpPath")&&ln(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&&(!Ti.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")&&gt(String(e.proxyIp??""),"proxyIp",t),n("socks5")&&gt(String(e.socks5??""),"socks5",t),n("httpProxy")&&gt(String(e.httpProxy??""),"httpProxy",t),n("relayPool")&&gt(String(e.relayPool??""),"relayPool",t),n("officialCount")&&me(Number(e.officialCount),"officialCount",1,200,t),n("domainCount")&&me(Number(e.domainCount),"domainCount",1,200,t),n("maxNodes")&&me(Number(e.maxNodes),"maxNodes",0,500,t),n("dls")&&me(Number(e.dls),"dls",0,1e3,t),n("maxLatency")&&me(Number(e.maxLatency),"maxLatency",0,1e4,t),n("dataBudgetMB")&&me(Number(e.dataBudgetMB),"dataBudgetMB",0,102400,t),n("subTokenTtlDays")&&me(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(i=>/^\d{1,5}$/.test(i)&&Number(i)>=1&&Number(i)<=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")&&oo(String(e.addApi??""),"addApi",t),n("addCsv")&&oo(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(i=>/^[A-Za-z]{2,3}$/.test(i))||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 un(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 Ti,Ci,so=D(()=>{"use strict";Ti=/^(?=.{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])?)*$/,Ci=/^(?:(?:socks5|socks|socks5h|http|https):\/\/)?(?:[^\s@/]+@)?(?:\[[0-9a-fA-F:]+\]|[A-Za-z0-9._-]+)(?::\d{1,5})?$/});function lo(e,t=Date.now()){let n={};for(let o of ao){let s=e[o];s!==void 0&&(n[o]=s)}let r=Ri.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 co(e){let t=new Set([...ao.map(String),"socks5","httpProxy"]),n={};for(let[r,o]of Object.entries(e))t.has(r)&&(n[r]=o);return n}function io(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 uo(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:io(s),to:io(o)})}return n}var ao,Ri,fo=D(()=>{"use strict";ao=["poolOfficial","officialCount","poolDomain","domainCount","poolManual","poolCountries","add","dls","maxLatency","maxNodes","proxyIp","relayPool","useBuiltinRelay","proxyMode","nat64","concurrentDial","dataBudgetMB","resolvePreferred","enableTrojan","enableXhttp","subProtocol","subTransport","subVariants","subName","subPorts","clientFingerprint","ech","echHost","echDns","tlsFragment","tlsFragmentSize","tlsFragmentDelay","subToken","subTokenTtlDays","unlockProbe","udpDns","udpDnsEndpoint"],Ri=[{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 mo(){return new Response(JSON.stringify({build:Ge,version:fn,ts:Date.now()}),{status:200,headers:{"Content-Type":"application/json","Cache-Control":"no-store","Access-Control-Allow-Origin":"*"}})}var Ge,fn,po,dn=D(()=>{"use strict";Ge="435b64e-547f9c43",fn="0.15.5",po="/__cfp_version"});var yo={};Re(yo,{API_PREFIX:()=>pn,getScannerToken:()=>Ni,handleApi:()=>Li});function Di(e){return e.headers.get("CF-Connecting-IP")??e.headers.get("x-forwarded-for")?.split(",")[0]?.trim()??"unknown"}function ki(e,t){let n=ne.get(e);return n?t>=n.resetAt?(ne.delete(e),!1):n.count>=vi:!1}function Ii(e,t){let n=ne.get(e);if(!n||t>=n.resetAt){if(ne.size>=go){for(let[r,o]of ne)t>=o.resetAt&&ne.delete(r);ne.size>=go&&ne.clear()}ne.set(e,{count:1,resetAt:t+ho});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 Y(e,t){return H({ok:!1,error:e},t)}async function Ni(e,t){let n=await e.get(Mt);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(Mt,r),r}async function Li(e,t,n){if(!t.pathname.startsWith(pn))return null;let{store:r,env:o,config:s,auth:i}=n,a=t.pathname.slice(pn.length)||"/",l=e.method.toUpperCase();if(a==="/session"&&l==="GET"){let c=await nn(r,e);return H({ok:!0,authenticated:c,panelPath:i.panelPath})}if(a==="/login"&&l==="POST"){let c="";try{let y=await e.json();c=String(y.password??"")}catch{return Y("\u8BF7\u6C42\u4F53\u89E3\u6790\u5931\u8D25",400)}if(!c)return Y("\u8BF7\u8F93\u5165\u5BC6\u7801",400);let u=Di(e),d=Date.now();if(ki(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(ho/1e3))}});let m=await Wr(i,c);if(!m.ok)return Ii(u,d),Y("\u5BC6\u7801\u9519\u8BEF",401);ne.delete(u),m.legacy&&await Vr(r,c).catch(()=>{}),await Zr(r).catch(()=>{});let g=await qr(r);return H({ok:!0},200,{"Set-Cookie":Jr(g)})}if(a==="/logout"&&l==="POST")return await $r(r,e),H({ok:!0},200,{"Set-Cookie":_r()});if(a==="/preferred-ips"&&l==="POST"){let c=e.headers.get("Authorization")??"",u=c.startsWith("Bearer ")?c.slice(7).trim():c.trim();if(!await to(r,u))return Y("Token \u6821\u9A8C\u5931\u8D25",401);let m;try{m=await e.json()}catch{return Y("\u8BF7\u6C42\u4F53\u89E3\u6790\u5931\u8D25",400)}let y=(Array.isArray(m.ips)?m.ips.map(I=>String(I)):[]).map(I=>I.trim()).filter(I=>I.length>0),S=m.mode==="append",p=I=>I.split("#")[0].trim().replace(/^\[([^\]]+)\]:(\d+)$/,"$1:$2"),x=await r.get(te),E,N=y.length;if(S){let I=(x??"").split(`
7
7
  `).map(A=>A.trim()).filter(A=>A.length>0),X=new Set(I.map(p)),M=y.filter(A=>{let v=p(A);return X.has(v)?!1:(X.add(v),!0)});N=M.length,E=[...I,...M].join(`
8
8
  `)}else E=y.join(`
9
9
  `);x!==E&&await r.put(te,E);let P={};!S&&(s.add??"").trim()!==""&&(P.add=""),s.poolManual||(P.poolManual=!0);let b=!1;return Object.keys(P).length>0&&(await ke(r,De(s,P)),n.onConfigChanged(),b=P.add!==void 0),H({ok:!0,mode:S?"append":"replace",count:y.length,added:N,clearedManual:b,enabledManual:P.poolManual===!0})}if(!await nn(r,e))return Y("\u672A\u767B\u5F55\u6216\u4F1A\u8BDD\u5DF2\u8FC7\u671F",401);if(a==="/status"&&l==="GET"){let c=await Ie(r),u=Fe(c),d=je(s.subDomain||o.DATA_HOST||t.hostname);return H({ok:!0,panelPath:i.panelPath,domain:t.hostname,nodeDomain:d,dataHost:o.DATA_HOST??"",colo:e.cf?.colo??"UNK",coloLabel:Be(e.cf?.colo??""),localIps:u.length,generatedPassword:i.generatedPassword,version:Ge,pkgVersion:fn,readAt:Date.now()})}if(a==="/config"&&l==="GET")return H({ok:!0,config:s});if(a==="/config"&&l==="PUT"){let c;try{c=await e.json()}catch{return Y("\u8BF7\u6C42\u4F53\u89E3\u6790\u5931\u8D25",400)}if(!c.config||typeof c.config!="object")return Y("\u7F3A\u5C11\u914D\u7F6E\u5BF9\u8C61",400);let u=cn(c.config);if(u.length>0)return Y(un(u),400);let d=De(s,c.config);return await ke(r,d),n.onConfigChanged(),H({ok:!0,config:d})}if(a==="/config/export"&&l==="GET")return H({ok:!0,...lo(s)});if(a==="/config/import"&&l==="POST"){let c;try{c=await e.json()}catch{return Y("\u8BF7\u6C42\u4F53\u89E3\u6790\u5931\u8D25",400)}if(!c.config||typeof c.config!="object")return Y("\u7F3A\u5C11\u914D\u7F6E\u5BF9\u8C61",400);let u=co(c.config);if(Object.keys(u).length===0)return Y("\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=cn(u);if(d.length>0)return Y(un(d),400);let m=uo(s,u);if(c.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=De(s,u);return await ke(r,g),n.onConfigChanged(),H({ok:!0,applied:m.length,diff:m,config:g})}if(a==="/ips"&&l==="GET"){let c=await Ie(r),u=Fe(c);return H({ok:!0,raw:c,count:u.length,entries:u})}if(a==="/ips"&&l==="DELETE")return await r.delete(te),H({ok:!0});if(a==="/ips"&&l==="PUT"){let c;try{c=await e.json()}catch{return Y("\u8BF7\u6C42\u4F53\u89E3\u6790\u5931\u8D25",400)}if(typeof c.raw!="string")return Y("\u7F3A\u5C11 raw \u5B57\u6BB5",400);let u=c.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.4";
90
+ VERSION = "0.15.5";
91
91
  NAME = "cfpilot";
92
92
  }
93
93
  });
@@ -5477,10 +5477,15 @@ async function runScan(options) {
5477
5477
  });
5478
5478
  }
5479
5479
  }
5480
- const stage2 = pickWithDiversity(
5481
- wsFiltered.sort((a, b) => a.tls.tlsMs - b.tls.tlsMs || a.latency - b.latency),
5482
- speedLimit
5480
+ const rankedByLatency = wsFiltered.sort(
5481
+ (a, b) => a.tls.tlsMs - b.tls.tlsMs || a.latency - b.latency
5483
5482
  );
5483
+ let stage2;
5484
+ if (options.twoStageSpeed && !options.skipSpeed) {
5485
+ stage2 = await coarsePreRank(options, rankedByLatency, speedLimit, report, strictProbePath);
5486
+ } else {
5487
+ stage2 = pickWithDiversity(rankedByLatency, speedLimit);
5488
+ }
5484
5489
  let speedResults;
5485
5490
  const speedMode = options.speedMode ?? "probe";
5486
5491
  if (options.skipSpeed) {
@@ -5683,6 +5688,83 @@ function formatCopyable(entries) {
5683
5688
  function formatEntries(entries) {
5684
5689
  return entries.map((e) => `${formatHost(e.ip)}:${e.port}#${preferredRemark(e)}`);
5685
5690
  }
5691
+ function rankByCoarseSpeed(items, coarse, limit) {
5692
+ const sorted = [...items].sort(
5693
+ (a, b) => (coarse.get(b.ip) ?? 0) - (coarse.get(a.ip) ?? 0)
5694
+ );
5695
+ if (sorted.length <= limit) return sorted;
5696
+ return pickWithDiversity(sorted, limit);
5697
+ }
5698
+ async function coarsePreRank(options, candidates, speedLimit, report, probePath) {
5699
+ const limit = Math.max(1, options.coarseSpeedLimit ?? COARSE_SPEED_DEFAULTS.limit);
5700
+ const poolInput = pickWithDiversity(candidates, limit);
5701
+ const startedAt = Date.now();
5702
+ const budgetMs = options.coarseBudgetMs ?? COARSE_SPEED_DEFAULTS.budgetMs;
5703
+ const coarse = /* @__PURE__ */ new Map();
5704
+ let done = 0;
5705
+ let budgetHit = false;
5706
+ report({ type: "stage", stage: 2, name: "\u5168\u91CF\u7C97\u7B5B\uFF08\u77ED\u6D4B\u7C97\u6392\uFF09", total: poolInput.length });
5707
+ await pool(poolInput, 1, async (item) => {
5708
+ if (Date.now() - startedAt > budgetMs) {
5709
+ if (!budgetHit) {
5710
+ budgetHit = true;
5711
+ report({
5712
+ type: "progress",
5713
+ stage: 2,
5714
+ done,
5715
+ total: poolInput.length,
5716
+ message: `\u7C97\u7B5B\u5DF2\u8FBE\u603B\u9884\u7B97 ${Math.round(budgetMs / 1e3)}s\uFF0C\u5269\u4F59\u5019\u9009\u6309\u5EF6\u8FDF\u515C\u5E95`
5717
+ });
5718
+ }
5719
+ return;
5720
+ }
5721
+ let speed = 0;
5722
+ try {
5723
+ const common = {
5724
+ ip: item.ip,
5725
+ port: options.port,
5726
+ connections: options.coarseConnections ?? COARSE_SPEED_DEFAULTS.connections,
5727
+ durationMs: options.coarseDurationMs ?? COARSE_SPEED_DEFAULTS.durationMs,
5728
+ warmupMs: COARSE_SPEED_DEFAULTS.warmupMs,
5729
+ windowMs: COARSE_SPEED_DEFAULTS.windowMs,
5730
+ timeoutMs: options.coarseTimeoutMs ?? COARSE_SPEED_DEFAULTS.timeoutMs
5731
+ };
5732
+ if ((options.speedMode ?? "probe") === "url") {
5733
+ const parsed = parseSpeedUrl(
5734
+ options.speedUrl ?? DEFAULT_SPEED_URL,
5735
+ schemeForPort(options.port)
5736
+ );
5737
+ const one = await measureThroughput({
5738
+ ...common,
5739
+ sniHost: parsed.host,
5740
+ requestHost: parsed.host,
5741
+ path: withBytes(parsed, options.speedBytes ?? 104857600)
5742
+ });
5743
+ if (one.ok) speed = one.steadyMBps;
5744
+ } else {
5745
+ const one = await measureProbeThroughput({
5746
+ ...common,
5747
+ host: options.host,
5748
+ bytes: options.speedBytes ?? 5 * 1024 * 1024,
5749
+ path: probePath,
5750
+ token: options.uuid
5751
+ });
5752
+ if (one.ok) speed = one.steadyMBps;
5753
+ }
5754
+ } catch {
5755
+ }
5756
+ coarse.set(item.ip, speed);
5757
+ done++;
5758
+ report({
5759
+ type: "progress",
5760
+ stage: 2,
5761
+ done,
5762
+ total: poolInput.length,
5763
+ message: `\u7C97\u7B5B ${done}/${poolInput.length} \xB7 \u77ED\u6D4B ${speed.toFixed(1)} MB/s`
5764
+ });
5765
+ });
5766
+ return rankByCoarseSpeed(candidates, coarse, speedLimit);
5767
+ }
5686
5768
  function pickWithDiversity(ranked, top) {
5687
5769
  if (top <= 0) return [];
5688
5770
  const v4 = ranked.filter((item) => !item.ip.includes(":"));
@@ -5725,6 +5807,7 @@ function roundRobinBy(ranked, top, keyOf) {
5725
5807
  }
5726
5808
  return out;
5727
5809
  }
5810
+ var COARSE_SPEED_DEFAULTS;
5728
5811
  var init_scan = __esm({
5729
5812
  "src/scan/scan.ts"() {
5730
5813
  "use strict";
@@ -5733,6 +5816,22 @@ var init_scan = __esm({
5733
5816
  init_countries();
5734
5817
  init_unlock();
5735
5818
  init_ip_ranges();
5819
+ COARSE_SPEED_DEFAULTS = {
5820
+ /** 粗筛最多测多少个 101 通过候选(预算上限) */
5821
+ limit: 120,
5822
+ /** 单次粗筛测量时长:精测 6s 的 1/5 */
5823
+ durationMs: 1200,
5824
+ /** 丢弃的慢启动样本:短测不能沿用精测的 1s,否则几乎没有稳态样本 */
5825
+ warmupMs: 300,
5826
+ /** 结算窗口:与短测时长匹配 */
5827
+ windowMs: 300,
5828
+ /** 连接数:精测 8 条的 1/4,只求相对排序、不求绝对带宽 */
5829
+ connections: 2,
5830
+ /** 单次整体预算(含拨号 / TLS / 传输),失败候选最多占 3s */
5831
+ timeoutMs: 3e3,
5832
+ /** 整个粗筛阶段的总预算,到点停止派发,剩余候选按延迟兜底 */
5833
+ budgetMs: 24e4
5834
+ };
5736
5835
  }
5737
5836
  });
5738
5837
 
@@ -7346,6 +7445,16 @@ scan \u9009\u9879:
7346
7445
  \u5E26\u5BBD\u7531\u6574\u6761\u94FE\u8DEF\u5171\u4EAB\uFF1A\u5E76\u884C\u6D4B\u591A\u4E2A\u5019\u9009\u4F1A\u4E92\u76F8\u62A2\u5E26\u5BBD\uFF0C
7347
7446
  \u6BCF\u4E2A\u90FD\u53EA\u80FD\u6D4B\u5230 1/N\uFF0C\u6570\u503C\u666E\u904D\u504F\u4F4E\uFF08\u8001\u7248\u672C\u62A5\u51FA
7348
7447
  0.1 MB/s \u7684\u4E3B\u56E0\uFF09\u3002>1 \u53EA\u5728\u5343\u5146\u4EE5\u4E0A\u94FE\u8DEF\u624D\u6709\u610F\u4E49
7448
+ --two-stage-speed \u4E24\u8F6E\u6D4B\u901F\uFF08\u9ED8\u8BA4\u5173\u95ED\uFF09\uFF1A\u5BF9**\u5168\u90E8** 101 \u901A\u8FC7\u5019\u9009\u5148\u505A\u77ED\u6D4B\u7C97\u6392\uFF0C
7449
+ \u518D\u5BF9\u7C97\u6392\u524D --speed-limit \u540D\u505A\u5B8C\u6574\u7CBE\u6D4B
7450
+ \u89E3\u51B3\u300C\u63E1\u624B\u7A0D\u6162\u4F46\u4E0B\u884C\u660E\u663E\u66F4\u5FEB\u7684 IP \u88AB\u5EF6\u8FDF\u6392\u5E8F\u622A\u6389\u300D
7451
+ \u7C97\u7B5B\u4E32\u884C 1.2s \xD7 2 \u8FDE\u63A5\uFF0C\u6700\u591A 120 \u4E2A\u3001\u603B\u9884\u7B97 4 \u5206\u949F\uFF1B
7452
+ \u7C97\u6D4B\u901F\u5EA6\u53EA\u7528\u4E8E\u6392\u5E8F\uFF0C**\u4E0D\u5199\u8FDB\u7ED3\u679C**\uFF0C\u901F\u5EA6\u4ECD\u6765\u81EA\u7CBE\u6D4B
7453
+ --coarse-speed-limit <n> \u7C97\u7B5B\u5019\u9009\u4E0A\u9650\uFF0C\u9ED8\u8BA4 120
7454
+ --coarse-duration <ms> \u7C97\u7B5B\u5355\u6B21\u65F6\u957F\uFF0C\u9ED8\u8BA4 1200
7455
+ --coarse-conns <n> \u7C97\u7B5B\u8FDE\u63A5\u6570\uFF0C\u9ED8\u8BA4 2
7456
+ --coarse-timeout <ms> \u7C97\u7B5B\u5355\u6B21\u6574\u4F53\u9884\u7B97\uFF0C\u9ED8\u8BA4 3000
7457
+ --coarse-budget <ms> \u7C97\u7B5B\u9636\u6BB5\u603B\u9884\u7B97\uFF0C\u9ED8\u8BA4 240000\uFF08\u5230\u70B9\u5269\u4F59\u6309\u5EF6\u8FDF\u515C\u5E95\uFF09
7349
7458
  --retries <n> \u6BCF\u4E2A\u63A2\u6D4B\u7684\u5C1D\u8BD5\u6B21\u6570\uFF08\u542B\u9996\u6B21\uFF09\uFF0C\u9ED8\u8BA4 2
7350
7459
  \u771F\u673A\u5076\u53D1\u5931\u8D25\u7387 3~5%\uFF0C\u91CD\u8BD5\u53D6\u7B2C\u4E00\u6B21\u6210\u529F\u7684\u7ED3\u679C
7351
7460
  --no-verify \u9636\u6BB5\u4E8C\u53EA\u505A 101 \u63E1\u624B\uFF0C\u8DF3\u8FC7\u54CD\u5E94\u4F53\u6821\u9A8C
@@ -8769,6 +8878,14 @@ ${NAME} v${VERSION}
8769
8878
  probeLimit: flagNumber(args, "probe-limit", 120),
8770
8879
  probeTimeoutMs: flagNumber(args, "probe-timeout", 3e3),
8771
8880
  speedLimit: flagNumber(args, "speed-limit", 30),
8881
+ // 两轮测速:默认关闭(脚本行为不变),--two-stage-speed 开启。
8882
+ // 桌面版界面默认开启,两边语义一致:true = 全量短测粗排 + 前 N 精测。
8883
+ twoStageSpeed: flagBool(args, "two-stage-speed"),
8884
+ coarseSpeedLimit: flagNumber(args, "coarse-speed-limit", COARSE_SPEED_DEFAULTS.limit),
8885
+ coarseDurationMs: flagNumber(args, "coarse-duration", COARSE_SPEED_DEFAULTS.durationMs),
8886
+ coarseConnections: flagNumber(args, "coarse-conns", COARSE_SPEED_DEFAULTS.connections),
8887
+ coarseTimeoutMs: flagNumber(args, "coarse-timeout", COARSE_SPEED_DEFAULTS.timeoutMs),
8888
+ coarseBudgetMs: flagNumber(args, "coarse-budget", COARSE_SPEED_DEFAULTS.budgetMs),
8772
8889
  speedTimeoutMs: flagNumber(args, "speed-timeout", 12e3),
8773
8890
  speedBytes: flagNumber(args, "speed-bytes", 5 * 1024 * 1024),
8774
8891
  speedMode,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cfpilot",
3
- "version": "0.15.4",
3
+ "version": "0.15.5",
4
4
  "description": "CFPilot —— Cloudflare Pages 代理部署与优选工具(交互菜单 + 子命令)",
5
5
  "type": "module",
6
6
  "license": "AGPL-3.0-only",