cfpilot 0.33.6 → 0.33.7
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 +1 -1
- package/assets/dataplane.js +1 -1
- package/assets/worker.js +1 -1
- package/dist/cli.js +70 -24
- package/package.json +1 -1
package/assets/control.js
CHANGED
|
@@ -4,7 +4,7 @@ const __sfx=(()=>{const __t=new TextDecoder(),__c=new Map();return b=>{let v=__c
|
|
|
4
4
|
`))),i){let N=""+T+__sfx("IFRyb2phbg==");r.push(N),I.push(N),n.push([__sfx("ICAtIG5hbWU6IA==")+B(N)+"",__sfx("ICAgIHR5cGU6IHRyb2phbg=="),__sfx("ICAgIHBhc3N3b3JkOiA=")+B(t.config.trojanPassword)+"",__sfx("ICAgIHNlcnZlcjog")+b.ip+"",__sfx("ICAgIHBvcnQ6IA==")+E+"",__sfx("ICAgIG5ldHdvcms6IHdz"),__sfx("ICAgIHRsczogdHJ1ZQ=="),__sfx("ICAgIHNuaTog")+t.domain+"",__sfx("ICAgIGNsaWVudC1maW5nZXJwcmludDog")+t.config.clientFingerprint+"",...l()," ws-opts:",__sfx("ICAgICAgcGF0aDog")+B(t.config.trojanPath)+""," headers:",` Host: ${t.domain}`].join(`
|
|
5
5
|
`))}}});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(""),u&&(e.push(" nameserver-policy:"),e.push(` ${B(d)}: ${c?B(c):"https://223.5.5.5/dns-query"}`),e.push(""));let f=nn(t.routeProfile??"",{mainGroup:Q,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 p of r)e.push(` - ${B(p)}`);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 b of r)e.push(` - ${B(b)}`);e.push(""),e.push(__sfx("ICAtIG5hbWU6ICLmlYXpmpzovaznp7si")),e.push(__sfx("ICAgIHR5cGU6IGZhbGxiYWNr")),e.push(__sfx("ICAgIHVybDogImh0dHA6Ly93d3cuZ3N0YXRpYy5jb20vZ2VuZXJhdGVfMjA0Ig==")),e.push(__sfx("ICAgIGludGVydmFsOiAzMDA=")),e.push(" proxies:");for(let b of r)e.push(` - ${B(b)}`);let p=(b,m)=>{e.push(""),e.push(__sfx("ICAtIG5hbWU6IA==")+B(b)+""),e.push(__sfx("ICAgIHR5cGU6IHNlbGVjdA==")),e.push(" proxies:");for(let x of m)e.push(` - ${B(x)}`)};o.v4.length>0&&p(__sfx("5LyY6YCJSVB2NA=="),o.v4),o.v6.length>0&&p(__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(p=>p.includes("MATCH,"))||e.push(` - MATCH,${Q}`)):e.push(...ot(Q)),e.push(""),e.join(`
|
|
6
6
|
`)}function ro(t){let e=[],n=[],r=lt(t.config.subVariants,t.config,hn),o=r.some(c=>c===__sfx("dmxlc3Mtd3M=")),s=r.includes(__sfx("dHJvamFu")),a=t.config.ech,i=t.config.echHost.trim()||__sfx("Y2xvdWRmbGFyZS1lY2guY29t"),u=()=>a?{ech:{enabled:!0,query_server_name:i}}:{};for(let c of ct(t)){let l=[];c.entries.forEach((f,p)=>{let b=`${c.name} ${Ee(f,"vless",p,"")}`;for(let m of pt(f,t)){let x=t.ports.length>1?`:${m}`:"",I=`${b}${x}`,E=""+I+__sfx("IFRyb2phbg==");o&&l.push(I),s&&l.push(E),o&&e.push({type:__sfx("dmxlc3M="),tag:I,server:f.ip,server_port:m,uuid:t.config.uuid,tls:{enabled:!0,server_name:t.domain,insecure:!1,utls:{enabled:!0,fingerprint:t.config.clientFingerprint},...u()},transport:{type:"ws",path:t.config.wsPath,headers:{Host:t.domain}}}),s&&e.push({type:__sfx("dHJvamFu"),tag:E,server:f.ip,server_port:m,password:t.config.trojanPassword,tls:{enabled:!0,server_name:t.domain,insecure:!1,utls:{enabled:!0,fingerprint:t.config.clientFingerprint},...u()},transport:{type:"ws",path:t.config.trojanPath,headers:{Host:t.domain}}})}}),l.length>0&&n.push({tag:c.name,members:l})}e.push({type:"direct",tag:"direct"});for(let c of n)e.push({type:"selector",tag:c.tag,outbounds:c.members,default:c.members[0]});return e.push({type:"selector",tag:__sfx("Q0ZQaWxvdA=="),outbounds:n.length>0?n.map(c=>c.tag):["direct"],default:n.length>0?n[0].tag:"direct"}),JSON.stringify({log:{level:"info",timestamp:!0},dns:{servers:[{tag:"dns-out",address:"https://1.1.1.1/dns-query"},{tag:"local",address:"local"}],rules:[{domain_suffix:gn,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:gn,outbound:"direct"}],final:__sfx("Q0ZQaWxvdA=="),auto_detect_interface:!0}},null,2)}function oo(t){let e=[],n=lt(t.config.subVariants,t.config);for(let r of ct(t))r.entries.forEach((o,s)=>{let a=Ee(o,__sfx("dmxlc3M="),s,r.name);for(let i of pt(o,t)){let u=t.ports.length>1?`:${i}`:"",d=`${a}${u}`,c={...o,port:i};for(let l of n)l===__sfx("dmxlc3Mtd3M=")?e.push(dn(c,t,"ws",`${d} WS`)):l===__sfx("dmxlc3MteGh0dHA=")?e.push(dn(c,t,__sfx("eGh0dHA="),""+d+__sfx("IFhIVFRQ"))):e.push(to(c,t,""+d+__sfx("IFRyb2phbg==")))}});return Gt(e.join(`
|
|
7
|
-
`))}function Sn(t,e){let n=ft(e.config.subName);switch(t){case __sfx("Y2xhc2g="):return{body:no(e),contentType:"text/yaml; charset=utf-8",fileName:n};case"singbox":return{body:ro(e),contentType:"application/json; charset=utf-8",fileName:n};default:return{body:oo(e),contentType:"text/plain; charset=utf-8",fileName:n}}}var te,Dr,Lr,on,sn,an,Fr,Ur,Mr,Zr,Qr,qr,ee,_r,pn,hn,$r,gn,Me=U(()=>{"use strict";Qt();W();rt();st();te=443;Dr=[__sfx("aXDlnLDlnYA="),__sfx("aXAg5Zyw5Z2A"),"ip",__sfx("5Zyw5Z2A"),__sfx("5pyN5Yqh5Zmo"),"server","host"],Lr=[__sfx("56uv5Y+j"),"port"],on=[__sfx("5LiL6L296YCf5bqm"),__sfx("6YCf5bqm"),"speed","download"],sn=[__sfx("5bmz5Z2H5bu26L+f"),__sfx("5bu26L+f"),"latency","delay",__sfx("5ZON5bqU5pe26Ze0"),"rtt"],an=["colo",__sfx("5py65oi/"),__sfx("5pWw5o2u5Lit5b+D"),__sfx("5Zyw5Yy6"),"region"],Fr=[__sfx("5Zu95a62"),"country",__sfx("5Zu95Yir")],Ur=[__sfx("5Z+O5biC"),"city"],Mr=["tls",__sfx("5piv5ZCm5pSv5oyBdGxz"),__sfx("5pSv5oyBdGxz")];Zr={official:__sfx("5a6Y5pa55LyY6YCJSVA="),domain:__sfx("5LyY6YCJ5Z+f5ZCN"),manual:__sfx("5LyY6YCJ"),api:__sfx("6L+c56iLQVBJ"),csv:__sfx("5rWL6YCfQ1NW")};Qr=12e4,qr=32,ee=new Map,_r="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36";pn=[__sfx("dmxlc3Mtd3M="),__sfx("dmxlc3MteGh0dHA="),__sfx("dHJvamFu")];hn=[__sfx("dmxlc3Mtd3M="),__sfx("dHJvamFu")];$r=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;gn=".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 po(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 On(t,e){let n=await crypto.subtle.importKey("raw",Rn.encode(t),{name:"HMAC",hash:"SHA-256"},!1,["sign"]),r=await crypto.subtle.sign("HMAC",n,Rn.encode(e));return po(new Uint8Array(r))}async function je(t){let e=(await t.get(Ke))?.trim();if(e)return e;if(!(t instanceof Z))return Ge();if(mt)return mt;let n=Date.now();if(Be===0&&(Be=n),n-Be<=go)return He||(He=Ge()),He;let r=Ge();return await t.put(Ke,r),Be=0,He=r,mt=r,r}async function In(t){let e=Ge();return t instanceof Z?await t.put(Ke,e):await t.put(Ke,e),e}async function Nn(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=`${ht}.${o.toString(36)}.${s}`,i=(await On(t,a)).slice(0,bt);return`${a}.${i}`}async function Ye(t,e,n=Date.now()){if(!t||!e)return{ok:!1,reason:"format"};let r=e.split(".");if(r.length!==4||r[0]!==ht)return{ok:!1,reason:"format"};let o=r[1],s=r[2],a=r[3];if(!o||!s||a.length!==bt)return{ok:!1,reason:"format"};let i=Number.parseInt(o,36);if(!Number.isFinite(i)||i<0)return{ok:!1,reason:"format"};let u=(await On(t,`${ht}.${o}.${s}`)).slice(0,bt);return X(a,u)?i>0&&Math.floor(n/1e3)>=i?{ok:!1,reason:"expired",exp:i}:{ok:!0,exp:i}:{ok:!1,reason:"signature"}}var Ke,ht,bt,Rn,Ge,mt,He,Be,go,yt=U(()=>{"use strict";Te();W();Ke="SUB_TOKEN_SECRET",ht="v1",bt=22,Rn=new TextEncoder;Ge=()=>H(32);mt=null,He=null,Be=0,go=9e4});function bo(t){let e="";for(let n of t)e+=(n<16?"0":"")+n.toString(16);return e}function yo(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 Un(t,e,n){let r=yo(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 bo(new Uint8Array(s))}function Mn(t){if(t.startsWith(`${Et}$`)){let[r,o,s,a]=t.split("$");if(r!==Et||!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 Hn(t,e){return t.scheme==="pbkdf2"?await Un(e,t.salt,t.iterations):await Qe(`${t.salt}:${e}`)}async function St(t,e){let n=await Un(t,e,Ln);return n?`${Et}$${Ln}$${e}$${n}`:`${e}:${await Qe(`${e}:${t}`)}`}async function wo(t,e){let n=Mn(t);if(!n)return!1;let r=await Hn(n,e);return r?X(r,n.expected):!1}function Fn(t){return`/${t.trim().replace(/^\/+/,"")}`}async function Bn(t,e,n){let r=await t.get(Ie)??"",o=n&&n.trim()?Fn(n):"";o?r!==o&&(r=o,await t.put(Ie,r)):r||(r=Fn(`${jt}-${Bt(6)}`),await t.put(Ie,r));let s=await t.get(me)??"",a=null,i=e&&e.trim()?e.trim():"";if(i){if(!s||!await wo(s,i)){let d=H(8);s=await St(i,d),await t.put(me,s)}await t.get(ie)&&await t.delete(ie)}else if(!s){let u=`cfp-${H(8)}`,d=H(8);s=await St(u,d),await t.put(me,s),a=u,await t.put(ie,u)}return{panelPath:r,passwordHash:s,generatedPassword:a}}async function Gn(t,e){let n=Mn(t.passwordHash);if(!n)return{ok:!1,legacy:!1};let r=await Hn(n,e);if(!r)return{ok:!1,legacy:!1};let o=X(r,n.expected);return{ok:o,legacy:o&&n.scheme==="sha256"}}async function Kn(t,e){let n=H(8);await t.put(me,await St(e,n))}async function jn(t){await t.get(ie)&&await t.delete(ie)}function Ct(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}function Po(t){for(let[e,n]of fe)n<=t&&fe.delete(e)}async function Yn(t){let e=H(24);await t.put(`${Oe}${e}`,JSON.stringify({ua:"",t:Date.now()}),Pt);let n=Date.now();return Po(n),fe.set(e,n+Pt*1e3),e}function zn(t){return!!Ct(t)[Se]}async function xt(t,e){let n=Ct(e)[Se];if(!n)return!1;let r=fe.get(n);if(r!==void 0){if(r>Date.now())return!0;fe.delete(n)}return!!await t.get(`${Oe}${n}`)}function Vn(t,e=Pt){return`${Se}=${t}; Path=/; HttpOnly; Secure; SameSite=Strict; Max-Age=${e}`}function Xn(){return`${Se}=; Path=/; HttpOnly; Secure; SameSite=Strict; Max-Age=0`}async function Wn(t,e){let n=Ct(e)[Se];n&&(fe.delete(n),await t.delete(`${Oe}${n}`))}async function Zn(t){let e=H(20);return await t.put(`${Re}${e}`,"1",ho),e}async function Jn(t,e){if(!e)return!1;let n=await t.get("SCANNER_TOKEN");return n&&X(n,e)?!0:await t.get(`${Re}${e}`)?(await t.delete(`${Re}${e}`),!0):!1}var Se,Pt,ho,Ln,Et,fe,At=U(()=>{"use strict";be();W();Se=__sfx("Y2ZwaWxvdF9zZXNz"),Pt=3600*24,ho=600,Ln=3e4,Et="pbkdf2";fe=new Map});function Qn(t){return Kt(t)}async function Tt(t,e){if(j.config&&Date.now()-j.configAt<Eo)return j.config;let n=await Vt(t,e);return j.config=n,j.configAt=Date.now(),n}function qn(){j.config=null,j.configAt=0}async function Rt(t,e){if(j.auth&&Date.now()-j.authAt<So)return j.auth;let n=await Bn(t,e.PANEL_PASSWORD,e.PANEL_PATH);return j.auth=n,j.authAt=Date.now(),n}function Ot(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 Ce(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 _n(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,So,j,Ve=U(()=>{"use strict";Te();be();At();Eo=15e3,So=6e4,j={config:null,configAt:0,auth:null,authAt:0}});function Nt(t){let e=[];if(t.split(/\r?\n/).forEach((s,a)=>{let i=s.trim();if(!i)return;let u=i.replace(/^["']|["']$/g,"").trim();!u||u.startsWith("#")||ne(i)===null&&e.push(a+1)}),e.length===0)return"";let r=e.slice(0,3).map(s=>`\u7B2C ${s} \u884C`).join("\u3001"),o=e.length>3?` \u7B49 ${e.length} \u884C`:"";return __sfx("5omL5Yqo5oyH5a6aIElQIOaciSA=")+e.length+__sfx("IOihjOaXoOazleivhuWIq++8iA==")+r+""+o+")"}function It(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 re(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 Xe(t,e,n,r=Ao){let o=t.split(/\r?\n|,/).map(s=>s.trim()).filter(Boolean);if(o.length>r){n.push({field:e,message:""+e+__sfx("IOacgOWkmiA=")+r+__sfx("IOadoe+8iOW9k+WJjSA=")+o.length+")"});return}for(let s of o)if(!xo.test(s)){n.push({field:e,message:""+e+__sfx("IOmHjOacieaXoOazleivhuWIq+eahOadoeebru+8mg==")+s.slice(0,40)+""});return}}function er(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 Ro(t,e,n){let r=t.split(/\r?\n/).map(s=>s.trim()).filter(Boolean);if(r.length>$n){n.push({field:e,message:""+e+__sfx("IOacgOWkmiA=")+$n+__sfx("IOadoe+8iOW9k+WJjSA=")+r.length+")"});return}let o=Nt(t);o&&n.push({field:e,message:o})}function kt(t){let e=[],n=o=>Object.prototype.hasOwnProperty.call(t,o);n("wsPath")&&It(String(t.wsPath??""),"wsPath",e),n(__sfx("dHJvamFuUGF0aA=="))&&It(String(t.trojanPath??""),__sfx("dHJvamFuUGF0aA=="),e),n(__sfx("eGh0dHBQYXRo"))&&It(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&&(!Co.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=="))&&Xe(String(t.proxyIp??""),__sfx("cHJveHlJcA=="),e),n(__sfx("c29ja3M1"))&&Xe(String(t.socks5??""),__sfx("c29ja3M1"),e),n("httpProxy")&&Xe(String(t.httpProxy??""),"httpProxy",e),n("relayPool")&&Xe(String(t.relayPool??""),"relayPool",e,To),n("officialCount")&&re(Number(t.officialCount),"officialCount",1,200,e),n("domainCount")&&re(Number(t.domainCount),"domainCount",1,200,e),n("maxNodes")&&re(Number(t.maxNodes),"maxNodes",0,500,e),n("dls")&&re(Number(t.dls),"dls",0,1e3,e),n("maxLatency")&&re(Number(t.maxLatency),"maxLatency",0,1e4,e),n("dataBudgetMB")&&re(Number(t.dataBudgetMB),"dataBudgetMB",0,102400,e),n("subTokenTtlDays")&&re(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")&&er(String(t.addApi??""),"addApi",e),n("addCsv")&&er(String(t.addCsv??""),"addCsv",e),n("add")&&Ro(String(t.add??""),"add",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 vt(t){return t.length===0?"":t.length===1?t[0].message:"有 "+t.length+__sfx("IOmhuemFjee9ruS4jeWQiOazle+8mg==")+t.map(e=>e.message).join("\uFF1B")+""}var Co,xo,Ao,To,$n,tr=U(()=>{"use strict";Me();Co=/^(?=.{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])?)*$/;xo=/^(?:(?:socks5|socks|socks5h|http|https):\/\/)?(?:[^\s@/]+@)?(?:\[[0-9a-fA-F:]+\]|[A-Za-z0-9._-]+)(?::\d{1,5})?$/;Ao=20,To=200,$n=2e3});function or(t,e=Date.now()){let n={};for(let o of rr){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 sr(t){let e=new Set([...rr.map(String),__sfx("c29ja3M1"),"httpProxy"]),n={};for(let[r,o]of Object.entries(t))e.has(r)&&(n[r]=o);return n}function nr(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 ir(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:nr(s),to:nr(o)})}return n}var rr,Oo,ar=U(()=>{"use strict";rr=["poolOfficial","officialCount","poolDomain","domainCount","poolManual","poolCountries","add","dls","maxLatency","maxNodes",__sfx("cHJveHlJcA=="),"relayPool","useBuiltinRelay","proxyMode","nat64","concurrentDial","dataBudgetMB","resolvePreferred","aggressiveRedial",__sfx("ZW5hYmxlVHJvamFu"),__sfx("ZW5hYmxlWGh0dHA="),"subProtocol","subTransport","subVariants","subName","subPorts","clientFingerprint","ech","echHost","echDns","tlsFragment","tlsFragmentSize","tlsFragmentDelay","subToken","subTokenTtlDays","unlockProbe","udpDns","udpDnsEndpoint"],Oo=[{field:"uuid",reason:__sfx("5YWl56uZ5Yet5o2u")},{field:__sfx("dHJvamFuUGFzc3dvcmQ="),reason:__sfx("5YWl56uZ5Yet5o2u")},{field:"wsPath",reason:__sfx("5a6e5L6L5qCH6K+G77yI6K6i6ZiF6ZO+5o6l6YeM5Y+v6KeB77yM5a+85Ye65Y2z5pq06Zyy5YWl5Y+j77yJ")},{field:__sfx("dHJvamFuUGF0aA=="),reason:__sfx("5a6e5L6L5qCH6K+G")},{field:__sfx("eGh0dHBQYXRo"),reason:__sfx("5a6e5L6L5qCH6K+G")},{field:"subDomain",reason:__sfx("5a6e5L6L5qCH6K+G")},{field:"addApi",reason:__sfx("VVJMIOWPr+iDveWQq+engeaciSB0b2tlbg==")},{field:"addCsv",reason:__sfx("VVJMIOWPr+iDveWQq+engeaciSB0b2tlbg==")}]});function lr(){return new Response(JSON.stringify({build:Dt,version:Lt,ts:Date.now()}),{status:200,headers:{"Content-Type":"application/json","Cache-Control":"no-store","Access-Control-Allow-Origin":"*"}})}var Dt,Lt,ur,Ft=U(()=>{"use strict";Dt="77d82aa-82ab544c",Lt=__sfx("MC4zMy42"),ur=__sfx("L19fY2ZwX3ZlcnNpb24=")});var pr={};hr(pr,{API_PREFIX:()=>Mt,getScannerToken:()=>Fo,handleApi:()=>Uo,pruneLoginFailures:()=>fr});function vo(t){return t.headers.get("CF-Connecting-IP")??t.headers.get("x-forwarded-for")?.split(",")[0]?.trim()??"unknown"}function Do(t,e){let n=pe.get(t);return n?e>=n.resetAt?(pe.delete(t),!1):n.count>=No:!1}function fr(t,e,n=ko){if(!(t.size<n)){for(let[r,o]of t)e>=o.resetAt&&t.delete(r);for(;t.size>=n;){let r=t.keys().next().value;if(r===void 0)break;t.delete(r)}}}function Lo(t,e){let n=pe.get(t);if(!n||e>=n.resetAt){fr(pe,e),pe.set(t,{count:1,resetAt:e+cr});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 S(t,e){return C({ok:!1,error:t},e)}async function Fo(t,e){let n=await t.get(et);if(n)return n;if(typeof e.SCANNER_TOKEN=="string"&&e.SCANNER_TOKEN)return e.SCANNER_TOKEN;let r=H(24);return await t.put(et,r),r}async function Uo(t,e,n){if(!e.pathname.startsWith(Mt))return null;let{store:r,env:o,config:s,auth:a}=n,i=e.pathname.slice(Mt.length)||"/",u=t.method.toUpperCase();if(i==="/session"&&u==="GET"){let c=await xt(r,t);return C(c?{ok:!0,authenticated:c,panelPath:a.panelPath}:{ok:!0,authenticated:c,hasSessionCookie:zn(t)})}if(i==="/login"&&u==="POST"){let c="";try{let m=await t.json();c=String(m.password??"")}catch{return S(__sfx("6K+35rGC5L2T6Kej5p6Q5aSx6LSl"),400)}if(!c)return S(__sfx("6K+36L6T5YWl5a+G56CB"),400);let l=vo(t),f=Date.now();if(Do(l,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(cr/1e3))}});let p=await Gn(a,c);if(!p.ok)return Lo(l,f),S(__sfx("5a+G56CB6ZSZ6K+v"),401);pe.delete(l),p.legacy&&await Kn(r,c).catch(()=>{}),await jn(r).catch(()=>{});let b=await Yn(r);return C({ok:!0},200,{"Set-Cookie":Vn(b)})}if(i==="/logout"&&u==="POST")return await Wn(r,t),C({ok:!0},200,{"Set-Cookie":Xn()});if(i==="/preferred-ips"&&u==="POST"){let c=t.headers.get("Authorization")??"",l=c.startsWith("Bearer ")?c.slice(7).trim():c.trim();if(!await Jn(r,l))return S(__sfx("VG9rZW4g5qCh6aqM5aSx6LSl"),401);let p;try{p=await t.json()}catch{return S(__sfx("6K+35rGC5L2T6Kej5p6Q5aSx6LSl"),400)}let m=(Array.isArray(p.ips)?p.ips.map(g=>String(g)):[]).map(g=>g.trim()).filter(g=>g.length>0),{valid:x,invalid:I}=mn(m),E=p.mode==="append",M=p.target==="relay",T=g=>g.split("#")[0].trim().replace(/^\[([^\]]+)\]:(\d+)$/,"$1:$2");if(x.length===0&&m.length>0)return S(__sfx("5rKh5pyJ5Y+v6K+G5Yir55qE5p2h55uu77yI5bey6Lez6L+HIA==")+I+" \u884C\uFF09",400);if(M){if(x.length===0)return S(__sfx("5rKh5pyJ5Y+v6K+G5Yir55qE5Y+N5Luj5YWl5Y+j"),400);let g=Io,y=x.slice(0,g),R=x.length-y.length,D=(s.relayPool??"").split(`
|
|
7
|
+
`))}function Sn(t,e){let n=ft(e.config.subName);switch(t){case __sfx("Y2xhc2g="):return{body:no(e),contentType:"text/yaml; charset=utf-8",fileName:n};case"singbox":return{body:ro(e),contentType:"application/json; charset=utf-8",fileName:n};default:return{body:oo(e),contentType:"text/plain; charset=utf-8",fileName:n}}}var te,Dr,Lr,on,sn,an,Fr,Ur,Mr,Zr,Qr,qr,ee,_r,pn,hn,$r,gn,Me=U(()=>{"use strict";Qt();W();rt();st();te=443;Dr=[__sfx("aXDlnLDlnYA="),__sfx("aXAg5Zyw5Z2A"),"ip",__sfx("5Zyw5Z2A"),__sfx("5pyN5Yqh5Zmo"),"server","host"],Lr=[__sfx("56uv5Y+j"),"port"],on=[__sfx("5LiL6L296YCf5bqm"),__sfx("6YCf5bqm"),"speed","download"],sn=[__sfx("5bmz5Z2H5bu26L+f"),__sfx("5bu26L+f"),"latency","delay",__sfx("5ZON5bqU5pe26Ze0"),"rtt"],an=["colo",__sfx("5py65oi/"),__sfx("5pWw5o2u5Lit5b+D"),__sfx("5Zyw5Yy6"),"region"],Fr=[__sfx("5Zu95a62"),"country",__sfx("5Zu95Yir")],Ur=[__sfx("5Z+O5biC"),"city"],Mr=["tls",__sfx("5piv5ZCm5pSv5oyBdGxz"),__sfx("5pSv5oyBdGxz")];Zr={official:__sfx("5a6Y5pa55LyY6YCJSVA="),domain:__sfx("5LyY6YCJ5Z+f5ZCN"),manual:__sfx("5LyY6YCJ"),api:__sfx("6L+c56iLQVBJ"),csv:__sfx("5rWL6YCfQ1NW")};Qr=12e4,qr=32,ee=new Map,_r="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36";pn=[__sfx("dmxlc3Mtd3M="),__sfx("dmxlc3MteGh0dHA="),__sfx("dHJvamFu")];hn=[__sfx("dmxlc3Mtd3M="),__sfx("dHJvamFu")];$r=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;gn=".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 po(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 On(t,e){let n=await crypto.subtle.importKey("raw",Rn.encode(t),{name:"HMAC",hash:"SHA-256"},!1,["sign"]),r=await crypto.subtle.sign("HMAC",n,Rn.encode(e));return po(new Uint8Array(r))}async function je(t){let e=(await t.get(Ke))?.trim();if(e)return e;if(!(t instanceof Z))return Ge();if(mt)return mt;let n=Date.now();if(Be===0&&(Be=n),n-Be<=go)return He||(He=Ge()),He;let r=Ge();return await t.put(Ke,r),Be=0,He=r,mt=r,r}async function In(t){let e=Ge();return t instanceof Z?await t.put(Ke,e):await t.put(Ke,e),e}async function Nn(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=`${ht}.${o.toString(36)}.${s}`,i=(await On(t,a)).slice(0,bt);return`${a}.${i}`}async function Ye(t,e,n=Date.now()){if(!t||!e)return{ok:!1,reason:"format"};let r=e.split(".");if(r.length!==4||r[0]!==ht)return{ok:!1,reason:"format"};let o=r[1],s=r[2],a=r[3];if(!o||!s||a.length!==bt)return{ok:!1,reason:"format"};let i=Number.parseInt(o,36);if(!Number.isFinite(i)||i<0)return{ok:!1,reason:"format"};let u=(await On(t,`${ht}.${o}.${s}`)).slice(0,bt);return X(a,u)?i>0&&Math.floor(n/1e3)>=i?{ok:!1,reason:"expired",exp:i}:{ok:!0,exp:i}:{ok:!1,reason:"signature"}}var Ke,ht,bt,Rn,Ge,mt,He,Be,go,yt=U(()=>{"use strict";Te();W();Ke="SUB_TOKEN_SECRET",ht="v1",bt=22,Rn=new TextEncoder;Ge=()=>H(32);mt=null,He=null,Be=0,go=9e4});function bo(t){let e="";for(let n of t)e+=(n<16?"0":"")+n.toString(16);return e}function yo(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 Un(t,e,n){let r=yo(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 bo(new Uint8Array(s))}function Mn(t){if(t.startsWith(`${Et}$`)){let[r,o,s,a]=t.split("$");if(r!==Et||!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 Hn(t,e){return t.scheme==="pbkdf2"?await Un(e,t.salt,t.iterations):await Qe(`${t.salt}:${e}`)}async function St(t,e){let n=await Un(t,e,Ln);return n?`${Et}$${Ln}$${e}$${n}`:`${e}:${await Qe(`${e}:${t}`)}`}async function wo(t,e){let n=Mn(t);if(!n)return!1;let r=await Hn(n,e);return r?X(r,n.expected):!1}function Fn(t){return`/${t.trim().replace(/^\/+/,"")}`}async function Bn(t,e,n){let r=await t.get(Ie)??"",o=n&&n.trim()?Fn(n):"";o?r!==o&&(r=o,await t.put(Ie,r)):r||(r=Fn(`${jt}-${Bt(6)}`),await t.put(Ie,r));let s=await t.get(me)??"",a=null,i=e&&e.trim()?e.trim():"";if(i){if(!s||!await wo(s,i)){let d=H(8);s=await St(i,d),await t.put(me,s)}await t.get(ie)&&await t.delete(ie)}else if(!s){let u=`cfp-${H(8)}`,d=H(8);s=await St(u,d),await t.put(me,s),a=u,await t.put(ie,u)}return{panelPath:r,passwordHash:s,generatedPassword:a}}async function Gn(t,e){let n=Mn(t.passwordHash);if(!n)return{ok:!1,legacy:!1};let r=await Hn(n,e);if(!r)return{ok:!1,legacy:!1};let o=X(r,n.expected);return{ok:o,legacy:o&&n.scheme==="sha256"}}async function Kn(t,e){let n=H(8);await t.put(me,await St(e,n))}async function jn(t){await t.get(ie)&&await t.delete(ie)}function Ct(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}function Po(t){for(let[e,n]of fe)n<=t&&fe.delete(e)}async function Yn(t){let e=H(24);await t.put(`${Oe}${e}`,JSON.stringify({ua:"",t:Date.now()}),Pt);let n=Date.now();return Po(n),fe.set(e,n+Pt*1e3),e}function zn(t){return!!Ct(t)[Se]}async function xt(t,e){let n=Ct(e)[Se];if(!n)return!1;let r=fe.get(n);if(r!==void 0){if(r>Date.now())return!0;fe.delete(n)}return!!await t.get(`${Oe}${n}`)}function Vn(t,e=Pt){return`${Se}=${t}; Path=/; HttpOnly; Secure; SameSite=Strict; Max-Age=${e}`}function Xn(){return`${Se}=; Path=/; HttpOnly; Secure; SameSite=Strict; Max-Age=0`}async function Wn(t,e){let n=Ct(e)[Se];n&&(fe.delete(n),await t.delete(`${Oe}${n}`))}async function Zn(t){let e=H(20);return await t.put(`${Re}${e}`,"1",ho),e}async function Jn(t,e){if(!e)return!1;let n=await t.get("SCANNER_TOKEN");return n&&X(n,e)?!0:await t.get(`${Re}${e}`)?(await t.delete(`${Re}${e}`),!0):!1}var Se,Pt,ho,Ln,Et,fe,At=U(()=>{"use strict";be();W();Se=__sfx("Y2ZwaWxvdF9zZXNz"),Pt=3600*24,ho=600,Ln=3e4,Et="pbkdf2";fe=new Map});function Qn(t){return Kt(t)}async function Tt(t,e){if(j.config&&Date.now()-j.configAt<Eo)return j.config;let n=await Vt(t,e);return j.config=n,j.configAt=Date.now(),n}function qn(){j.config=null,j.configAt=0}async function Rt(t,e){if(j.auth&&Date.now()-j.authAt<So)return j.auth;let n=await Bn(t,e.PANEL_PASSWORD,e.PANEL_PATH);return j.auth=n,j.authAt=Date.now(),n}function Ot(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 Ce(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 _n(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,So,j,Ve=U(()=>{"use strict";Te();be();At();Eo=15e3,So=6e4,j={config:null,configAt:0,auth:null,authAt:0}});function Nt(t){let e=[];if(t.split(/\r?\n/).forEach((s,a)=>{let i=s.trim();if(!i)return;let u=i.replace(/^["']|["']$/g,"").trim();!u||u.startsWith("#")||ne(i)===null&&e.push(a+1)}),e.length===0)return"";let r=e.slice(0,3).map(s=>`\u7B2C ${s} \u884C`).join("\u3001"),o=e.length>3?` \u7B49 ${e.length} \u884C`:"";return __sfx("5omL5Yqo5oyH5a6aIElQIOaciSA=")+e.length+__sfx("IOihjOaXoOazleivhuWIq++8iA==")+r+""+o+")"}function It(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 re(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 Xe(t,e,n,r=Ao){let o=t.split(/\r?\n|,/).map(s=>s.trim()).filter(Boolean);if(o.length>r){n.push({field:e,message:""+e+__sfx("IOacgOWkmiA=")+r+__sfx("IOadoe+8iOW9k+WJjSA=")+o.length+")"});return}for(let s of o)if(!xo.test(s)){n.push({field:e,message:""+e+__sfx("IOmHjOacieaXoOazleivhuWIq+eahOadoeebru+8mg==")+s.slice(0,40)+""});return}}function er(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 Ro(t,e,n){let r=t.split(/\r?\n/).map(s=>s.trim()).filter(Boolean);if(r.length>$n){n.push({field:e,message:""+e+__sfx("IOacgOWkmiA=")+$n+__sfx("IOadoe+8iOW9k+WJjSA=")+r.length+")"});return}let o=Nt(t);o&&n.push({field:e,message:o})}function kt(t){let e=[],n=o=>Object.prototype.hasOwnProperty.call(t,o);n("wsPath")&&It(String(t.wsPath??""),"wsPath",e),n(__sfx("dHJvamFuUGF0aA=="))&&It(String(t.trojanPath??""),__sfx("dHJvamFuUGF0aA=="),e),n(__sfx("eGh0dHBQYXRo"))&&It(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&&(!Co.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=="))&&Xe(String(t.proxyIp??""),__sfx("cHJveHlJcA=="),e),n(__sfx("c29ja3M1"))&&Xe(String(t.socks5??""),__sfx("c29ja3M1"),e),n("httpProxy")&&Xe(String(t.httpProxy??""),"httpProxy",e),n("relayPool")&&Xe(String(t.relayPool??""),"relayPool",e,To),n("officialCount")&&re(Number(t.officialCount),"officialCount",1,200,e),n("domainCount")&&re(Number(t.domainCount),"domainCount",1,200,e),n("maxNodes")&&re(Number(t.maxNodes),"maxNodes",0,500,e),n("dls")&&re(Number(t.dls),"dls",0,1e3,e),n("maxLatency")&&re(Number(t.maxLatency),"maxLatency",0,1e4,e),n("dataBudgetMB")&&re(Number(t.dataBudgetMB),"dataBudgetMB",0,102400,e),n("subTokenTtlDays")&&re(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")&&er(String(t.addApi??""),"addApi",e),n("addCsv")&&er(String(t.addCsv??""),"addCsv",e),n("add")&&Ro(String(t.add??""),"add",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 vt(t){return t.length===0?"":t.length===1?t[0].message:"有 "+t.length+__sfx("IOmhuemFjee9ruS4jeWQiOazle+8mg==")+t.map(e=>e.message).join("\uFF1B")+""}var Co,xo,Ao,To,$n,tr=U(()=>{"use strict";Me();Co=/^(?=.{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])?)*$/;xo=/^(?:(?:socks5|socks|socks5h|http|https):\/\/)?(?:[^\s@/]+@)?(?:\[[0-9a-fA-F:]+\]|[A-Za-z0-9._-]+)(?::\d{1,5})?$/;Ao=20,To=200,$n=2e3});function or(t,e=Date.now()){let n={};for(let o of rr){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 sr(t){let e=new Set([...rr.map(String),__sfx("c29ja3M1"),"httpProxy"]),n={};for(let[r,o]of Object.entries(t))e.has(r)&&(n[r]=o);return n}function nr(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 ir(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:nr(s),to:nr(o)})}return n}var rr,Oo,ar=U(()=>{"use strict";rr=["poolOfficial","officialCount","poolDomain","domainCount","poolManual","poolCountries","add","dls","maxLatency","maxNodes",__sfx("cHJveHlJcA=="),"relayPool","useBuiltinRelay","proxyMode","nat64","concurrentDial","dataBudgetMB","resolvePreferred","aggressiveRedial",__sfx("ZW5hYmxlVHJvamFu"),__sfx("ZW5hYmxlWGh0dHA="),"subProtocol","subTransport","subVariants","subName","subPorts","clientFingerprint","ech","echHost","echDns","tlsFragment","tlsFragmentSize","tlsFragmentDelay","subToken","subTokenTtlDays","unlockProbe","udpDns","udpDnsEndpoint"],Oo=[{field:"uuid",reason:__sfx("5YWl56uZ5Yet5o2u")},{field:__sfx("dHJvamFuUGFzc3dvcmQ="),reason:__sfx("5YWl56uZ5Yet5o2u")},{field:"wsPath",reason:__sfx("5a6e5L6L5qCH6K+G77yI6K6i6ZiF6ZO+5o6l6YeM5Y+v6KeB77yM5a+85Ye65Y2z5pq06Zyy5YWl5Y+j77yJ")},{field:__sfx("dHJvamFuUGF0aA=="),reason:__sfx("5a6e5L6L5qCH6K+G")},{field:__sfx("eGh0dHBQYXRo"),reason:__sfx("5a6e5L6L5qCH6K+G")},{field:"subDomain",reason:__sfx("5a6e5L6L5qCH6K+G")},{field:"addApi",reason:__sfx("VVJMIOWPr+iDveWQq+engeaciSB0b2tlbg==")},{field:"addCsv",reason:__sfx("VVJMIOWPr+iDveWQq+engeaciSB0b2tlbg==")}]});function lr(){return new Response(JSON.stringify({build:Dt,version:Lt,ts:Date.now()}),{status:200,headers:{"Content-Type":"application/json","Cache-Control":"no-store","Access-Control-Allow-Origin":"*"}})}var Dt,Lt,ur,Ft=U(()=>{"use strict";Dt="daf280f-82ab544c",Lt=__sfx("MC4zMy43"),ur=__sfx("L19fY2ZwX3ZlcnNpb24=")});var pr={};hr(pr,{API_PREFIX:()=>Mt,getScannerToken:()=>Fo,handleApi:()=>Uo,pruneLoginFailures:()=>fr});function vo(t){return t.headers.get("CF-Connecting-IP")??t.headers.get("x-forwarded-for")?.split(",")[0]?.trim()??"unknown"}function Do(t,e){let n=pe.get(t);return n?e>=n.resetAt?(pe.delete(t),!1):n.count>=No:!1}function fr(t,e,n=ko){if(!(t.size<n)){for(let[r,o]of t)e>=o.resetAt&&t.delete(r);for(;t.size>=n;){let r=t.keys().next().value;if(r===void 0)break;t.delete(r)}}}function Lo(t,e){let n=pe.get(t);if(!n||e>=n.resetAt){fr(pe,e),pe.set(t,{count:1,resetAt:e+cr});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 S(t,e){return C({ok:!1,error:t},e)}async function Fo(t,e){let n=await t.get(et);if(n)return n;if(typeof e.SCANNER_TOKEN=="string"&&e.SCANNER_TOKEN)return e.SCANNER_TOKEN;let r=H(24);return await t.put(et,r),r}async function Uo(t,e,n){if(!e.pathname.startsWith(Mt))return null;let{store:r,env:o,config:s,auth:a}=n,i=e.pathname.slice(Mt.length)||"/",u=t.method.toUpperCase();if(i==="/session"&&u==="GET"){let c=await xt(r,t);return C(c?{ok:!0,authenticated:c,panelPath:a.panelPath}:{ok:!0,authenticated:c,hasSessionCookie:zn(t)})}if(i==="/login"&&u==="POST"){let c="";try{let m=await t.json();c=String(m.password??"")}catch{return S(__sfx("6K+35rGC5L2T6Kej5p6Q5aSx6LSl"),400)}if(!c)return S(__sfx("6K+36L6T5YWl5a+G56CB"),400);let l=vo(t),f=Date.now();if(Do(l,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(cr/1e3))}});let p=await Gn(a,c);if(!p.ok)return Lo(l,f),S(__sfx("5a+G56CB6ZSZ6K+v"),401);pe.delete(l),p.legacy&&await Kn(r,c).catch(()=>{}),await jn(r).catch(()=>{});let b=await Yn(r);return C({ok:!0},200,{"Set-Cookie":Vn(b)})}if(i==="/logout"&&u==="POST")return await Wn(r,t),C({ok:!0},200,{"Set-Cookie":Xn()});if(i==="/preferred-ips"&&u==="POST"){let c=t.headers.get("Authorization")??"",l=c.startsWith("Bearer ")?c.slice(7).trim():c.trim();if(!await Jn(r,l))return S(__sfx("VG9rZW4g5qCh6aqM5aSx6LSl"),401);let p;try{p=await t.json()}catch{return S(__sfx("6K+35rGC5L2T6Kej5p6Q5aSx6LSl"),400)}let m=(Array.isArray(p.ips)?p.ips.map(g=>String(g)):[]).map(g=>g.trim()).filter(g=>g.length>0),{valid:x,invalid:I}=mn(m),E=p.mode==="append",M=p.target==="relay",T=g=>g.split("#")[0].trim().replace(/^\[([^\]]+)\]:(\d+)$/,"$1:$2");if(x.length===0&&m.length>0)return S(__sfx("5rKh5pyJ5Y+v6K+G5Yir55qE5p2h55uu77yI5bey6Lez6L+HIA==")+I+" \u884C\uFF09",400);if(M){if(x.length===0)return S(__sfx("5rKh5pyJ5Y+v6K+G5Yir55qE5Y+N5Luj5YWl5Y+j"),400);let g=Io,y=x.slice(0,g),R=x.length-y.length,D=(s.relayPool??"").split(`
|
|
8
8
|
`).map(O=>O.trim()).filter(Boolean),Y,xe=y.length;if(E){let O=new Set(D.map(T)),k=y.filter(Ae=>{let L=T(Ae);return O.has(L)?!1:(O.add(L),!0)});xe=k.length,Y=[...D,...k]}else Y=y;Y.length>g&&(Y=Y.slice(0,g));let We=await Xt(r,s);return await ue(r,ae(We,{relayPool:Y.join(`
|
|
9
9
|
`)})),n.onConfigChanged(),C({ok:!0,target:"relay",mode:E?"append":"replace",count:y.length,added:xe,invalid:I,overLimit:R,limit:g})}let N=await r.get(V),P,h=x.length;if(E){let g=(N??"").split(`
|
|
10
10
|
`).map(D=>D.trim()).filter(D=>D.length>0),y=new Set(g.map(T)),R=x.filter(D=>{let Y=T(D);return y.has(Y)?!1:(y.add(Y),!0)});h=R.length,P=[...g,...R].join(`
|
package/assets/dataplane.js
CHANGED
|
@@ -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 u=Date.now()+mt,c="";for(;;){let x=s.peek(),T=co(x);if(T>=0){c=new TextDecoder().decode(x.subarray(0,T)),s.skip(T+4);break}if(x.byteLength>8192)throw new Error(__sfx("SFRUUCDku6PnkIblk43lupTlpLTotoXov4cgODE5MiDlrZfoioI="));let p=u-Date.now();if(p<=0)throw new Error(__sfx("SFRUUCDku6PnkIbmj6HmiYvotoXml7bvvIg=")+mt+__sfx("bXMg5peg5ZON5bqU77yJ"));let R=null,E;try{E=await Promise.race([s.fill(),new Promise(k=>{R=setTimeout(()=>k("timeout"),p)})])}finally{R&&clearTimeout(R)}if(E==="timeout")throw new Error(__sfx("SFRUUCDku6PnkIbmj6HmiYvotoXml7bvvIg=")+mt+__sfx("bXMg5peg5ZON5bqU77yJ"));if(E===null)throw new Error(__sfx("SFRUUCDku6PnkIblk43lupTkuI3lrozmlbTvvIjov57mjqXooqvmj5DliY3lhbPpl63vvIk="))}let g=c.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 re(__sfx("SFRUUCDku6PnkIYgQ09OTkVDVCDlpLHotKXvvJo=")+y[1]+"");return s.release()}finally{try{i.releaseLock()}catch{}}}var uo,mt,Cn=S(()=>{"use strict";X();we();He();uo=[13,10,13,10];mt=6e3});function gt(e){if(e instanceof le||(e instanceof Error?e.message:String(e)).includes(kn))return!0;let n=e instanceof Error?e.cause:void 0;return n!==void 0&&n!==e&>(n)}function vn(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 Be(e){let t=vn(e);if(t===null)return null;for(let[n,o,r,s]of fo){let i=vn(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 ht(e){let t=e[6]??0,n=e[7]??0;return`${t>>>8}.${t&255}.${n>>>8}.${n&255}`}function po(e){let t=(e.split("%")[0]??"").toLowerCase();if(!t.includes(":"))return null;let n=ye(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 Be(ht(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 Be(ht(n))??null;if(n[0]===100&&n[1]===65435&&n[2]===0&&n[3]===0&&n[4]===0&&n[5]===0){let s=Be(ht(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 yt(e){let t=e.trim().toLowerCase().replace(/^\[|\]$/g,"");if(t==="")return null;if(t.includes(":"))return po(t);if(/^\d{1,3}(?:\.\d{1,3}){3}$/.test(t))return Be(t);if(t==="localhost"||t.endsWith(".localhost"))return{kind:"loopback",reason:__sfx("546v5Zue5Li75py65ZCN")};for(let n of mo)if(t.endsWith(n))return{kind:"internal-name",reason:__sfx("5YaF572R5Z+f5ZCN5ZCO57yA")};return null}var kn,In,le,fo,mo,bt=S(()=>{"use strict";X();kn=__sfx("55uu5qCH5Zyw5Z2A6KKr562W55Wl5oum5oiq"),In={kind:"ipv6-direct-unsupported",reason:__sfx("55u06L+e5LiO5Y+N5Luj6YCa6YGT5LiN5pSv5oyBIElQdjYg55uu5qCH77yM5Y+v5pS555So6JC95Zyw5Luj55CG6L2s5Y+R")},le=class extends Error{kind;constructor(t,n){super(`${kn}\uFF1A${t}\uFF08${n.reason}\uFF09`),this.name="TargetBlockedError",this.kind=n.kind}};fo=[[__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")]];mo=[".local",".internal"]});function yo(e){return/^\d{1,3}(\.\d{1,3}){3}$/.test(e)?!0:e.includes(":")&&/^[0-9a-fA-F:.]+$/.test(e)}function wt(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 bo(e,t,n,o=Nn){try{let r=`${e}?name=${encodeURIComponent(t)}&type=${n}`,s=await fetch(r,{headers:{accept:"application/dns-json"},signal:AbortSignal.timeout(o)});if(!s.ok)return null;let i=await s.json();if(!i||i.Status!==0&&i.Status!==3)return null;if(!Array.isArray(i.Answer))return[];let a=n==="TXT"?16:n==="A"?1:28;return i.Answer.filter(l=>l.type===a).map(l=>String(l.data))}catch{return null}}async function Dn(e,t,n={}){for(let o of ho){if(n.deadline!==void 0&&Date.now()>=n.deadline)break;let r=n.timeoutMs??Nn,s=n.deadline!==void 0?n.deadline-Date.now():Number[__sfx("UE9TSVRJVkVfSU5GSU5JVFk=")],i=Math.max(50,Math.min(r,s)),a=await bo(o,e,t,i);if(a!==null)return a}return[]}function wo(e,t){let n=[],o=String(e).replace(/^"|"$/g,"").replace(/\\010/g,",").replace(/\\n/g,",").trim();if(!o||o===On)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}=wt(i,t);if(!H(a)&&!te(a))return[];n.push({hostname:a,port:l})}return n}async function Fe(e,t,n={}){let o=e.trim();if(!o)return[];if(yo(o))return[{hostname:o,port:t}];let r=`${o}:${t}`,s=_.get(r);if(s&&Date.now()-s.at<Un)return _.delete(r),_.set(r,s),s.ips;let i=[],[a,l]=await Promise.all([n.skipTxt?Promise.resolve([]):Dn(o,"TXT",n),Dn(o,"A",n)]);if(!n.skipTxt)for(let c of a){let d=wo(c,t);if(d.length>0){i.push(...d);break}if(String(c).replace(/^"|"$/g,"").replace(/\\010/g,",").trim()===On)break}if(i.length===0)for(let c of l)H(c)&&i.push({hostname:c,port:t});let f=[],u=new Set;for(let c of i){let d=`${c.hostname}:${c.port}`;u.has(d)||(u.add(d),f.push(c))}if(f.length>0){let c=Date.now();for(let[d,g]of _)c-g.at>=Un&&_.delete(d);for(;_.size>=go;){let d=_.keys().next().value;if(d===void 0)break;_.delete(d)}_.set(r,{at:c,ips:f})}return f}var On,ho,Nn,Un,go,_,Ke=S(()=>{"use strict";X();On=__sfx("QGVkZ2V0dW5uZWw="),ho=["https://cloudflare-dns.com/dns-query","https://dns.google/resolve","https://dns.alidns.com/resolve","https://doh.pub/dns-query"],Nn=4e3,Un=300*1e3,go=1e3,_=new Map});var St={};ve(St,{[__sfx("QlVJTFRJTl9SRUxBWV9ET01BSU5T")]:()=>Ln,[__sfx("Q09MT19UT19DT1VOVFJZ")]:()=>Mn,[__sfx("UkVMQVlfQkFUQ0hfU0laRQ==")]:()=>Xe,[__sfx("UkVMQVlfRE9NQUlOX0xJTUlU")]:()=>Pt,clearRelayCache:()=>Eo,collectRelayEndpoints:()=>xe,coloToCountry:()=>xo,relayCacheSize:()=>Ao,resolveRelayEntry:()=>xt,selectRelayDomains:()=>Fn});function xo(e){let t=String(e??"").toUpperCase();return t?Mn[t]??(/^[A-Z]{2}$/.test(t)?t:"US"):"US"}function So(e){for(let[t,n]of J)e-n.at>=Bn&&J.delete(t);for(;J.size>=Po;){let t=J.keys().next().value;if(t===void 0)break;J.delete(t)}}async function xt(e,t=443,n=Hn,o={}){let r=e.trim();if(!r)return[];let s=`${r}:${t}:${n}`,i=J.get(s);if(i&&Date.now()-i.at<Bn)return i.ips;let a=r,l=t,f=(r.match(/:/g)??[]).length;if(f===1){let c=/^(.*):(\d{1,5})$/.exec(r);c&&(a=c[1],l=Number(c[2]))}else if(f>1&&r.startsWith("[")){let c=/^\[([^\]]+)\]:(\d{1,5})$/.exec(r);c&&(a=c[1],l=Number(c[2]))}let u=[];if(H(a)||te(a))u=[{ip:a,port:Number.isInteger(l)&&l>0?l:t,label:r}];else try{u=(await Fe(a,l,{skipTxt:o.skipTxt,deadline:o.deadline,timeoutMs:o.timeoutMs})).slice(0,n).map(d=>({ip:d.hostname,port:d.port,label:`${a} \u2192 ${d.hostname}`}))}catch{u=[]}if(u.length>0){let c=Date.now();So(c),J.set(s,{at:c,ips:u})}return u}function Fn(e=Pt,t=Ln){return t.slice(0,Math.max(0,e))}async function xe(e={}){let t=e.perDomain??Hn,n=[],o=new Set,r=d=>{for(let g of d){let y=`${g.ip}:${g.port}`;o.has(y)||(o.add(y),n.push(g))}},s=(e.userEntries??"").trim(),i=s?s.split(/[\n,;]+/).map(d=>d.trim()).filter(Boolean):[],a=e.domainLimit??Pt,l=e.useBuiltin!==!1?Fn(a):[],f=await Promise.all([...i.map(d=>xt(d,443,t,{deadline:e.deadline,timeoutMs:e.timeoutMs})),...l.map(d=>xt(d,443,t,{skipTxt:!0,deadline:e.deadline,timeoutMs:e.timeoutMs}))]);for(let d=0;d<i.length;d++)r(f[d]);let u=f.slice(i.length),c=u.reduce((d,g)=>Math.max(d,g.length),0);for(let d=0;d<c;d++)for(let g of u)d<g.length&&r([g[d]]);return n}function Eo(){J.clear()}function Ao(){return J.size}var Ln,Mn,Hn,Xe,Pt,Bn,Po,J,Pe=S(()=>{"use strict";X();Ke();Ln=[__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")],Mn={[__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"};Hn=4,Xe=6,Pt=6,Bn=30*1e3,Po=256,J=new Map});function Et(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 Kn(e){return e.map(([t,n])=>{let o=Et(t)??0,r=n===0?0:4294967295<<32-n>>>0;return[(o&r)>>>0,r]})}function Xn(e){let t=Et(e);if(t===null)return!1;for(let[n,o]of Io)if((t&o)>>>0===n)return!0;return!1}function se(e){let t=Et(e);if(t===null)return!1;for(let[n,o]of ko)if((t&o)>>>0===n)return!0;return!1}function Gn(e){let t=[],n=new Set,o=u=>{let c=`${u.source}|${u.host}|${u.port}`;n.has(c)||(n.add(c),t.push(u))};for(let u of e.proxies??[])u.kind==="direct"?o({source:"proxy",host:u.host,port:u.port,label:__sfx("UHJveHlJUCA=")+u.host+":"+u.port+"",via:{kind:"direct",host:u.host,port:u.port}}):o({source:"proxy",host:u.host,port:u.port,label:`${u.kind.toUpperCase()} ${u.host}:${u.port}`,via:{kind:u.kind,host:u.host,port:u.port,username:u.username,password:u.password,serverName:u.serverName}});let s=se(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(u=>!se(u.ip)),l=i.filter(u=>se(u.ip));for(let u of a)o({source:"optimized",host:u.ip,port:u.port,label:__sfx("5LyY6YCJIA==")+u.ip+":"+u.port+""});for(let u of l)o({source:"optimized",host:u.ip,port:u.port,label:__sfx("5LyY6YCJIA==")+u.ip+":"+u.port+__sfx("77yIQ2xvdWRmbGFyZSDnvZHmrrXvvIzlj6/og73kuI3lj6/ovr7vvIk="),deprioritized:!0});let f=e.relay??[];for(let u of f)o({source:"relay",host:u.ip,port:u.port,label:__sfx("5Y+N5LujIA==")+u.label+"",deprioritized:!0});return t.map((u,c)=>({candidate:u,index:c})).sort((u,c)=>{let d=+!!u.candidate.deprioritized-+!!c.candidate.deprioritized;return d!==0?d:u.index-c.index}).map(u=>u.candidate)}function Wn(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 Vn(e,t){let n=e instanceof Error?e.message:String(e);return gt(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 zn(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 To,Ro,Co,vo,ko,Io,At=S(()=>{"use strict";bt();To=[[__sfx("MTAzLjIxLjI0NC4w"),22],[__sfx("MTAzLjIyLjIwMC4w"),22],[__sfx("MTAzLjMxLjQuMA=="),22],[__sfx("MTA0LjE2LjAuMA=="),13],[__sfx("MTA0LjI0LjAuMA=="),14],[__sfx("MTA4LjE2Mi4xOTIuMA=="),18],[__sfx("MTMxLjAuNzIuMA=="),22],[__sfx("MTQxLjEwMS42NC4w"),18],[__sfx("MTYyLjE1OC4wLjA="),15],[__sfx("MTcyLjY0LjAuMA=="),13],[__sfx("MTczLjI0NS40OC4w"),20],[__sfx("MTg4LjExNC45Ni4w"),20],[__sfx("MTkwLjkzLjI0MC4w"),20],[__sfx("MTk3LjIzNC4yNDAuMA=="),22],[__sfx("MTk4LjQxLjEyOC4w"),17]],Ro=[[__sfx("MTA0LjMxLjAuMA=="),15],[__sfx("MTkyLjAuMC4w"),24],[__sfx("MTkyLjAuMi4w"),24],[__sfx("MTkyLjg4Ljk5LjA="),24],[__sfx("MTk5LjI3LjEyOC4w"),21],[__sfx("MS4wLjAuMA=="),24],[__sfx("MS4xLjEuMA=="),24]],Co=[[__sfx("MjIzLjUuNS4w"),24]],vo=[...To,...Ro];ko=Kn(vo),Io=Kn(Co)});function Yn(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 d=s[1].toLowerCase();r=n.slice(s[0].length),d===__sfx("c29ja3M1")||d===__sfx("c29ja3M=")||d===__sfx("c29ja3M1aA==")?o=__sfx("c29ja3M1"):d==="https"?o="https":d==="http"&&(o="http")}let i=r.lastIndexOf("@"),a={};if(i>=0){let d=r.slice(0,i);r=r.slice(i+1);let g=d.indexOf(":");g>=0?a={username:d.slice(0,g),password:d.slice(g+1)}:a={username:d}}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:u,port:c}=wt(r,0);return!u||!Number.isInteger(c)||c<=0||c>65535?null:(!l&&o==="https"&&!Uo(u)&&(l=u),{host:u,port:c,kind:o,...a,...l?{serverName:l}:{}})}function Uo(e){return/^\d{1,3}(\.\d{1,3}){3}$/.test(e)}function Se(e,t="direct"){let n=[];for(let o of e.split(/[\n,;]+/)){let r=o.trim();if(!r)continue;let s=Yn(r,t);s&&n.push(s)}return n}var Tt=S(()=>{"use strict";Ke()});async function Do(){return Rt||(Rt=(async()=>(await import("cloudflare:sockets")).connect)()),await Rt}function No(e,t){if(!H(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 Ge(e,t,n,o,r){let i=(await Do())({hostname:e,port:t},o?{secureTransport:o}:void 0),a=async(f,u)=>{let c,d=new Promise((g,y)=>{c=setTimeout(()=>y(new Error(""+u+__sfx("6LaF5pe277ya")+e+":"+t+"")),n)});try{return await Promise.race([f,d])}finally{c&&clearTimeout(c)}},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 Lo(e){let t=e.timeoutMs??kt;try{let n=await Ge(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&&H(e.hostname)){let o=No(e.hostname,e.nat64);if(o){let r=await Ge(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 Mo(e){return e.includes(":")}function Ho(e){return e.source==="proxy"&&e.via!==void 0&&e.via.kind!=="direct"}async function Bo(e,t){let n=e.timeoutMs??kt;if(t.kind==="direct"){let s=await Ge(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 Ge(t.host,t.port,n,o,t.kind==="https"?t.serverName:void 0);try{return t.kind==="http"||t.kind==="https"?{readable:await Rn(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 An(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 Zn(e){return e instanceof Error?e.message:typeof e=="string"?e:String(e)}function Ko(e){if(e.length===0)return __sfx("5pyq55+l5Y6f5Zug");let t=e.map(Zn),n=t.slice(-Fo),o=t.length-n.length;return`${o>0?`\uFF08\u5171 ${t.length} \u6761\uFF0C\u7701\u7565\u524D ${o} \u6761\uFF09`:""}${n.join("\uFF1B")}`}function Xo(e){return e.length===0?Promise.reject(new Error(__sfx("5rKh5pyJ5Y+v55So55qE5Ye656uZ5ouo5Y+35pa55byP"))):new Promise((t,n)=>{let o=e.length,r=!1,s=[];for(let i of e)i().then(a=>{if(r){try{let l=a.close;Promise.resolve(l?l():a.writable.close()).catch(()=>{})}catch{}return}r=!0,t(a)},a=>{s.push(a),o-=1,o===0&&!r&&(r=!0,n(new Error(__sfx("5pys5om5IA==")+e.length+__sfx("IOS4quWAmemAieWFqOmDqOWksei0pe+8mg==")+Ko(s)+"")))})})}async function vt(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+=Ct){let i=e.slice(s,s+Ct);try{return await Xo(i)}catch(a){o=a,n.push(Zn(a))}}throw new Error(__sfx("5YWo6YOoIA==")+e.length+__sfx("IOS4quWAmemAieWdh+Wksei0pe+8iOWIhiA=")+n.length+__sfx("IOaJue+8jOavj+aJueacgOWkmiA=")+Ct+__sfx("IOS4quW5tuWPke+8ie+8mgo=")+n.join(`
|
|
4
4
|
`),{cause:o})}async function jn(e,t){let n=[...e];if(!t)return n;try{let o=await xe(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 Go(e,t,n){if(e.length===0)return null;for(let o=0;o<e.length;o+=Xe){let s=e.slice(o,o+Xe).map(i=>t({source:"relay",host:i.ip,port:i.port,label:__sfx("5Y+N5LujIA==")+i.label+""}));try{return await vt(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=yt(e.hostname);if(h)throw new le(e.hostname,h)}let o=e.budgetMs??Oo,r=Date.now()+o,s=[...e.optimizedIps??[]],i=!1;if(e.resolvePreferred)try{let h=await Fe(e.hostname,e.port,{deadline:r});if(h.length>0){i=!0;for(let w of h)s.push({ip:w.hostname,port:w.port})}}catch{}let a=se(e.hostname),l=i&&s.length>0&&s.every(h=>se(h.ip)),f=[...e.relay??[]];(l||a)&&e.relayPool&&(f=await jn(f,{...e.relayPool,deadline:r}));let c=f,d=Gn({targetHost:e.hostname,targetPort:e.port,optimizedIps:s,proxies:t,deprioritizeDirect:a,relay:[]});if(d.length===0)throw new Error(__sfx("5rKh5pyJ5Y+v55So55qE5Ye656uZ5ouo5Y+35pa55byP"));let g=h=>async()=>{let w=r-Date.now();if(w<=0)throw new Error(__sfx("5ouo5Y+36aKE566X5bey55So5bC977yI")+o+"ms):"+e.hostname+":"+e.port+"");let v=Math.max(200,Math.min(e.timeoutMs??kt,w)),j={...e,timeoutMs:v};try{if(!Ho(h)&&Mo(e.hostname))throw new le(e.hostname,In);if(!e.skipTargetPolicy&&h.source!=="proxy"&&h.source!=="relay"){let O=yt(h.host);if(O)throw new le(h.host,O)}if(h.source==="proxy"&&h.via)try{let O=await Bo(j,{host:h.via.host,port:h.via.port,kind:h.via.kind,username:h.via.username,password:h.via.password,serverName:h.via.serverName});return En(h.via),O}catch(O){throw O instanceof re||Sn(h.via,Date.now()),O}return await Lo({...j,hostname:h.host,port:h.port})}catch(O){let Z=Vn(O,h.label);throw e.onFailure?.(Z),O}},y=Wn(d),{landing:x,[__sfx("cHJveHlJcA==")]:T,direct:p,fallback:R}=y,E=x.length>0||T.length>0,k=async()=>{if(x.length===0)throw new Error(__sfx("5pyq6YWN572u6JC95Zyw5Luj55CG"));let h,w=pt(x,v=>v.via,Date.now());for(let v of w)try{return await g(v)()}catch(j){h=j}throw h??new Error(__sfx("6JC95Zyw5Luj55CG5YWo6YOo5aSx6LSl"))},K=async()=>{if(T.length===0)throw new Error(__sfx("5pyq6YWN572uIFByb3h5SVA="));let h=Date.now(),w=pt(T,v=>v.via,h);return await vt(w.map(g),!0)},q=async()=>{let h;if(x.length>0)try{return await k()}catch(w){h=w}if(T.length>0)try{return await K()}catch(w){h=w}throw h??new Error(__sfx("5rKh5pyJ5Y+v55So55qE5Luj55CG"))},N=async()=>await vt(p.map(g),n),Y=async()=>{let h=c;return h.length===0&&e.relayPool&&(h=await jn([],{...e.relayPool,deadline:r})),await Go(h,g,n)},$=async()=>{for(let h of R)try{return await g(h)()}catch{}return null};if(!E)try{return await N()}catch(h){let w=await Y();if(w)return w;let v=await $();if(v)return v;throw h}let ie=e.proxyMode??"only",U=a||l;if(ie==="only")try{return await q()}catch(h){let w=await Y();if(w)return w;let v=await $();if(v)return v;throw h}if(ie==="global"||ie==="smart"&&U)try{return await q()}catch(h){if(ie==="global")try{return await N()}catch{}let w=await Y();if(w)return w;let v=await $();if(v)return v;throw h}try{return await N()}catch(h){try{return await q()}catch{}let w=await Y();if(w)return w;let v=await $();if(v)return v;throw h}}var Rt,kt,Oo,Ct,Fo,It=S(()=>{"use strict";Tn();Cn();bt();He();X();Ke();Pe();At();Tt();Rt=null;kt=8e3,Oo=15e3;Ct=6,Fo=8});async function _n(e,t,n,o=!0,r,s){let i=e.getReader(),a=t.getWriter();try{for(;!n?.exhausted;){let l;try{l=await i.read()}catch(u){s?.(u,"read");break}if(l.done)break;let f=l.value;if(!(!f||f.byteLength===0)){if(r?.(f.byteLength))break;try{await a.write(f)}catch(u){s?.(u,"write");break}}}}finally{if(o)try{await a.close()}catch{}else try{a.releaseLock()}catch{}try{i.releaseLock()}catch{}}}var ue,We=S(()=>{"use strict";ue=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 nr={};ve(nr,{diagnosticCounters:()=>zo,[__sfx("aGFuZGxlV2ViU29ja2V0")]:()=>je,recentDiagnostics:()=>jo,recentRoutes:()=>Yo,recordDiagnostics:()=>Q,truncateCloseReason:()=>tr});function tr(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 zo(){return{...de}}function Yo(){return Ye}function er(e,t,n){Ye.unshift({at:Date.now(),target:e,via:t.via,endpoint:t.endpoint,cfTarget:se(e.split(":")[0]??""),publicDns:Xn(e.split(":")[0]??""),phase:n}),Ye.length>20&&(Ye.length=20)}function Q(e,t,n){ze.unshift({at:Date.now(),target:e,failures:t,summary:n}),ze.length>$n&&(ze.length=$n)}function jo(){return ze}function Jo(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 je(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=Jo(e.headers.get(__sfx("c2VjLXdlYnNvY2tldC1wcm90b2NvbA=="))),f=[],u=0,c=!1,d=null,g=null,y=new Le,x=null,T=null,p=()=>{T&&(clearTimeout(T),T=null)},R=!1,E=new Ne,k=null,K=!1,q=!1,N=null,Y=null,$=m=>{try{a.send(m)}catch{}},ie=m=>{let b=new Uint8Array(2+m.byteLength);b[0]=0,b[1]=m.byteLength,b.set(m,2),$(b)},U=(m,b)=>{K=!0;try{a.close(m,tr(b))}catch{}h()},h=()=>{if(!q){if(q=!0,zt(),f=[],u=0,p(),x&&(clearTimeout(x),x=null),w&&(clearTimeout(w),w=null),k){let m=k;k=null;try{m.cancel()}catch{}}if(d){let m=d.close;if(m)try{m()}catch{}else try{d.writable.close()}catch{}}}},w=null,v=new Set,j=0,O=[],Z=0,et=m=>{if(!(m.byteLength===0||ae>0)){if(Z+m.byteLength>qn){U(1009,__sfx("5pyq56Gu6K6k6YCa6Lev55qE5LiK6KGM5pWw5o2u6L+H5aSa"));return}if(Ve+m.byteLength>Vo){U(1009,__sfx("5a6e5L6L5YaF5a2Y6aKE566X5bey5ruh77yM6K+36YeN6K+V"));return}O.push(m),Z+=m.byteLength,Ve+=m.byteLength}},zt=()=>{Ve=Math.max(0,Ve-Z),O=[],Z=0},tt=0,Ur=()=>{tt+=1},Yt=async()=>{if(!d)return;let m=++tt,b=d.readable.getReader();k=b,w&&clearTimeout(w);let P=setTimeout(()=>{w===P&&(w=null),!(ae>0)&&Z!==0&&Qt("stall")},Qn);w=P;try{for(;;){let{done:B,value:M}=await b.read();if(B)break;if(M&&M.byteLength>0){let D=ae===0;if(ae+=M.byteLength,D&&zt(),jt.add(M.byteLength)){Zt();return}let C=E.yieldCount;await E.onChunk(M.byteLength),E.yieldCount>C&&de.downlinkYields++,$(M)}}}catch{}finally{try{b.releaseLock()}catch{}if(clearTimeout(P),w===P&&(w=null),k===b&&(k=null),m!==tt||K)return;if(ae===0&&Z>0&&j<Ut&&!R){Qt("eof");return}let B=d;U(1e3,B?`done via=${B.via} ep=${B.endpoint} dl=${ae} ret=${Z} rd=${j}`:"done")}},ae=0,jt=new ue((n.dataBudgetMB||0)*1024*1024),Zt=()=>{let m=__sfx("5Y2V6L+e5o6l5rWB6YeP6LaF6L+HIA==")+n.dataBudgetMB+__sfx("TUIg5LiK6ZmQ");Q(N?`${N.hostname}:${N.port}`:__sfx("5pyq5bu656uL5Ye656uZ"),[],m),U(1009,m)},Dr=async m=>{let b=g;if(b)try{await y.write(()=>g===b?b:null,m)}catch(P){Q(N?`${N.hostname}:${N.port}`:__sfx("5pyq5bu656uL5Ye656uZ"),[],__sfx("5LiK6KGM5YaZ5YWl5aSx6LSl77ya")+String(P)+""),h()}},_t=async m=>{if(f.length===0)return;let b=f;f=[],u=0;for(let P of b)et(P),await m.write(P)},Jt=m=>{if(t===__sfx("dmxlc3M=")){let P=Ue(m,n.uuid);return P?{command:P.header.command,port:P.header.port,hostname:P.header.hostname,headerLength:P.consumed}:null}let b=mn(m,n[__sfx("dHJvamFuUGFzc3dvcmQ=")]);return b?{command:b.header.command,port:b.header.port,hostname:b.header.hostname,headerLength:b.consumed}:null},Or=()=>{x&&(clearTimeout(x),x=null)},Nr=async()=>{if(!(K||c)){if(Jt(l)){await nt();return}U(1008,l.byteLength===0?__sfx("5o+h5omL6LaF5pe277ya5pyq5pS25Yiw5Y2P6K6u5aS0"):__sfx("5o+h5omL6LaF5pe277ya5Y2P6K6u5aS05LiN5a6M5pW05oiW6K6k6K+B5aSx6LSl"))}},nt=async()=>{if(K||c)return;let m=Jt(l);if(!m){l.byteLength>0&&!x&&(x=setTimeout(()=>{x=null,Nr().catch(C=>U(1011,String(C)))},Zo));return}if(Or(),p(),c)return;c=!0,N=m;let b=t===__sfx("dmxlc3M=")?sn:pn;if(m.command===b){if(t===__sfx("dmxlc3M=")&&n.udpDns==="doh"&&m.port===53){ie(new Uint8Array(0)),Y=new Oe({endpoint:n.udpDnsEndpoint,send:$});let C=l.subarray(m.headerLength);C.byteLength>0&&Y.push(C);return}U(1002,n.udpDns==="doh"?__sfx("VURQIOS7heaUr+aMgSBETlPvvIg1MyDnq6/lj6PvvIk="):__sfx("VURQIOacquWQr+eUqO+8iOmdouadv+WPr+W8gOWQryBETlMgb3ZlciBEb0jvvIk="));return}t===__sfx("dmxlc3M=")&&ie(new Uint8Array(0));let P=[],B=null;try{d=await fe({hostname:m.hostname,port:m.port,proxies:o,timeoutMs:Jn,concurrent:n.concurrentDial,nat64:n.nat64||void 0,proxyMode:n.proxyMode,resolvePreferred:n.resolvePreferred,relayPool:{userEntries:n.relayPool||void 0,useBuiltin:n.useBuiltinRelay},onFailure:C=>{P.push(C),s?.failures.push(C)}})}catch(C){B=C}if(!d){let C=P.length>0?P.map(he=>zn(he)).join(`
|
|
5
|
-
`):__sfx("5Ye656uZ6L+e5o6l5aSx6LSl77ya")+String(B)+"";Q(`${m.hostname}:${m.port}`,P,C),U(1011,C);return}let M=d.writable.getWriter();g=M,er(`${m.hostname}:${m.port}`,d,"initial");let D=l.byteLength>m.headerLength?l.subarray(m.headerLength):new Uint8Array(0);l=new Uint8Array(0);try{await y.run(async()=>{D.byteLength>0&&(et(D),await M.write(D)),await _t(M)})}catch(C){Q(`${m.hostname}:${m.port}`,[],__sfx("5LiK6KGM6aaW5YyF5YaZ5YWl5aSx6LSl77ya")+String(C)+""),h()}r?.waitUntil(Yt())},Qt=async m=>{if(K||R)return;let b=N;if(!b){U(1011,__sfx("5Ye656uZ5peg5pWw5o2u77ya55uu5qCH5pyq6Kej5p6Q"));return}if(j>=Ut){U(1011,__sfx("5Ye656uZ5peg5pWw5o2u77ya55u06L+e5LiO5Y+N5Luj5YWl5Y+j5Z2H5peg5ZON5bqU"));return}R=!0;let P=bn({via:d?.via,port:b.port,userProxyConfigured:o.length>0||!!n[__sfx("cHJveHlJcA==")],aggressive:n.aggressiveRedial===!0});if(!P.allowed){de.guardedRedials++,Q(`${b.hostname}:${b.port}`,[],__sfx("5Ye656uZ5peg5pWw5o2u77ya")+P.reason+__sfx("77yb5pyq5YiH5o2i5Y+N5Luj77yI5Y+v5byA5ZCvIGFnZ3Jlc3NpdmVSZWRpYWzvvIk=")),U(1011,__sfx("5Ye656uZ5peg5pWw5o2u77ya")+P.reason+"");return}j++,m==="stall"?de.stallRedials++:de.eofRedials++,Q(`${b.hostname}:${b.port}`,[],m==="stall"?__sfx("55u06L+eIA==")+Qn+__sfx("bXMg5peg5LiL6KGM5pWw5o2u77yM5pS56LWw5Y+N5Luj5YWl5Y+j"):__sfx("5Ye656uZ6Zu25LiL6KGM5Y2zIEVPRi9SZXNldO+8jOeri+WNs+aUuei1sOWPjeS7o+WFpeWPow=="));let B=[];try{B=await xe({userEntries:n.relayPool||void 0,useBuiltin:n.useBuiltinRelay})}catch{B=[]}let M=B.filter(D=>!v.has(`${D.ip}:${D.port}`));if(M.length===0){U(1011,__sfx("5Ye656uZ5peg5pWw5o2u77ya5peg5Y+N5Luj5YWl5Y+j5Y+v55So"));return}for(let D of M.slice(0,Ut)){if(v.add(`${D.ip}:${D.port}`),Ur(),d){let C=d;if(C.close)try{C.close()}catch{}}g=null,ae=0;try{let C=await fe({hostname:D.ip,port:D.port,timeoutMs:Jn,resolvePreferred:!1,skipTargetPolicy:!0,proxies:n.aggressiveRedial?o:void 0,proxyMode:n.aggressiveRedial?n.proxyMode:void 0});if(!C)continue;d=C,er(`${b.hostname}:${b.port}`,C,"redial");let he=C.writable.getWriter();g=he;let $t=0;for(let Ce of O)$t+=Ce.byteLength;let rt=new Uint8Array($t),en=0;for(let Ce of O)rt.set(Ce,en),en+=Ce.byteLength;await y.run(async()=>{rt.byteLength>0&&await he.write(rt),await _t(he)}),Q(`${b.hostname}:${b.port}`,[],__sfx("5bey5YiH5o2i5Y+N5Luj5YWl5Y+jIA==")+D.ip+":"+D.port+""),r?.waitUntil(Yt());return}catch(C){Q(`${b.hostname}:${b.port}`,[],__sfx("5Y+N5Luj5YWl5Y+jIA==")+D.ip+":"+D.port+__sfx("IOWksei0pe+8mg==")+String(C)+"")}}U(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(p(),jt.add(P.byteLength)){Zt();return}if(!c){if(l=yn(l,P),l.byteLength>Wo){U(1009,__sfx("5o+h5omL5aS06LaF6L+HIDY0S0I="));return}await nt();return}if(Y){Y.push(P);return}if(!g){if(f.push(P),u+=P.byteLength,u>qn){U(1009,__sfx("5ouo5Y+35pyf6Ze05pWw5o2u6L+H5aSa"));return}return}et(P),await Dr(P)}})()});let qt=()=>{h()};a.addEventListener("close",qt),a.addEventListener("error",qt),l.byteLength>0?nt().catch(m=>U(1011,String(m))):T=setTimeout(()=>{T=null,!(K||c||l.byteLength>0)&&(de.firstPacketTimeouts++,U(1008,__sfx("6aaW5YyF6LaF5pe277ya5pyq5pS25Yiw5Y2P6K6u5aS0")))},_o);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 Jn,Qn,Ut,Wo,qn,Vo,Ve,ze,$n,de,Ye,Zo,_o,Dt=S(()=>{"use strict";ct();hn();gn();we();wn();xn();It();We();At();Pe();Jn=5e3,Qn=2500,Ut=2,Wo=64*1024,qn=8*1024*1024,Vo=32*1024*1024,Ve=0;ze=[],$n=20,de={stallRedials:0,eofRedials:0,guardedRedials:0,firstPacketTimeouts:0,downlinkYields:0};Ye=[];Zo=2e3,_o=8e3});var fr={};ve(fr,{[__sfx("Y2xlYXJYaHR0cFNlc3Npb25z")]:()=>rs,[__sfx("aGFuZGxlWGh0dHA=")]:()=>Mt,[__sfx("aXNYaHR0cFBhdGg=")]:()=>Lt,[__sfx("cGFyc2VYaHR0cFJvdXRl")]:()=>Nt,[__sfx("cmVjZW50WGh0dHBEaWFnbm9zdGljcw==")]:()=>$o,[__sfx("cmVjb3JkWGh0dHBEaWFnbm9zdGljcw==")]:()=>z});function qo(e,t){return new Promise(n=>{let o=setTimeout(()=>n(null),t);e.then(r=>{clearTimeout(o),n(r)},()=>{clearTimeout(o),n(null)})})}function z(e,t,n){Ze.unshift({at:Date.now(),target:e,...t,summary:n}),Ze.length>20&&(Ze.length=20)}function $o(){return Ze}function es(e){return String(e||"").trim().replace(/\/+$/,"")||"/"}function Nt(e,t){let n=es(t??__sfx("L3hodHRw"));if(e===n||e===`${n}/`)return{kind:"stream-one"};let o=`${n}/`;if(!e.startsWith(o))return null;let r=e.slice(o.length);if(!r)return null;let s=r.split("/");if(s.length===1&&s[0])return/[\s\u0000-\u001f]/.test(s[0])?null:{kind:"session",sessionId:s[0]};if(s.length===2&&s[0]&&/^\d+$/.test(s[1])){if(/[\s\u0000-\u001f]/.test(s[0]))return null;let i=Number(s[1]);return!Number.isSafeInteger(i)||i<0||i>1e6?null:{kind:__sfx("cGFja2V0LXVw"),sessionId:s[0],seq:i}}return null}function Lt(e,t){return Nt(e,t)!==null}function lr(e){if(e.reservedBytes<=0){e.reservedBytes=0;return}Ee=Math.max(0,Ee-e.reservedBytes),e.reservedBytes=0}function ir(e,t){return t<=0?!0:Ee+t>ns?!1:(Ee+=t,e.reservedBytes+=t,!0)}function rs(){for(let[e,t]of W)V(e,t);W.clear(),Ee=0}function os(e,t){return t-e.lastUploadAt>Ot&&t-e.lastDownlinkAt>Ot&&t-e.lastActivityAt>Ot}function ss(e,t){return e.closed?!0:e.header||e.dialResult||e.downlinkStarted?!1:t-e.createdAt>ar}function ur(e,t,n,o){let r=Date.now();for(let[a,l]of W)(l.closed||os(l,r)||r-l.createdAt>30*6e4)&&V(a,l);let s=W.get(e);if(s)return cr(s,n,r),s;if(W.size>=rr){for(let[a,l]of W)ss(l,r)&&V(a,l);if(W.size>=rr)return null}if(!o){let a=0;for(let l of W.values())l.header||(a+=1);if(a>=ts)return null}let i={id:e,createdAt:r,lastUploadAt:r,lastDownlinkAt:r,lastActivityAt:r,header:void 0,headerWaiters:[],dialPromise:null,dialResult:null,pending:new Map,reservedBytes:0,nextPumpSeq:0,pumpStarted:!1,signalResolve:null,traffic:new ue(t),downlinkStarted:!1,closed:!1,targetLabel:""};return W.set(e,i),i}function cr(e,t,n){t==="upload"?e.lastUploadAt=n:e.lastDownlinkAt=n,e.lastActivityAt=n}function V(e,t){if(!t.closed){t.closed=!0;for(let n of t.headerWaiters)try{n(null)}catch{}if(t.headerWaiters=[],t.signalResolve?.(),t.signalResolve=null,t.dialResult?.close)try{t.dialResult.close()}catch{}lr(t),t.pending.clear(),W.delete(e)}}function is(e){let t=e.signalResolve;e.signalResolve=null,t?.()}function as(e,t){return e.header?Promise.resolve(e.header):e.closed?Promise.resolve(null):new Promise(n=>{let o=s=>{clearTimeout(r),n(s)},r=setTimeout(()=>{let s=e.headerWaiters.indexOf(o);s>=0&&e.headerWaiters.splice(s,1),n(null)},t);e.headerWaiters.push(o)})}function ls(e,t){e.header=t;let n=e.headerWaiters;e.headerWaiters=[];for(let o of n)try{o(t)}catch{}}function L(e){let t=100+Math.floor(Math.random()*900);return{"Content-Type":"text/event-stream","Cache-Control":"no-store","X-Accel-Buffering":"no","Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET, POST","X-Padding":"X".repeat(t),...e}}function us(e){let t=e.addons,n=new Uint8Array(2+t.byteLength);return n[0]=e.version,n[1]=t.byteLength,n.set(t,2),n}async function cs(e,t,n){if(e.dialResult)return e.dialResult;if(!e.dialPromise){let o=e.header;if(!o)throw new Error(__sfx("VkxFU1Mg5aS05pyq5Yiw6L6+"));e.targetLabel=`${o.hostname}:${o.port}`,e.dialPromise=fe({hostname:o.hostname,port:o.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:r=>{z(e.targetLabel,r,__sfx("WEhUVFAg5Ye656uZ5aSx6LSl77yI")+r.candidate+"):"+r.message+"")}}).then(r=>(e.dialResult=r,r)).catch(r=>{throw z(e.targetLabel,{kind:"dial",message:String(r),candidate:"all"},__sfx("WEhUVFAg5Ye656uZ5YWo6YOo5aSx6LSl77ya")+String(r)+""),r})}return await e.dialPromise}async function fs(e,t){let n=t.writable.getWriter();try{for(;!e.closed;){let o=e.pending.get(e.nextPumpSeq);if(o){if(e.pending.delete(e.nextPumpSeq),e.nextPumpSeq+=1,lr(e),o.byteLength===0)continue;if(e.traffic.add(o.byteLength)){z(e.targetLabel,{kind:"budget",message:__sfx("5rWB6YeP6LaF6ZmQ"),candidate:"traffic"},__sfx("WEhUVFAg5LiK6KGM5rWB6YeP6LaF6ZmQ"));break}try{await n.write(o)}catch(i){z(e.targetLabel,{kind:"relay-write",message:String(i),candidate:t.endpoint},__sfx("WEhUVFAg5YaZ5YWl55uu5qCH5aSx6LSl77ya")+String(i)+"");break}continue}let r=null,s=new Promise(i=>{r=i});if(e.signalResolve=r,e.pending.has(e.nextPumpSeq)||e.closed){e.signalResolve=null;continue}await s}}finally{try{n.releaseLock()}catch{}}}async function ds(e,t,n,o,r){let s=(t.dataBudgetMB||0)*1024*1024,i=ur(o,s,"upload",r===0);if(!i)return new Response(__sfx("5Lya6K+d5pWw5bey6L6+5LiK6ZmQ77yM6K+356iN5ZCO6YeN6K+V"),{status:503,headers:L()});if(i.closed)return null;let a=Number(e.headers.get("content-length")??"");if(Number.isFinite(a)&&a>or)return new Response(__sfx("5YiG5YyF6LaF5Ye65LiK6ZmQ"),{status:413,headers:L()});let l;try{let f=await e.arrayBuffer();l=new Uint8Array(f)}catch{return new Response(__sfx("6K+35rGC5L2T6K+75Y+W5aSx6LSl"),{status:400,headers:L()})}if(l.byteLength>or)return new Response(__sfx("5YiG5YyF6LaF5Ye65LiK6ZmQ"),{status:413,headers:L()});if(r===0&&!i.header){let f=Ue(l,t.uuid);if(!f)return V(o,i),new Response(__sfx("VkxFU1Mg5aS06Kej5p6Q5aSx6LSl"),{status:400,headers:L()});if(f.header.command!==ut)return V(o,i),new Response(__sfx("WEhUVFAg5pqC5LiN5pSv5oyBIFVEUA=="),{status:400,headers:L()});ls(i,f.header),i.targetLabel=`${f.header.hostname}:${f.header.port}`;let u=l.subarray(f.consumed);if(r>=i.nextPumpSeq&&!i.pending.has(r)){if(i.pending.size>=sr)return V(o,i),new Response(__sfx("5YiG5YyF57yT5a2Y5bey5ruh"),{status:503,headers:L()});if(!ir(i,u.byteLength))return V(o,i),new Response(__sfx("5pqC5a2Y6LaF6ZmQ"),{status:503,headers:L()});i.pending.set(r,u.slice())}}else{if(r<i.nextPumpSeq||i.pending.has(r))return new Response(null,{status:200,headers:L()});if(i.pending.size>=sr)return V(o,i),new Response(__sfx("5YiG5YyF57yT5a2Y5bey5ruh"),{status:503,headers:L()});if(!ir(i,l.byteLength))return V(o,i),new Response(__sfx("5pqC5a2Y6LaF6ZmQ"),{status:503,headers:L()});i.pending.set(r,l.slice())}return is(i),new Response(null,{status:200,headers:L()})}async function ps(e,t,n,o){let r=(t.dataBudgetMB||0)*1024*1024,s=ur(o,r,"downlink",!1);if(!s)return new Response(__sfx("5Lya6K+d5pWw5bey6L6+5LiK6ZmQ77yM6K+356iN5ZCO6YeN6K+V"),{status:503,headers:L()});if(s.closed||s.downlinkStarted)return null;s.downlinkStarted=!0;let i=as(s,ar),a=!1,l=null,f=null,u=!1,c=null,d=()=>{V(o,s)},g=new ReadableStream({start(y){f=y},async pull(y){if(!a)try{if(!u){let p=await i;if(a)return;if(!p){d(),y.close();return}try{c=await cs(s,t,n)}catch{d(),y.close();return}if(a)return;s.pumpStarted||(s.pumpStarted=!0,fs(s,c).catch(()=>{}));try{y.enqueue(us(p))}catch{}u=!0;return}if(!c)return;l||(l=c.readable.getReader());let{done:x,value:T}=await l.read();if(a)return;if(x){d();try{y.close()}catch{}return}if(T&&T.byteLength>0){if(cr(s,"downlink",Date.now()),s.traffic.add(T.byteLength)){z(s.targetLabel,{kind:"budget",message:__sfx("5rWB6YeP6LaF6ZmQ"),candidate:"traffic"},__sfx("WEhUVFAg5LiL6KGM5rWB6YeP6LaF6ZmQ")),d();try{y.close()}catch{}return}y.enqueue(T)}}catch(x){if(a)return;d();try{y.error(x)}catch{}}},cancel(y){if(a=!0,c)try{c.readable.cancel(y)}catch{}d()}});return new Response(g,{status:200,headers:L()})}async function Mt(e,t,n){let o=__sfx("L3hodHRw");try{o=new URL(e.url).pathname}catch{o=__sfx("L3hodHRw")}let r=Nt(o,t[__sfx("eGh0dHBQYXRo")]);return r?r.kind==="stream-one"?e.method!=="POST"?null:await ms(e,t,n):r.kind===__sfx("cGFja2V0LXVw")?e.method!=="POST"?null:await ds(e,t,n,r.sessionId,r.seq):e.method==="GET"?await ps(e,t,n,r.sessionId):null:null}async function ms(e,t,n){let o=e.body;if(!o)return new Response(__sfx("57y65bCR6K+35rGC5L2T"),{status:400});let r=new ne(o),s=await qo(ln(r,t.uuid),Qo);if(!s)return await r.cancel("header timeout"),new Response(__sfx("VkxFU1Mg5aS06Kej5p6Q5aSx6LSl"),{status:400});if(s.header.command!==ut)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:p=>{z(`${s.header.hostname}:${s.header.port}`,p,__sfx("WEhUVFAg5Ye656uZ5aSx6LSl77yI")+p.candidate+"):"+p.message+"")}})}catch(p){z(`${s.header.hostname}:${s.header.port}`,{kind:"dial",message:String(p),candidate:"all"},__sfx("WEhUVFAg5Ye656uZ5YWo6YOo5aSx6LSl77ya")+String(p)+"");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,u=null,c=!1,d=new ue((t.dataBudgetMB||0)*1024*1024),g=null,y=()=>{if(c)return;c=!0;let p=__sfx("5Y2V6L+e5o6l5rWB6YeP6LaF6L+HIA==")+t.dataBudgetMB+__sfx("TUIg5LiK6ZmQ");if(z(`${s.header.hostname}:${s.header.port}`,{kind:"budget",message:p,candidate:"traffic"},p),i.close)try{i.close()}catch{}try{g?.close()}catch{}},x=p=>d.add(p)?(y(),!0):!1;_n(s.payload,i.writable,void 0,!1,x,(p,R)=>{let E=p instanceof Error?p.message:String(p),k=`relay-${R}`;/cancel|abort|closed/i.test(E)?k=`relay-${R}-client-cancel`:/reset|broken pipe/i.test(E)&&(k=`relay-${R}-upstream-reset`),z(`${s.header.hostname}:${s.header.port}`,{kind:k,message:E.slice(0,200),candidate:i.endpoint},__sfx("WEhUVFAg5Lit57un")+R==="read"?"\u8BFB\u4E0A\u6E38":"\u5199\u76EE\u6807"+__sfx("5aSx6LSl77yI")+k+"):"+E.slice(0,120)+"")}).catch(()=>{});let T=new ReadableStream({start(p){g=p,p.enqueue(l),f=!0},async pull(p){if(!(c||!f)){u||(u=i.readable.getReader());try{let{done:R,value:E}=await u.read();if(c)return;if(R){if(i.close)try{i.close()}catch{}p.close();return}if(E&&E.byteLength>0){if(d.add(E.byteLength)){y();return}p.enqueue(E)}}catch(R){if(c)return;if(i.close)try{i.close()}catch{}try{p.error(R)}catch{}}}},cancel(p){c=!0;try{i.readable.cancel(p)}catch{}if(i.close)try{i.close()}catch{}}});return new Response(T,{status:200,headers:{"Content-Type":"text/event-stream","Cache-Control":"no-store","X-Accel-Buffering":"no"}})}var Qo,Ze,W,ar,rr,ts,Ot,or,sr,ns,Ee,Ht=S(()=>{"use strict";we();ct();We();It();Qo=2e3;Ze=[];W=new Map,ar=3e4,rr=100,ts=20,Ot=10*6e4,or=10*1024*1024,sr=30,ns=32*1024*1024,Ee=0});function Je(){return new Response(JSON.stringify({build:Bt,version:hs,ts:Date.now()}),{status:200,headers:{"Content-Type":"application/json","Cache-Control":"no-store","Access-Control-Allow-Origin":"*"}})}var Bt,hs,_e,Ft=S(()=>{"use strict";Bt="77d82aa-82ab544c",hs=__sfx("MC4zMy42"),_e=__sfx("L19fY2ZwX3ZlcnNpb24=")});function dr(e){return e[__sfx("S1Y=")]?new pe(e[__sfx("S1Y=")]):new Kt}var pe,Kt,Qe=S(()=>{"use strict";pe=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}},Kt=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 ce(e,t){if(e==null)return t;let n=String(e).trim();if(n==="")return t;let o=Number(n);return Number.isFinite(o)?o:t}function F(e,t){if(e==null||e==="")return t;let n=String(e).trim().toLowerCase();return["1","true","yes","on"].includes(n)?!0:["0","false","no","off"].includes(n)?!1:t}function gs(e){let t=e.trim().toLowerCase();return t==="global"||t==="fallback"||t==="smart"?t:"only"}function mr(e){return e.trim().toLowerCase()==="signed"?"signed":"legacy"}function hr(e){return e.trim().toLowerCase()==="doh"?"doh":"off"}function I(e,t){return e==null?t:String(e)}function ys(e){return{uuid:I(e[__sfx("VVVJRA==")],""),[__sfx("dHJvamFuUGFzc3dvcmQ=")]:I(e[__sfx("VFJPSkFOX1BBU1NXT1JE")],""),wsPath:I(e[__sfx("V1NfUEFUSA==")]||e[__sfx("UEFUSA==")],A.wsPath),[__sfx("dHJvamFuUGF0aA==")]:A[__sfx("dHJvamFuUGF0aA==")],[__sfx("eGh0dHBQYXRo")]:A[__sfx("eGh0dHBQYXRo")],add:I(e[__sfx("QURE")],""),addApi:I(e[__sfx("QUREQVBJ")],""),addCsv:I(e[__sfx("QUREX0NTVg==")],""),poolOfficial:F(e[__sfx("T0ZGSUNJQUxfSVA=")],A.poolOfficial),officialCount:ce(e[__sfx("T0ZGSUNJQUxfSVBfQ09VTlQ=")],A.officialCount),poolDomain:F(e[__sfx("UFJFRkVSUkVEX0RPTUFJTg==")],A.poolDomain),domainCount:ce(e[__sfx("UFJFRkVSUkVEX0RPTUFJTl9DT1VOVA==")],A.domainCount),poolManual:F(e[__sfx("TUFOVUFMX0lQ")],A.poolManual),poolCountries:I(e[__sfx("UE9PTF9DT1VOVFJJRVM=")],A.poolCountries),dls:ce(e[__sfx("RExT")],0),maxLatency:ce(e[__sfx("TUFYX0xBVEVOQ1k=")],0),maxNodes:0,[__sfx("cHJveHlJcA==")]:I(e[__sfx("UFJPWFlJUA==")],""),[__sfx("c29ja3M1")]:I(e[__sfx("U09DS1M1")],""),httpProxy:I(e[__sfx("SFRUUF9QUk9YWQ==")],""),proxyMode:gs(I(e[__sfx("UFJPWFlfTU9ERQ==")],"")),nat64:I(e[__sfx("TkFUNjQ=")],""),concurrentDial:F(e[__sfx("VENQX0NPTkNVUlJFTlRfRElBTA==")],!0),dataBudgetMB:ce(e[__sfx("REFUQV9CVURHRVRfTUI=")],A.dataBudgetMB),resolvePreferred:F(e[__sfx("UkVTT0xWRV9QUkVGRVJSRUQ=")],A.resolvePreferred),aggressiveRedial:F(e[__sfx("QUdHUkVTU0lWRV9SRURJQUw=")],A.aggressiveRedial),relayPool:I(e[__sfx("UkVMQVlfUE9PTA==")],""),useBuiltinRelay:F(e[__sfx("VVNFX0JVSUxUSU5fUkVMQVk=")],A.useBuiltinRelay),[__sfx("ZW5hYmxlVHJvamFu")]:F(e[__sfx("RU5BQkxFX1RST0pBTg==")]??e[__sfx("VFJPSkFO")],A[__sfx("ZW5hYmxlVHJvamFu")]),[__sfx("ZW5hYmxlWGh0dHA=")]:F(e[__sfx("RU5BQkxFX1hIVFRQ")]??e[__sfx("WEhUVFA=")],A[__sfx("ZW5hYmxlWGh0dHA=")]),subDomain:"",subProtocol:"both",subTransport:"both",subVariants:I(e[__sfx("U1VCX1ZBUklBTlRT")],A.subVariants),subName:I(e[__sfx("U1VCX05BTUU=")],A.subName).trim()||A.subName,subPorts:I(e[__sfx("U1VCX1BPUlRT")],A.subPorts),clientFingerprint:A.clientFingerprint,ech:F(e[__sfx("RUNI")],A.ech),echHost:I(e[__sfx("RUNIX0hPU1Q=")],A.echHost),echDns:I(e[__sfx("RUNIX0ROUw==")],A.echDns),tlsFragment:!1,tlsFragmentSize:A.tlsFragmentSize,tlsFragmentDelay:A.tlsFragmentDelay,subToken:mr(I(e[__sfx("U1VCX1RPS0VOX01PREU=")],"")),subTokenTtlDays:ce(e[__sfx("U1VCX1RPS0VOX1RUTF9EQVlT")],A.subTokenTtlDays),unlockProbe:F(e[__sfx("VU5MT0NLX1BST0JF")],A.unlockProbe),udpDns:hr(I(e[__sfx("VURQX0ROUw==")],"")),udpDnsEndpoint:I(e[__sfx("VURQX0ROU19FTkRQT0lOVA==")],A.udpDnsEndpoint)}}function bs(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]=ce(r,0);else if(o==="concurrentDial"||o==="resolvePreferred"||o==="aggressiveRedial"||o==="useBuiltinRelay"||o===__sfx("ZW5hYmxlVHJvamFu")||o===__sfx("ZW5hYmxlWGh0dHA=")||o==="tlsFragment"||o==="ech"||o==="poolOfficial"||o==="poolDomain"||o==="poolManual"||o==="unlockProbe")n[o]=F(r,!1);else if(o==="subProtocol"){let s=String(r);n[o]=s===__sfx("dmxlc3M=")||s===__sfx("dHJvamFu")||s==="both"?s:"both"}else if(o==="subTransport"){let s=String(r);n[o]=s==="ws"||s===__sfx("eGh0dHA=")||s==="both"?s:"both"}else o==="subToken"?n[o]=mr(String(r)):o==="udpDns"?n[o]=hr(String(r)):n[o]=String(r);return n}async function gr(e,t){let n=ys(t),o=await e.get(pr),r={};if(o)try{r=JSON.parse(o)}catch{r={}}let s=bs(n,r),i=!1,a=e instanceof pe,l=Date.now();o?Ae=0:Ae===0&&(Ae=l);let f=l-Ae>ws;return a&&f&&(s.uuid||(s.uuid=ot(),i=!0),s[__sfx("dHJvamFuUGFzc3dvcmQ=")]||(s[__sfx("dHJvamFuUGFzc3dvcmQ=")]=ot().replace(/-/g,"").slice(0,16),i=!0),Ae=0),o&&(s.officialCount<1||s.domainCount<1)&&(s.officialCount<1&&(s.officialCount=A.officialCount,i=!0),s.domainCount<1&&(s.domainCount=A.domainCount,i=!0)),i&&await xs(e,s),s}async function xs(e,t){await e.put(pr,JSON.stringify(t))}var pr,A,Ae,ws,qe=S(()=>{"use strict";ee();Qe();pr="CONFIG",A={uuid:"",[__sfx("dHJvamFuUGFzc3dvcmQ=")]:"",wsPath:__sfx("L3ZsZXNz"),[__sfx("dHJvamFuUGF0aA==")]:__sfx("L3Ryb2phbg=="),[__sfx("eGh0dHBQYXRo")]:__sfx("L3hodHRw"),add:"",addApi:"",addCsv:"",poolOfficial:!0,officialCount:20,poolDomain:!0,domainCount:10,poolManual:!0,poolCountries:"",dls:0,maxLatency:0,maxNodes:0,[__sfx("cHJveHlJcA==")]:"",[__sfx("c29ja3M1")]:"",httpProxy:"",proxyMode:"only",nat64:"",concurrentDial:!0,dataBudgetMB:0,resolvePreferred:!0,aggressiveRedial:!1,relayPool:"",useBuiltinRelay:!0,[__sfx("ZW5hYmxlVHJvamFu")]:!0,[__sfx("ZW5hYmxlWGh0dHA=")]:!0,subDomain:"",subProtocol:__sfx("dmxlc3M="),subTransport:"ws",subVariants:__sfx("dmxlc3Mtd3M="),subName:__sfx("Q0ZQaWxvdA=="),subPorts:"443",clientFingerprint:"chrome",ech:!1,echHost:__sfx("Y2xvdWRmbGFyZS1lY2guY29t"),echDns:"",tlsFragment:!1,tlsFragmentSize:"10-20",tlsFragmentDelay:"10-20",subToken:"legacy",subTokenTtlDays:0,unlockProbe:!1,udpDns:"off",udpDnsEndpoint:"https://dns.google/dns-query"};Ae=0,ws=9e4});var yr,Ps,Yi,Ss,ji,br=S(()=>{"use strict";yr={[__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"]},Ps=__sfx("SEtH6aaZ5rivLFRQReWPsOWMlyxOUlTkuJzkuqwsS0lY5aSn6ZiqLElDTummluWwlCxTSU7mlrDliqDlnaEsS1VM5ZCJ6ZqG5Z2hLEJLS+abvOiwtyxTR07og6Hlv5fmmI7luIIsTU5M6ams5bC85ouJLFNZROaCieWwvCxNRUzloqjlsJTmnKwsTEFY5rSb5p2J55+2LFNKQ+Wco+S9leWhnixTRUHopb/pm4Xlm74sT1JE6Iqd5Yqg5ZOlLElBROWNjuebm+mhvyxFV1Lnur3nk6blhYssWVla5aSa5Lym5aSaLFlWUua4qeWTpeWNjixMSFLkvKbmlaYsRlJB5rOV5YWw5YWL56aPLENER+W3tOm7jixBTVPpmL/lp4bmlq/nibnkuLksTUFE6ams5b636YeMLEFSTuaWr+W+t+WTpeWwlOaRqSxJU1TkvIrmlq/lnabluIPlsJQsRFhC6L+q5ouc"),Yi=(()=>{let e={};for(let t of Ps.split(","))t.length>3&&(e[t.slice(0,3)]=t.slice(3));return e})(),Ss=new Map;for(let[e,t]of Object.entries(yr))for(let n of t)Ss.set(n,e);ji=Object.keys(yr)});var _i,wr=S(()=>{"use strict";_i=new Set("GEOSITE GEOIP GEOIP-CIDR DOMAIN DOMAIN-SUFFIX DOMAIN-KEYWORD IP-CIDR IP-CIDR6 SRC-IP-CIDR DST-PORT SRC-PORT PROCESS-NAME MATCH".split(" "))});var fa,xr=S(()=>{"use strict";X();ee();br();wr();fa=".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 ha,Pr=S(()=>{"use strict";Qe();ee();ha=new TextEncoder});var Da,Sr=S(()=>{"use strict";qe();ee();Da=3600*24});function Er(e){return dr(e)}async function Ar(e,t){if(Te.config&&Date.now()-Te.configAt<Es)return Te.config;let n=await gr(e,t);return Te.config=n,Te.configAt=Date.now(),n}var Es,Te,Gt=S(()=>{"use strict";Qe();qe();Sr();Es=15e3,Te={config:null,configAt:0,auth:null,authAt:0}});var Rr={};ve(Rr,{clearUnlockCache:()=>Ds,runUnlockProbe:()=>Us});function ks(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 Is(e){let t=Date.now(),n=new AbortController,o=setTimeout(()=>n.abort(),Rs);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:ks(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 Us(e,t){let n=e||"UNK",o=Date.now(),r=me.get(n);if(r&&o-r.at<Cs)return{...r.data,cached:!0};let s=await Promise.all(Ts.map(a=>Is(a))),i={colo:n,region:t,cached:!1,at:o,targets:s};if(me.size>=vs){let a="",l=Number[__sfx("UE9TSVRJVkVfSU5GSU5JVFk=")];for(let[f,u]of me)u.at<l&&(l=u.at,a=f);a&&me.delete(a)}return me.set(n,{at:o,data:i}),i}function Ds(){me.clear()}var Ts,Rs,Cs,vs,me,Cr=S(()=>{"use strict";Ts=[{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"}],Rs=4e3,Cs=600*1e3,vs=16,me=new Map});ee();var Mr=8*1024*1024,Hr=2*1024*1024,nn=600*1e3,Br=6*1024*1024*1024,st=Date.now(),it=0;function rn(e){e-st>=nn&&(st=e,it=0)}function Fr(e,t=Date.now()){rn(t),it+=e}function tn(e){return rn(e),Br-it}var Kr=(()=>{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})(),Xr=5e3;function Gr(e,t=Xr){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 at(e){let t=new URL(e.url);if(e.headers.get("Upgrade")?.toLowerCase()===__sfx("d2Vic29ja2V0")){let f=new WebSocketPair,[u,c]=Object.values(f);c.accept();let d=Gr((g,y)=>c.close(g,y));return c.addEventListener("message",g=>{let y=typeof g.data=="string"?g.data:"";if(y==="PING"||y==="ping"){d.cancel(),c.send(JSON.stringify({pong:!0,colo:e.cf?.colo??"UNK",clientIp:e.headers.get("CF-Connecting-IP")??""}));try{c.close(1e3,"Probe complete")}catch{}return}d.cancel();try{c.close(1e3,"Probe aborted")}catch{}}),c.addEventListener("close",()=>d.cancel()),c.addEventListener("error",()=>d.cancel()),new Response(null,{status:101,[__sfx("d2ViU29ja2V0")]:u})}let o=Number.parseInt(t.searchParams.get("bytes")??"",10),r=Number.isFinite(o)&&o>0?Math.min(o,Mr):Hr,s=Date.now();if(tn(s)<=0){let f=Math.max(1e3,st+nn-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=Kr,a=0,l=new ReadableStream({pull(f){let u=tn(Date.now());if(a>=r||u<=0){f.close();return}let c=Math.min(i.byteLength,r-a,u);f.enqueue(i.subarray(0,c)),a+=c,Fr(c)}});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":Ie(4)}})}Dt();Ht();Tt();Ft();ee();qe();We();xr();Pr();ee();function Xt(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"}})}Gt();Gt();async function Tr(e){let t=Er(e);return await Ar(t,e)}function Wt(e){let t=[];return t.push(...Se(e[__sfx("cHJveHlJcA==")],"direct")),t.push(...Se(e[__sfx("c29ja3M1")],__sfx("c29ja3M1"))),t.push(...Se(e.httpProxy,"http")),t}var Vt=6e4,Os=10,Re=0,$e=0;function vr(e){return e>=$e?(Re=0,$e=e+Vt,!1):Re>=Os}function kr(e,t){if(!t)return!1;let n=(e.headers.get(__sfx("eC1jZnBpbG90LXRva2Vu"))??"").trim();if(!n)return!1;let o=Date.now();return ge(n,t)?(Re=0,!0):(o>=$e&&($e=o+Vt,Re=0),Re+=1,!1)}async function Ir(e,t,n){let o=new URL(e.url);if(o.pathname===__sfx("L19fZWRnZV9wcm9iZQ=="))return at(e);if(o.pathname===_e||o.pathname===__sfx("L19fdmVyc2lvbg=="))return Je();if(o.pathname==="/region"&&e.method==="GET"){let{coloToCountry:i}=await Promise.resolve().then(()=>(Pe(),St)),a=e.cf?.colo??"",l=a?i(a):"";return new Response(JSON.stringify({ok:!0,colo:a,region:l,timestamp:new Date().toISOString()},null,2),{status:200,headers:{"Content-Type":"application/json; charset=utf-8"}})}let r=await Tr(t);if(o.pathname===__sfx("L19fZGlhZw==")){if(vr(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(Vt/1e3))}});if(!kr(e,r.uuid))return null;let{recentDiagnostics:i,diagnosticCounters:a,recentRoutes:l}=await Promise.resolve().then(()=>(Dt(),nr)),{[__sfx("cmVjZW50WGh0dHBEaWFnbm9zdGljcw==")]:f}=await Promise.resolve().then(()=>(Ht(),fr));return new Response(JSON.stringify({ok:!0,impl:"self",build:Bt,recent:i(),[__sfx("eGh0dHA=")]:f(),counters:a(),routes:l()},null,2),{status:200,headers:{"Content-Type":"application/json; charset=utf-8","Cache-Control":"no-store"}})}if(o.pathname==="/__unlock_probe"){if(!r.unlockProbe)return null;if(vr(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(!kr(e,r.uuid))return null;let{coloToCountry:i}=await Promise.resolve().then(()=>(Pe(),St)),{runUnlockProbe:a}=await Promise.resolve().then(()=>(Cr(),Rr)),l=e.cf?.colo??"",f=l?i(l):"",u=await a(l,f);return new Response(JSON.stringify({ok:!0,...u},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 je(e,__sfx("dmxlc3M="),r,Wt(r),n):r[__sfx("ZW5hYmxlVHJvamFu")]&&o.pathname===r[__sfx("dHJvamFuUGF0aA==")]?s!==__sfx("d2Vic29ja2V0")?null:await je(e,__sfx("dHJvamFu"),r,Wt(r),n):r[__sfx("ZW5hYmxlWGh0dHA=")]&&Lt(o.pathname,r[__sfx("eGh0dHBQYXRo")])?await Mt(e,r,Wt(r)):null}Ft();var Al={async fetch(e,t,n){try{return new URL(e.url).pathname===_e?Je():await Ir(e,t,n)??Xt(200)}catch{return Xt(500)}}};export{Al as default};
|
|
5
|
+
`):__sfx("5Ye656uZ6L+e5o6l5aSx6LSl77ya")+String(B)+"";Q(`${m.hostname}:${m.port}`,P,C),U(1011,C);return}let M=d.writable.getWriter();g=M,er(`${m.hostname}:${m.port}`,d,"initial");let D=l.byteLength>m.headerLength?l.subarray(m.headerLength):new Uint8Array(0);l=new Uint8Array(0);try{await y.run(async()=>{D.byteLength>0&&(et(D),await M.write(D)),await _t(M)})}catch(C){Q(`${m.hostname}:${m.port}`,[],__sfx("5LiK6KGM6aaW5YyF5YaZ5YWl5aSx6LSl77ya")+String(C)+""),h()}r?.waitUntil(Yt())},Qt=async m=>{if(K||R)return;let b=N;if(!b){U(1011,__sfx("5Ye656uZ5peg5pWw5o2u77ya55uu5qCH5pyq6Kej5p6Q"));return}if(j>=Ut){U(1011,__sfx("5Ye656uZ5peg5pWw5o2u77ya55u06L+e5LiO5Y+N5Luj5YWl5Y+j5Z2H5peg5ZON5bqU"));return}R=!0;let P=bn({via:d?.via,port:b.port,userProxyConfigured:o.length>0||!!n[__sfx("cHJveHlJcA==")],aggressive:n.aggressiveRedial===!0});if(!P.allowed){de.guardedRedials++,Q(`${b.hostname}:${b.port}`,[],__sfx("5Ye656uZ5peg5pWw5o2u77ya")+P.reason+__sfx("77yb5pyq5YiH5o2i5Y+N5Luj77yI5Y+v5byA5ZCvIGFnZ3Jlc3NpdmVSZWRpYWzvvIk=")),U(1011,__sfx("5Ye656uZ5peg5pWw5o2u77ya")+P.reason+"");return}j++,m==="stall"?de.stallRedials++:de.eofRedials++,Q(`${b.hostname}:${b.port}`,[],m==="stall"?__sfx("55u06L+eIA==")+Qn+__sfx("bXMg5peg5LiL6KGM5pWw5o2u77yM5pS56LWw5Y+N5Luj5YWl5Y+j"):__sfx("5Ye656uZ6Zu25LiL6KGM5Y2zIEVPRi9SZXNldO+8jOeri+WNs+aUuei1sOWPjeS7o+WFpeWPow=="));let B=[];try{B=await xe({userEntries:n.relayPool||void 0,useBuiltin:n.useBuiltinRelay})}catch{B=[]}let M=B.filter(D=>!v.has(`${D.ip}:${D.port}`));if(M.length===0){U(1011,__sfx("5Ye656uZ5peg5pWw5o2u77ya5peg5Y+N5Luj5YWl5Y+j5Y+v55So"));return}for(let D of M.slice(0,Ut)){if(v.add(`${D.ip}:${D.port}`),Ur(),d){let C=d;if(C.close)try{C.close()}catch{}}g=null,ae=0;try{let C=await fe({hostname:D.ip,port:D.port,timeoutMs:Jn,resolvePreferred:!1,skipTargetPolicy:!0,proxies:n.aggressiveRedial?o:void 0,proxyMode:n.aggressiveRedial?n.proxyMode:void 0});if(!C)continue;d=C,er(`${b.hostname}:${b.port}`,C,"redial");let he=C.writable.getWriter();g=he;let $t=0;for(let Ce of O)$t+=Ce.byteLength;let rt=new Uint8Array($t),en=0;for(let Ce of O)rt.set(Ce,en),en+=Ce.byteLength;await y.run(async()=>{rt.byteLength>0&&await he.write(rt),await _t(he)}),Q(`${b.hostname}:${b.port}`,[],__sfx("5bey5YiH5o2i5Y+N5Luj5YWl5Y+jIA==")+D.ip+":"+D.port+""),r?.waitUntil(Yt());return}catch(C){Q(`${b.hostname}:${b.port}`,[],__sfx("5Y+N5Luj5YWl5Y+jIA==")+D.ip+":"+D.port+__sfx("IOWksei0pe+8mg==")+String(C)+"")}}U(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(p(),jt.add(P.byteLength)){Zt();return}if(!c){if(l=yn(l,P),l.byteLength>Wo){U(1009,__sfx("5o+h5omL5aS06LaF6L+HIDY0S0I="));return}await nt();return}if(Y){Y.push(P);return}if(!g){if(f.push(P),u+=P.byteLength,u>qn){U(1009,__sfx("5ouo5Y+35pyf6Ze05pWw5o2u6L+H5aSa"));return}return}et(P),await Dr(P)}})()});let qt=()=>{h()};a.addEventListener("close",qt),a.addEventListener("error",qt),l.byteLength>0?nt().catch(m=>U(1011,String(m))):T=setTimeout(()=>{T=null,!(K||c||l.byteLength>0)&&(de.firstPacketTimeouts++,U(1008,__sfx("6aaW5YyF6LaF5pe277ya5pyq5pS25Yiw5Y2P6K6u5aS0")))},_o);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 Jn,Qn,Ut,Wo,qn,Vo,Ve,ze,$n,de,Ye,Zo,_o,Dt=S(()=>{"use strict";ct();hn();gn();we();wn();xn();It();We();At();Pe();Jn=5e3,Qn=2500,Ut=2,Wo=64*1024,qn=8*1024*1024,Vo=32*1024*1024,Ve=0;ze=[],$n=20,de={stallRedials:0,eofRedials:0,guardedRedials:0,firstPacketTimeouts:0,downlinkYields:0};Ye=[];Zo=2e3,_o=8e3});var fr={};ve(fr,{[__sfx("Y2xlYXJYaHR0cFNlc3Npb25z")]:()=>rs,[__sfx("aGFuZGxlWGh0dHA=")]:()=>Mt,[__sfx("aXNYaHR0cFBhdGg=")]:()=>Lt,[__sfx("cGFyc2VYaHR0cFJvdXRl")]:()=>Nt,[__sfx("cmVjZW50WGh0dHBEaWFnbm9zdGljcw==")]:()=>$o,[__sfx("cmVjb3JkWGh0dHBEaWFnbm9zdGljcw==")]:()=>z});function qo(e,t){return new Promise(n=>{let o=setTimeout(()=>n(null),t);e.then(r=>{clearTimeout(o),n(r)},()=>{clearTimeout(o),n(null)})})}function z(e,t,n){Ze.unshift({at:Date.now(),target:e,...t,summary:n}),Ze.length>20&&(Ze.length=20)}function $o(){return Ze}function es(e){return String(e||"").trim().replace(/\/+$/,"")||"/"}function Nt(e,t){let n=es(t??__sfx("L3hodHRw"));if(e===n||e===`${n}/`)return{kind:"stream-one"};let o=`${n}/`;if(!e.startsWith(o))return null;let r=e.slice(o.length);if(!r)return null;let s=r.split("/");if(s.length===1&&s[0])return/[\s\u0000-\u001f]/.test(s[0])?null:{kind:"session",sessionId:s[0]};if(s.length===2&&s[0]&&/^\d+$/.test(s[1])){if(/[\s\u0000-\u001f]/.test(s[0]))return null;let i=Number(s[1]);return!Number.isSafeInteger(i)||i<0||i>1e6?null:{kind:__sfx("cGFja2V0LXVw"),sessionId:s[0],seq:i}}return null}function Lt(e,t){return Nt(e,t)!==null}function lr(e){if(e.reservedBytes<=0){e.reservedBytes=0;return}Ee=Math.max(0,Ee-e.reservedBytes),e.reservedBytes=0}function ir(e,t){return t<=0?!0:Ee+t>ns?!1:(Ee+=t,e.reservedBytes+=t,!0)}function rs(){for(let[e,t]of W)V(e,t);W.clear(),Ee=0}function os(e,t){return t-e.lastUploadAt>Ot&&t-e.lastDownlinkAt>Ot&&t-e.lastActivityAt>Ot}function ss(e,t){return e.closed?!0:e.header||e.dialResult||e.downlinkStarted?!1:t-e.createdAt>ar}function ur(e,t,n,o){let r=Date.now();for(let[a,l]of W)(l.closed||os(l,r)||r-l.createdAt>30*6e4)&&V(a,l);let s=W.get(e);if(s)return cr(s,n,r),s;if(W.size>=rr){for(let[a,l]of W)ss(l,r)&&V(a,l);if(W.size>=rr)return null}if(!o){let a=0;for(let l of W.values())l.header||(a+=1);if(a>=ts)return null}let i={id:e,createdAt:r,lastUploadAt:r,lastDownlinkAt:r,lastActivityAt:r,header:void 0,headerWaiters:[],dialPromise:null,dialResult:null,pending:new Map,reservedBytes:0,nextPumpSeq:0,pumpStarted:!1,signalResolve:null,traffic:new ue(t),downlinkStarted:!1,closed:!1,targetLabel:""};return W.set(e,i),i}function cr(e,t,n){t==="upload"?e.lastUploadAt=n:e.lastDownlinkAt=n,e.lastActivityAt=n}function V(e,t){if(!t.closed){t.closed=!0;for(let n of t.headerWaiters)try{n(null)}catch{}if(t.headerWaiters=[],t.signalResolve?.(),t.signalResolve=null,t.dialResult?.close)try{t.dialResult.close()}catch{}lr(t),t.pending.clear(),W.delete(e)}}function is(e){let t=e.signalResolve;e.signalResolve=null,t?.()}function as(e,t){return e.header?Promise.resolve(e.header):e.closed?Promise.resolve(null):new Promise(n=>{let o=s=>{clearTimeout(r),n(s)},r=setTimeout(()=>{let s=e.headerWaiters.indexOf(o);s>=0&&e.headerWaiters.splice(s,1),n(null)},t);e.headerWaiters.push(o)})}function ls(e,t){e.header=t;let n=e.headerWaiters;e.headerWaiters=[];for(let o of n)try{o(t)}catch{}}function L(e){let t=100+Math.floor(Math.random()*900);return{"Content-Type":"text/event-stream","Cache-Control":"no-store","X-Accel-Buffering":"no","Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET, POST","X-Padding":"X".repeat(t),...e}}function us(e){let t=e.addons,n=new Uint8Array(2+t.byteLength);return n[0]=e.version,n[1]=t.byteLength,n.set(t,2),n}async function cs(e,t,n){if(e.dialResult)return e.dialResult;if(!e.dialPromise){let o=e.header;if(!o)throw new Error(__sfx("VkxFU1Mg5aS05pyq5Yiw6L6+"));e.targetLabel=`${o.hostname}:${o.port}`,e.dialPromise=fe({hostname:o.hostname,port:o.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:r=>{z(e.targetLabel,r,__sfx("WEhUVFAg5Ye656uZ5aSx6LSl77yI")+r.candidate+"):"+r.message+"")}}).then(r=>(e.dialResult=r,r)).catch(r=>{throw z(e.targetLabel,{kind:"dial",message:String(r),candidate:"all"},__sfx("WEhUVFAg5Ye656uZ5YWo6YOo5aSx6LSl77ya")+String(r)+""),r})}return await e.dialPromise}async function fs(e,t){let n=t.writable.getWriter();try{for(;!e.closed;){let o=e.pending.get(e.nextPumpSeq);if(o){if(e.pending.delete(e.nextPumpSeq),e.nextPumpSeq+=1,lr(e),o.byteLength===0)continue;if(e.traffic.add(o.byteLength)){z(e.targetLabel,{kind:"budget",message:__sfx("5rWB6YeP6LaF6ZmQ"),candidate:"traffic"},__sfx("WEhUVFAg5LiK6KGM5rWB6YeP6LaF6ZmQ"));break}try{await n.write(o)}catch(i){z(e.targetLabel,{kind:"relay-write",message:String(i),candidate:t.endpoint},__sfx("WEhUVFAg5YaZ5YWl55uu5qCH5aSx6LSl77ya")+String(i)+"");break}continue}let r=null,s=new Promise(i=>{r=i});if(e.signalResolve=r,e.pending.has(e.nextPumpSeq)||e.closed){e.signalResolve=null;continue}await s}}finally{try{n.releaseLock()}catch{}}}async function ds(e,t,n,o,r){let s=(t.dataBudgetMB||0)*1024*1024,i=ur(o,s,"upload",r===0);if(!i)return new Response(__sfx("5Lya6K+d5pWw5bey6L6+5LiK6ZmQ77yM6K+356iN5ZCO6YeN6K+V"),{status:503,headers:L()});if(i.closed)return null;let a=Number(e.headers.get("content-length")??"");if(Number.isFinite(a)&&a>or)return new Response(__sfx("5YiG5YyF6LaF5Ye65LiK6ZmQ"),{status:413,headers:L()});let l;try{let f=await e.arrayBuffer();l=new Uint8Array(f)}catch{return new Response(__sfx("6K+35rGC5L2T6K+75Y+W5aSx6LSl"),{status:400,headers:L()})}if(l.byteLength>or)return new Response(__sfx("5YiG5YyF6LaF5Ye65LiK6ZmQ"),{status:413,headers:L()});if(r===0&&!i.header){let f=Ue(l,t.uuid);if(!f)return V(o,i),new Response(__sfx("VkxFU1Mg5aS06Kej5p6Q5aSx6LSl"),{status:400,headers:L()});if(f.header.command!==ut)return V(o,i),new Response(__sfx("WEhUVFAg5pqC5LiN5pSv5oyBIFVEUA=="),{status:400,headers:L()});ls(i,f.header),i.targetLabel=`${f.header.hostname}:${f.header.port}`;let u=l.subarray(f.consumed);if(r>=i.nextPumpSeq&&!i.pending.has(r)){if(i.pending.size>=sr)return V(o,i),new Response(__sfx("5YiG5YyF57yT5a2Y5bey5ruh"),{status:503,headers:L()});if(!ir(i,u.byteLength))return V(o,i),new Response(__sfx("5pqC5a2Y6LaF6ZmQ"),{status:503,headers:L()});i.pending.set(r,u.slice())}}else{if(r<i.nextPumpSeq||i.pending.has(r))return new Response(null,{status:200,headers:L()});if(i.pending.size>=sr)return V(o,i),new Response(__sfx("5YiG5YyF57yT5a2Y5bey5ruh"),{status:503,headers:L()});if(!ir(i,l.byteLength))return V(o,i),new Response(__sfx("5pqC5a2Y6LaF6ZmQ"),{status:503,headers:L()});i.pending.set(r,l.slice())}return is(i),new Response(null,{status:200,headers:L()})}async function ps(e,t,n,o){let r=(t.dataBudgetMB||0)*1024*1024,s=ur(o,r,"downlink",!1);if(!s)return new Response(__sfx("5Lya6K+d5pWw5bey6L6+5LiK6ZmQ77yM6K+356iN5ZCO6YeN6K+V"),{status:503,headers:L()});if(s.closed||s.downlinkStarted)return null;s.downlinkStarted=!0;let i=as(s,ar),a=!1,l=null,f=null,u=!1,c=null,d=()=>{V(o,s)},g=new ReadableStream({start(y){f=y},async pull(y){if(!a)try{if(!u){let p=await i;if(a)return;if(!p){d(),y.close();return}try{c=await cs(s,t,n)}catch{d(),y.close();return}if(a)return;s.pumpStarted||(s.pumpStarted=!0,fs(s,c).catch(()=>{}));try{y.enqueue(us(p))}catch{}u=!0;return}if(!c)return;l||(l=c.readable.getReader());let{done:x,value:T}=await l.read();if(a)return;if(x){d();try{y.close()}catch{}return}if(T&&T.byteLength>0){if(cr(s,"downlink",Date.now()),s.traffic.add(T.byteLength)){z(s.targetLabel,{kind:"budget",message:__sfx("5rWB6YeP6LaF6ZmQ"),candidate:"traffic"},__sfx("WEhUVFAg5LiL6KGM5rWB6YeP6LaF6ZmQ")),d();try{y.close()}catch{}return}y.enqueue(T)}}catch(x){if(a)return;d();try{y.error(x)}catch{}}},cancel(y){if(a=!0,c)try{c.readable.cancel(y)}catch{}d()}});return new Response(g,{status:200,headers:L()})}async function Mt(e,t,n){let o=__sfx("L3hodHRw");try{o=new URL(e.url).pathname}catch{o=__sfx("L3hodHRw")}let r=Nt(o,t[__sfx("eGh0dHBQYXRo")]);return r?r.kind==="stream-one"?e.method!=="POST"?null:await ms(e,t,n):r.kind===__sfx("cGFja2V0LXVw")?e.method!=="POST"?null:await ds(e,t,n,r.sessionId,r.seq):e.method==="GET"?await ps(e,t,n,r.sessionId):null:null}async function ms(e,t,n){let o=e.body;if(!o)return new Response(__sfx("57y65bCR6K+35rGC5L2T"),{status:400});let r=new ne(o),s=await qo(ln(r,t.uuid),Qo);if(!s)return await r.cancel("header timeout"),new Response(__sfx("VkxFU1Mg5aS06Kej5p6Q5aSx6LSl"),{status:400});if(s.header.command!==ut)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:p=>{z(`${s.header.hostname}:${s.header.port}`,p,__sfx("WEhUVFAg5Ye656uZ5aSx6LSl77yI")+p.candidate+"):"+p.message+"")}})}catch(p){z(`${s.header.hostname}:${s.header.port}`,{kind:"dial",message:String(p),candidate:"all"},__sfx("WEhUVFAg5Ye656uZ5YWo6YOo5aSx6LSl77ya")+String(p)+"");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,u=null,c=!1,d=new ue((t.dataBudgetMB||0)*1024*1024),g=null,y=()=>{if(c)return;c=!0;let p=__sfx("5Y2V6L+e5o6l5rWB6YeP6LaF6L+HIA==")+t.dataBudgetMB+__sfx("TUIg5LiK6ZmQ");if(z(`${s.header.hostname}:${s.header.port}`,{kind:"budget",message:p,candidate:"traffic"},p),i.close)try{i.close()}catch{}try{g?.close()}catch{}},x=p=>d.add(p)?(y(),!0):!1;_n(s.payload,i.writable,void 0,!1,x,(p,R)=>{let E=p instanceof Error?p.message:String(p),k=`relay-${R}`;/cancel|abort|closed/i.test(E)?k=`relay-${R}-client-cancel`:/reset|broken pipe/i.test(E)&&(k=`relay-${R}-upstream-reset`),z(`${s.header.hostname}:${s.header.port}`,{kind:k,message:E.slice(0,200),candidate:i.endpoint},__sfx("WEhUVFAg5Lit57un")+R==="read"?"\u8BFB\u4E0A\u6E38":"\u5199\u76EE\u6807"+__sfx("5aSx6LSl77yI")+k+"):"+E.slice(0,120)+"")}).catch(()=>{});let T=new ReadableStream({start(p){g=p,p.enqueue(l),f=!0},async pull(p){if(!(c||!f)){u||(u=i.readable.getReader());try{let{done:R,value:E}=await u.read();if(c)return;if(R){if(i.close)try{i.close()}catch{}p.close();return}if(E&&E.byteLength>0){if(d.add(E.byteLength)){y();return}p.enqueue(E)}}catch(R){if(c)return;if(i.close)try{i.close()}catch{}try{p.error(R)}catch{}}}},cancel(p){c=!0;try{i.readable.cancel(p)}catch{}if(i.close)try{i.close()}catch{}}});return new Response(T,{status:200,headers:{"Content-Type":"text/event-stream","Cache-Control":"no-store","X-Accel-Buffering":"no"}})}var Qo,Ze,W,ar,rr,ts,Ot,or,sr,ns,Ee,Ht=S(()=>{"use strict";we();ct();We();It();Qo=2e3;Ze=[];W=new Map,ar=3e4,rr=100,ts=20,Ot=10*6e4,or=10*1024*1024,sr=30,ns=32*1024*1024,Ee=0});function Je(){return new Response(JSON.stringify({build:Bt,version:hs,ts:Date.now()}),{status:200,headers:{"Content-Type":"application/json","Cache-Control":"no-store","Access-Control-Allow-Origin":"*"}})}var Bt,hs,_e,Ft=S(()=>{"use strict";Bt="daf280f-82ab544c",hs=__sfx("MC4zMy43"),_e=__sfx("L19fY2ZwX3ZlcnNpb24=")});function dr(e){return e[__sfx("S1Y=")]?new pe(e[__sfx("S1Y=")]):new Kt}var pe,Kt,Qe=S(()=>{"use strict";pe=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}},Kt=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 ce(e,t){if(e==null)return t;let n=String(e).trim();if(n==="")return t;let o=Number(n);return Number.isFinite(o)?o:t}function F(e,t){if(e==null||e==="")return t;let n=String(e).trim().toLowerCase();return["1","true","yes","on"].includes(n)?!0:["0","false","no","off"].includes(n)?!1:t}function gs(e){let t=e.trim().toLowerCase();return t==="global"||t==="fallback"||t==="smart"?t:"only"}function mr(e){return e.trim().toLowerCase()==="signed"?"signed":"legacy"}function hr(e){return e.trim().toLowerCase()==="doh"?"doh":"off"}function I(e,t){return e==null?t:String(e)}function ys(e){return{uuid:I(e[__sfx("VVVJRA==")],""),[__sfx("dHJvamFuUGFzc3dvcmQ=")]:I(e[__sfx("VFJPSkFOX1BBU1NXT1JE")],""),wsPath:I(e[__sfx("V1NfUEFUSA==")]||e[__sfx("UEFUSA==")],A.wsPath),[__sfx("dHJvamFuUGF0aA==")]:A[__sfx("dHJvamFuUGF0aA==")],[__sfx("eGh0dHBQYXRo")]:A[__sfx("eGh0dHBQYXRo")],add:I(e[__sfx("QURE")],""),addApi:I(e[__sfx("QUREQVBJ")],""),addCsv:I(e[__sfx("QUREX0NTVg==")],""),poolOfficial:F(e[__sfx("T0ZGSUNJQUxfSVA=")],A.poolOfficial),officialCount:ce(e[__sfx("T0ZGSUNJQUxfSVBfQ09VTlQ=")],A.officialCount),poolDomain:F(e[__sfx("UFJFRkVSUkVEX0RPTUFJTg==")],A.poolDomain),domainCount:ce(e[__sfx("UFJFRkVSUkVEX0RPTUFJTl9DT1VOVA==")],A.domainCount),poolManual:F(e[__sfx("TUFOVUFMX0lQ")],A.poolManual),poolCountries:I(e[__sfx("UE9PTF9DT1VOVFJJRVM=")],A.poolCountries),dls:ce(e[__sfx("RExT")],0),maxLatency:ce(e[__sfx("TUFYX0xBVEVOQ1k=")],0),maxNodes:0,[__sfx("cHJveHlJcA==")]:I(e[__sfx("UFJPWFlJUA==")],""),[__sfx("c29ja3M1")]:I(e[__sfx("U09DS1M1")],""),httpProxy:I(e[__sfx("SFRUUF9QUk9YWQ==")],""),proxyMode:gs(I(e[__sfx("UFJPWFlfTU9ERQ==")],"")),nat64:I(e[__sfx("TkFUNjQ=")],""),concurrentDial:F(e[__sfx("VENQX0NPTkNVUlJFTlRfRElBTA==")],!0),dataBudgetMB:ce(e[__sfx("REFUQV9CVURHRVRfTUI=")],A.dataBudgetMB),resolvePreferred:F(e[__sfx("UkVTT0xWRV9QUkVGRVJSRUQ=")],A.resolvePreferred),aggressiveRedial:F(e[__sfx("QUdHUkVTU0lWRV9SRURJQUw=")],A.aggressiveRedial),relayPool:I(e[__sfx("UkVMQVlfUE9PTA==")],""),useBuiltinRelay:F(e[__sfx("VVNFX0JVSUxUSU5fUkVMQVk=")],A.useBuiltinRelay),[__sfx("ZW5hYmxlVHJvamFu")]:F(e[__sfx("RU5BQkxFX1RST0pBTg==")]??e[__sfx("VFJPSkFO")],A[__sfx("ZW5hYmxlVHJvamFu")]),[__sfx("ZW5hYmxlWGh0dHA=")]:F(e[__sfx("RU5BQkxFX1hIVFRQ")]??e[__sfx("WEhUVFA=")],A[__sfx("ZW5hYmxlWGh0dHA=")]),subDomain:"",subProtocol:"both",subTransport:"both",subVariants:I(e[__sfx("U1VCX1ZBUklBTlRT")],A.subVariants),subName:I(e[__sfx("U1VCX05BTUU=")],A.subName).trim()||A.subName,subPorts:I(e[__sfx("U1VCX1BPUlRT")],A.subPorts),clientFingerprint:A.clientFingerprint,ech:F(e[__sfx("RUNI")],A.ech),echHost:I(e[__sfx("RUNIX0hPU1Q=")],A.echHost),echDns:I(e[__sfx("RUNIX0ROUw==")],A.echDns),tlsFragment:!1,tlsFragmentSize:A.tlsFragmentSize,tlsFragmentDelay:A.tlsFragmentDelay,subToken:mr(I(e[__sfx("U1VCX1RPS0VOX01PREU=")],"")),subTokenTtlDays:ce(e[__sfx("U1VCX1RPS0VOX1RUTF9EQVlT")],A.subTokenTtlDays),unlockProbe:F(e[__sfx("VU5MT0NLX1BST0JF")],A.unlockProbe),udpDns:hr(I(e[__sfx("VURQX0ROUw==")],"")),udpDnsEndpoint:I(e[__sfx("VURQX0ROU19FTkRQT0lOVA==")],A.udpDnsEndpoint)}}function bs(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]=ce(r,0);else if(o==="concurrentDial"||o==="resolvePreferred"||o==="aggressiveRedial"||o==="useBuiltinRelay"||o===__sfx("ZW5hYmxlVHJvamFu")||o===__sfx("ZW5hYmxlWGh0dHA=")||o==="tlsFragment"||o==="ech"||o==="poolOfficial"||o==="poolDomain"||o==="poolManual"||o==="unlockProbe")n[o]=F(r,!1);else if(o==="subProtocol"){let s=String(r);n[o]=s===__sfx("dmxlc3M=")||s===__sfx("dHJvamFu")||s==="both"?s:"both"}else if(o==="subTransport"){let s=String(r);n[o]=s==="ws"||s===__sfx("eGh0dHA=")||s==="both"?s:"both"}else o==="subToken"?n[o]=mr(String(r)):o==="udpDns"?n[o]=hr(String(r)):n[o]=String(r);return n}async function gr(e,t){let n=ys(t),o=await e.get(pr),r={};if(o)try{r=JSON.parse(o)}catch{r={}}let s=bs(n,r),i=!1,a=e instanceof pe,l=Date.now();o?Ae=0:Ae===0&&(Ae=l);let f=l-Ae>ws;return a&&f&&(s.uuid||(s.uuid=ot(),i=!0),s[__sfx("dHJvamFuUGFzc3dvcmQ=")]||(s[__sfx("dHJvamFuUGFzc3dvcmQ=")]=ot().replace(/-/g,"").slice(0,16),i=!0),Ae=0),o&&(s.officialCount<1||s.domainCount<1)&&(s.officialCount<1&&(s.officialCount=A.officialCount,i=!0),s.domainCount<1&&(s.domainCount=A.domainCount,i=!0)),i&&await xs(e,s),s}async function xs(e,t){await e.put(pr,JSON.stringify(t))}var pr,A,Ae,ws,qe=S(()=>{"use strict";ee();Qe();pr="CONFIG",A={uuid:"",[__sfx("dHJvamFuUGFzc3dvcmQ=")]:"",wsPath:__sfx("L3ZsZXNz"),[__sfx("dHJvamFuUGF0aA==")]:__sfx("L3Ryb2phbg=="),[__sfx("eGh0dHBQYXRo")]:__sfx("L3hodHRw"),add:"",addApi:"",addCsv:"",poolOfficial:!0,officialCount:20,poolDomain:!0,domainCount:10,poolManual:!0,poolCountries:"",dls:0,maxLatency:0,maxNodes:0,[__sfx("cHJveHlJcA==")]:"",[__sfx("c29ja3M1")]:"",httpProxy:"",proxyMode:"only",nat64:"",concurrentDial:!0,dataBudgetMB:0,resolvePreferred:!0,aggressiveRedial:!1,relayPool:"",useBuiltinRelay:!0,[__sfx("ZW5hYmxlVHJvamFu")]:!0,[__sfx("ZW5hYmxlWGh0dHA=")]:!0,subDomain:"",subProtocol:__sfx("dmxlc3M="),subTransport:"ws",subVariants:__sfx("dmxlc3Mtd3M="),subName:__sfx("Q0ZQaWxvdA=="),subPorts:"443",clientFingerprint:"chrome",ech:!1,echHost:__sfx("Y2xvdWRmbGFyZS1lY2guY29t"),echDns:"",tlsFragment:!1,tlsFragmentSize:"10-20",tlsFragmentDelay:"10-20",subToken:"legacy",subTokenTtlDays:0,unlockProbe:!1,udpDns:"off",udpDnsEndpoint:"https://dns.google/dns-query"};Ae=0,ws=9e4});var yr,Ps,Yi,Ss,ji,br=S(()=>{"use strict";yr={[__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"]},Ps=__sfx("SEtH6aaZ5rivLFRQReWPsOWMlyxOUlTkuJzkuqwsS0lY5aSn6ZiqLElDTummluWwlCxTSU7mlrDliqDlnaEsS1VM5ZCJ6ZqG5Z2hLEJLS+abvOiwtyxTR07og6Hlv5fmmI7luIIsTU5M6ams5bC85ouJLFNZROaCieWwvCxNRUzloqjlsJTmnKwsTEFY5rSb5p2J55+2LFNKQ+Wco+S9leWhnixTRUHopb/pm4Xlm74sT1JE6Iqd5Yqg5ZOlLElBROWNjuebm+mhvyxFV1Lnur3nk6blhYssWVla5aSa5Lym5aSaLFlWUua4qeWTpeWNjixMSFLkvKbmlaYsRlJB5rOV5YWw5YWL56aPLENER+W3tOm7jixBTVPpmL/lp4bmlq/nibnkuLksTUFE6ams5b636YeMLEFSTuaWr+W+t+WTpeWwlOaRqSxJU1TkvIrmlq/lnabluIPlsJQsRFhC6L+q5ouc"),Yi=(()=>{let e={};for(let t of Ps.split(","))t.length>3&&(e[t.slice(0,3)]=t.slice(3));return e})(),Ss=new Map;for(let[e,t]of Object.entries(yr))for(let n of t)Ss.set(n,e);ji=Object.keys(yr)});var _i,wr=S(()=>{"use strict";_i=new Set("GEOSITE GEOIP GEOIP-CIDR DOMAIN DOMAIN-SUFFIX DOMAIN-KEYWORD IP-CIDR IP-CIDR6 SRC-IP-CIDR DST-PORT SRC-PORT PROCESS-NAME MATCH".split(" "))});var fa,xr=S(()=>{"use strict";X();ee();br();wr();fa=".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 ha,Pr=S(()=>{"use strict";Qe();ee();ha=new TextEncoder});var Da,Sr=S(()=>{"use strict";qe();ee();Da=3600*24});function Er(e){return dr(e)}async function Ar(e,t){if(Te.config&&Date.now()-Te.configAt<Es)return Te.config;let n=await gr(e,t);return Te.config=n,Te.configAt=Date.now(),n}var Es,Te,Gt=S(()=>{"use strict";Qe();qe();Sr();Es=15e3,Te={config:null,configAt:0,auth:null,authAt:0}});var Rr={};ve(Rr,{clearUnlockCache:()=>Ds,runUnlockProbe:()=>Us});function ks(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 Is(e){let t=Date.now(),n=new AbortController,o=setTimeout(()=>n.abort(),Rs);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:ks(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 Us(e,t){let n=e||"UNK",o=Date.now(),r=me.get(n);if(r&&o-r.at<Cs)return{...r.data,cached:!0};let s=await Promise.all(Ts.map(a=>Is(a))),i={colo:n,region:t,cached:!1,at:o,targets:s};if(me.size>=vs){let a="",l=Number[__sfx("UE9TSVRJVkVfSU5GSU5JVFk=")];for(let[f,u]of me)u.at<l&&(l=u.at,a=f);a&&me.delete(a)}return me.set(n,{at:o,data:i}),i}function Ds(){me.clear()}var Ts,Rs,Cs,vs,me,Cr=S(()=>{"use strict";Ts=[{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"}],Rs=4e3,Cs=600*1e3,vs=16,me=new Map});ee();var Mr=8*1024*1024,Hr=2*1024*1024,nn=600*1e3,Br=6*1024*1024*1024,st=Date.now(),it=0;function rn(e){e-st>=nn&&(st=e,it=0)}function Fr(e,t=Date.now()){rn(t),it+=e}function tn(e){return rn(e),Br-it}var Kr=(()=>{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})(),Xr=5e3;function Gr(e,t=Xr){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 at(e){let t=new URL(e.url);if(e.headers.get("Upgrade")?.toLowerCase()===__sfx("d2Vic29ja2V0")){let f=new WebSocketPair,[u,c]=Object.values(f);c.accept();let d=Gr((g,y)=>c.close(g,y));return c.addEventListener("message",g=>{let y=typeof g.data=="string"?g.data:"";if(y==="PING"||y==="ping"){d.cancel(),c.send(JSON.stringify({pong:!0,colo:e.cf?.colo??"UNK",clientIp:e.headers.get("CF-Connecting-IP")??""}));try{c.close(1e3,"Probe complete")}catch{}return}d.cancel();try{c.close(1e3,"Probe aborted")}catch{}}),c.addEventListener("close",()=>d.cancel()),c.addEventListener("error",()=>d.cancel()),new Response(null,{status:101,[__sfx("d2ViU29ja2V0")]:u})}let o=Number.parseInt(t.searchParams.get("bytes")??"",10),r=Number.isFinite(o)&&o>0?Math.min(o,Mr):Hr,s=Date.now();if(tn(s)<=0){let f=Math.max(1e3,st+nn-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=Kr,a=0,l=new ReadableStream({pull(f){let u=tn(Date.now());if(a>=r||u<=0){f.close();return}let c=Math.min(i.byteLength,r-a,u);f.enqueue(i.subarray(0,c)),a+=c,Fr(c)}});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":Ie(4)}})}Dt();Ht();Tt();Ft();ee();qe();We();xr();Pr();ee();function Xt(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"}})}Gt();Gt();async function Tr(e){let t=Er(e);return await Ar(t,e)}function Wt(e){let t=[];return t.push(...Se(e[__sfx("cHJveHlJcA==")],"direct")),t.push(...Se(e[__sfx("c29ja3M1")],__sfx("c29ja3M1"))),t.push(...Se(e.httpProxy,"http")),t}var Vt=6e4,Os=10,Re=0,$e=0;function vr(e){return e>=$e?(Re=0,$e=e+Vt,!1):Re>=Os}function kr(e,t){if(!t)return!1;let n=(e.headers.get(__sfx("eC1jZnBpbG90LXRva2Vu"))??"").trim();if(!n)return!1;let o=Date.now();return ge(n,t)?(Re=0,!0):(o>=$e&&($e=o+Vt,Re=0),Re+=1,!1)}async function Ir(e,t,n){let o=new URL(e.url);if(o.pathname===__sfx("L19fZWRnZV9wcm9iZQ=="))return at(e);if(o.pathname===_e||o.pathname===__sfx("L19fdmVyc2lvbg=="))return Je();if(o.pathname==="/region"&&e.method==="GET"){let{coloToCountry:i}=await Promise.resolve().then(()=>(Pe(),St)),a=e.cf?.colo??"",l=a?i(a):"";return new Response(JSON.stringify({ok:!0,colo:a,region:l,timestamp:new Date().toISOString()},null,2),{status:200,headers:{"Content-Type":"application/json; charset=utf-8"}})}let r=await Tr(t);if(o.pathname===__sfx("L19fZGlhZw==")){if(vr(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(Vt/1e3))}});if(!kr(e,r.uuid))return null;let{recentDiagnostics:i,diagnosticCounters:a,recentRoutes:l}=await Promise.resolve().then(()=>(Dt(),nr)),{[__sfx("cmVjZW50WGh0dHBEaWFnbm9zdGljcw==")]:f}=await Promise.resolve().then(()=>(Ht(),fr));return new Response(JSON.stringify({ok:!0,impl:"self",build:Bt,recent:i(),[__sfx("eGh0dHA=")]:f(),counters:a(),routes:l()},null,2),{status:200,headers:{"Content-Type":"application/json; charset=utf-8","Cache-Control":"no-store"}})}if(o.pathname==="/__unlock_probe"){if(!r.unlockProbe)return null;if(vr(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(!kr(e,r.uuid))return null;let{coloToCountry:i}=await Promise.resolve().then(()=>(Pe(),St)),{runUnlockProbe:a}=await Promise.resolve().then(()=>(Cr(),Rr)),l=e.cf?.colo??"",f=l?i(l):"",u=await a(l,f);return new Response(JSON.stringify({ok:!0,...u},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 je(e,__sfx("dmxlc3M="),r,Wt(r),n):r[__sfx("ZW5hYmxlVHJvamFu")]&&o.pathname===r[__sfx("dHJvamFuUGF0aA==")]?s!==__sfx("d2Vic29ja2V0")?null:await je(e,__sfx("dHJvamFu"),r,Wt(r),n):r[__sfx("ZW5hYmxlWGh0dHA=")]&&Lt(o.pathname,r[__sfx("eGh0dHBQYXRo")])?await Mt(e,r,Wt(r)):null}Ft();var Al={async fetch(e,t,n){try{return new URL(e.url).pathname===_e?Je():await Ir(e,t,n)??Xt(200)}catch{return Xt(500)}}};export{Al as default};
|
package/assets/worker.js
CHANGED
|
@@ -4,7 +4,7 @@ const __sfx=(()=>{const __t=new TextDecoder(),__c=new Map();return b=>{let v=__c
|
|
|
4
4
|
`))),a){let D=""+T+__sfx("IFRyb2phbg==");r.push(D),g.push(D),n.push([__sfx("ICAtIG5hbWU6IA==")+q(D)+"",__sfx("ICAgIHR5cGU6IHRyb2phbg=="),__sfx("ICAgIHBhc3N3b3JkOiA=")+q(e.config.trojanPassword)+"",__sfx("ICAgIHNlcnZlcjog")+h.ip+"",__sfx("ICAgIHBvcnQ6IA==")+S+"",__sfx("ICAgIG5ldHdvcms6IHdz"),__sfx("ICAgIHRsczogdHJ1ZQ=="),__sfx("ICAgIHNuaTog")+e.domain+"",__sfx("ICAgIGNsaWVudC1maW5nZXJwcmludDog")+e.config.clientFingerprint+"",...c()," ws-opts:",__sfx("ICAgICAgcGF0aDog")+q(e.config.trojanPath)+""," headers:",` Host: ${e.domain}`].join(`
|
|
5
5
|
`))}}});t.push(__sfx("IyBDRlBpbG90IOiHquWKqOeUn+aIkOiuoumYhQ==")),t.push(__sfx("bWl4ZWQtcG9ydDogNzg5MA==")),t.push(__sfx("YWxsb3ctbGFuOiBmYWxzZQ==")),t.push(__sfx("bW9kZTogcnVsZQ==")),t.push(__sfx("bG9nLWxldmVsOiBpbmZv")),t.push(__sfx("dW5pZmllZC1kZWxheTogdHJ1ZQ==")),t.push(__sfx("dGNwLWNvbmN1cnJlbnQ6IHRydWU=")),t.push(""),t.push("dns:"),t.push(__sfx("ICBlbmFibGU6IHRydWU=")),t.push(__sfx("ICBpcHY2OiBmYWxzZQ==")),t.push(__sfx("ICBlbmhhbmNlZC1tb2RlOiBmYWtlLWlw")),t.push(__sfx("ICBmYWtlLWlwLXJhbmdlOiAxOTguMTguMC4xLzE2")),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(__sfx("ICAgIGdlb2lwOiB0cnVl")),t.push(__sfx("ICAgIGdlb2lwLWNvZGU6IENO")),t.push(""),l&&(t.push(" nameserver-policy:"),t.push(` ${q(d)}: ${u?q(u):"https://223.5.5.5/dns-query"}`),t.push(""));let f=Yr(e.routeProfile??"",{mainGroup:ge,autoGroup:__sfx("6Ieq5Yqo6YCJ5oup")});if(t.push("proxies:"),n.length===0?t.push(" []"):t.push(...n),t.push(""),t.push(__sfx("cHJveHktZ3JvdXBzOg==")),t.push(__sfx("ICAtIG5hbWU6ICJDRlBpbG90Ig==")),t.push(__sfx("ICAgIHR5cGU6IHNlbGVjdA==")),t.push(" proxies:"),t.push(__sfx("ICAgICAgLSAi6Ieq5Yqo6YCJ5oupIg==")),t.push(__sfx("ICAgICAgLSAi5pWF6Zqc6L2s56e7Ig==")),o.v4.length>0&&t.push(__sfx("ICAgICAgLSAi5LyY6YCJSVB2NCI=")),o.v6.length>0&&t.push(__sfx("ICAgICAgLSAi5LyY6YCJSVB2NiI=")),r.length===0)t.push(" []");else for(let p of r)t.push(` - ${q(p)}`);if(r.length>0){t.push(""),t.push(__sfx("ICAtIG5hbWU6ICLoh6rliqjpgInmi6ki")),t.push(__sfx("ICAgIHR5cGU6IHVybC10ZXN0")),t.push(__sfx("ICAgIHVybDogImh0dHA6Ly93d3cuZ3N0YXRpYy5jb20vZ2VuZXJhdGVfMjA0Ig==")),t.push(__sfx("ICAgIGludGVydmFsOiAzMDA=")),t.push(__sfx("ICAgIHRvbGVyYW5jZTogNTA=")),t.push(" proxies:");for(let h of r)t.push(` - ${q(h)}`);t.push(""),t.push(__sfx("ICAtIG5hbWU6ICLmlYXpmpzovaznp7si")),t.push(__sfx("ICAgIHR5cGU6IGZhbGxiYWNr")),t.push(__sfx("ICAgIHVybDogImh0dHA6Ly93d3cuZ3N0YXRpYy5jb20vZ2VuZXJhdGVfMjA0Ig==")),t.push(__sfx("ICAgIGludGVydmFsOiAzMDA=")),t.push(" proxies:");for(let h of r)t.push(` - ${q(h)}`);let p=(h,y)=>{t.push(""),t.push(__sfx("ICAtIG5hbWU6IA==")+q(h)+""),t.push(__sfx("ICAgIHR5cGU6IHNlbGVjdA==")),t.push(" proxies:");for(let P of y)t.push(` - ${q(P)}`)};o.v4.length>0&&p(__sfx("5LyY6YCJSVB2NA=="),o.v4),o.v6.length>0&&p(__sfx("5LyY6YCJSVB2Ng=="),o.v6)}return f.groups.length>0&&(t.push(""),t.push(...f.groups)),t.push(""),t.push("rules:"),f.rules.length>0?(t.push(...f.rules),f.rules.some(p=>p.includes("MATCH,"))||t.push(` - MATCH,${ge}`)):t.push(...fn(ge)),t.push(""),t.join(`
|
|
6
6
|
`)}function ca(e){let t=[],n=[],r=hn(e.config.subVariants,e.config,so),o=r.some(u=>u===__sfx("dmxlc3Mtd3M=")),i=r.includes(__sfx("dHJvamFu")),s=e.config.ech,a=e.config.echHost.trim()||__sfx("Y2xvdWRmbGFyZS1lY2guY29t"),l=()=>s?{ech:{enabled:!0,query_server_name:a}}:{};for(let u of yn(e)){let c=[];u.entries.forEach((f,p)=>{let h=`${u.name} ${et(f,"vless",p,"")}`;for(let y of wn(f,e)){let P=e.ports.length>1?`:${y}`:"",g=`${h}${P}`,S=""+g+__sfx("IFRyb2phbg==");o&&c.push(g),i&&c.push(S),o&&t.push({type:__sfx("dmxlc3M="),tag:g,server:f.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}}}),i&&t.push({type:__sfx("dHJvamFu"),tag:S,server:f.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}}})}}),c.length>0&&n.push({tag:u.name,members:c})}t.push({type:"direct",tag:"direct"});for(let u of n)t.push({type:"selector",tag:u.tag,outbounds:u.members,default:u.members[0]});return t.push({type:"selector",tag:__sfx("Q0ZQaWxvdA=="),outbounds:n.length>0?n.map(u=>u.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:oo,server:"local"}]},inbounds:[{type:"mixed",tag:"mixed-in",listen:__sfx("MTI3LjAuMC4x"),listen_port:2080}],outbounds:t,route:{rules:[{ip_is_private:!0,outbound:"direct"},{domain_suffix:oo,outbound:"direct"}],final:__sfx("Q0ZQaWxvdA=="),auto_detect_interface:!0}},null,2)}function fa(e){let t=[],n=hn(e.config.subVariants,e.config);for(let r of yn(e))r.entries.forEach((o,i)=>{let s=et(o,__sfx("dmxlc3M="),i,r.name);for(let a of wn(o,e)){let l=e.ports.length>1?`:${a}`:"",d=`${s}${l}`,u={...o,port:a};for(let c of n)c===__sfx("dmxlc3Mtd3M=")?t.push(ro(u,e,"ws",`${d} WS`)):c===__sfx("dmxlc3MteGh0dHA=")?t.push(ro(u,e,__sfx("eGh0dHA="),""+d+__sfx("IFhIVFRQ"))):t.push(la(u,e,""+d+__sfx("IFRyb2phbg==")))}});return Ir(t.join(`
|
|
7
|
-
`))}function po(e,t){let n=bn(t.config.subName);switch(e){case __sfx("Y2xhc2g="):return{body:ua(t),contentType:"text/yaml; charset=utf-8",fileName:n};case"singbox":return{body:ca(t),contentType:"application/json; charset=utf-8",fileName:n};default:return{body:fa(t),contentType:"text/plain; charset=utf-8",fileName:n}}}var Te,Ks,Xs,Zr,Jr,Qr,Gs,zs,Ws,ta,ra,oa,Ae,ia,no,so,sa,oo,Et=k(()=>{"use strict";ie();ce();cn();dn();Te=443;Ks=[__sfx("aXDlnLDlnYA="),__sfx("aXAg5Zyw5Z2A"),"ip",__sfx("5Zyw5Z2A"),__sfx("5pyN5Yqh5Zmo"),"server","host"],Xs=[__sfx("56uv5Y+j"),"port"],Zr=[__sfx("5LiL6L296YCf5bqm"),__sfx("6YCf5bqm"),"speed","download"],Jr=[__sfx("5bmz5Z2H5bu26L+f"),__sfx("5bu26L+f"),"latency","delay",__sfx("5ZON5bqU5pe26Ze0"),"rtt"],Qr=["colo",__sfx("5py65oi/"),__sfx("5pWw5o2u5Lit5b+D"),__sfx("5Zyw5Yy6"),"region"],Gs=[__sfx("5Zu95a62"),"country",__sfx("5Zu95Yir")],zs=[__sfx("5Z+O5biC"),"city"],Ws=["tls",__sfx("5piv5ZCm5pSv5oyBdGxz"),__sfx("5pSv5oyBdGxz")];ta={official:__sfx("5a6Y5pa55LyY6YCJSVA="),domain:__sfx("5LyY6YCJ5Z+f5ZCN"),manual:__sfx("5LyY6YCJ"),api:__sfx("6L+c56iLQVBJ"),csv:__sfx("5rWL6YCfQ1NW")};ra=12e4,oa=32,Ae=new Map,ia="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36";no=[__sfx("dmxlc3Mtd3M="),__sfx("dmxlc3MteGh0dHA="),__sfx("dHJvamFu")];so=[__sfx("dmxlc3Mtd3M="),__sfx("dHJvamFu")];sa=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;oo=".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 wa(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 bo(e,t){let n=await crypto.subtle.importKey("raw",yo.encode(e),{name:"HMAC",hash:"SHA-256"},!1,["sign"]),r=await crypto.subtle.sign("HMAC",n,yo.encode(t));return wa(new Uint8Array(r))}async function vt(e){let t=(await e.get(kt))?.trim();if(t)return t;if(!(e instanceof me))return Rt();if(Sn)return Sn;let n=Date.now();if(Ct===0&&(Ct=n),n-Ct<=xa)return Tt||(Tt=Rt()),Tt;let r=Rt();return await e.put(kt,r),Ct=0,Tt=r,Sn=r,r}async function wo(e){let t=Rt();return e instanceof me?await e.put(kt,t):await e.put(kt,t),t}async function xo(e,t={}){let n=t.ttlDays??0,r=Math.floor((t.now??Date.now())/1e3),o=n>0?r+Math.round(n*86400):0,i=Math.floor(Math.random()*36**8).toString(36).padStart(8,"0"),s=`${En}.${o.toString(36)}.${i}`,a=(await bo(e,s)).slice(0,An);return`${s}.${a}`}async function It(e,t,n=Date.now()){if(!e||!t)return{ok:!1,reason:"format"};let r=t.split(".");if(r.length!==4||r[0]!==En)return{ok:!1,reason:"format"};let o=r[1],i=r[2],s=r[3];if(!o||!i||s.length!==An)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 bo(e,`${En}.${o}.${i}`)).slice(0,An);return re(s,l)?a>0&&Math.floor(n/1e3)>=a?{ok:!1,reason:"expired",exp:a}:{ok:!0,exp:a}:{ok:!1,reason:"signature"}}var kt,En,An,yo,Rt,Sn,Tt,Ct,xa,Tn=k(()=>{"use strict";dt();ce();kt="SUB_TOKEN_SECRET",En="v1",An=22,yo=new TextEncoder;Rt=()=>$(32);Sn=null,Tt=null,Ct=0,xa=9e4});function Ea(e){let t="";for(let n of e)t+=(n<16?"0":"")+n.toString(16);return t}function Aa(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 Co(e,t,n){let r=Aa(t);if(!r)return null;let o=await crypto.subtle.importKey("raw",new TextEncoder().encode(e),"PBKDF2",!1,["deriveBits"]),i=await crypto.subtle.deriveBits({name:"PBKDF2",salt:r,iterations:n,hash:"SHA-256"},o,256);return Ea(new Uint8Array(i))}function Ro(e){if(e.startsWith(`${kn}$`)){let[r,o,i,s]=e.split("$");if(r!==kn||!i||!s)return null;let a=Number.parseInt(o??"",10);return!Number.isFinite(a)||a<1||a>1e6?null:{scheme:"pbkdf2",salt:i,iterations:a,expected:s}}let[t,n]=e.split(":");return!t||!n?null:{scheme:"sha256",salt:t,iterations:0,expected:n}}async function ko(e,t){return e.scheme==="pbkdf2"?await Co(t,e.salt,e.iterations):await nn(`${e.salt}:${t}`)}async function vn(e,t){let n=await Co(e,t,Ao);return n?`${kn}$${Ao}$${t}$${n}`:`${t}:${await nn(`${t}:${e}`)}`}async function Ta(e,t){let n=Ro(e);if(!n)return!1;let r=await ko(n,t);return r?re(r,n.expected):!1}function To(e){return`/${e.trim().replace(/^\/+/,"")}`}async function vo(e,t,n){let r=await e.get(gt)??"",o=n&&n.trim()?To(n):"";o?r!==o&&(r=o,await e.put(gt,r)):r||(r=To(`${Dr}-${vr(6)}`),await e.put(gt,r));let i=await e.get(je)??"",s=null,a=t&&t.trim()?t.trim():"";if(a){if(!i||!await Ta(i,a)){let d=$(8);i=await vn(a,d),await e.put(je,i)}await e.get(De)&&await e.delete(De)}else if(!i){let l=`cfp-${$(8)}`,d=$(8);i=await vn(l,d),await e.put(je,i),s=l,await e.put(De,l)}return{panelPath:r,passwordHash:i,generatedPassword:s}}async function Io(e,t){let n=Ro(e.passwordHash);if(!n)return{ok:!1,legacy:!1};let r=await ko(n,t);if(!r)return{ok:!1,legacy:!1};let o=re(r,n.expected);return{ok:o,legacy:o&&n.scheme==="sha256"}}async function Oo(e,t){let n=$(8);await e.put(je,await vn(t,n))}async function Do(e){await e.get(De)&&await e.delete(De)}function In(e){let t=e.headers.get("Cookie")??"",n={};for(let r of t.split(";")){let o=r.indexOf("=");if(o<0)continue;let i=r.slice(0,o).trim(),s=r.slice(o+1).trim();i&&(n[i]=decodeURIComponent(s))}return n}function Ca(e){for(let[t,n]of Fe)n<=e&&Fe.delete(t)}async function Uo(e){let t=$(24);await e.put(`${mt}${t}`,JSON.stringify({ua:"",t:Date.now()}),Rn);let n=Date.now();return Ca(n),Fe.set(t,n+Rn*1e3),t}function No(e){return!!In(e)[tt]}async function On(e,t){let n=In(t)[tt];if(!n)return!1;let r=Fe.get(n);if(r!==void 0){if(r>Date.now())return!0;Fe.delete(n)}return!!await e.get(`${mt}${n}`)}function Lo(e,t=Rn){return`${tt}=${e}; Path=/; HttpOnly; Secure; SameSite=Strict; Max-Age=${t}`}function Mo(){return`${tt}=; Path=/; HttpOnly; Secure; SameSite=Strict; Max-Age=0`}async function Fo(e,t){let n=In(t)[tt];n&&(Fe.delete(n),await e.delete(`${mt}${n}`))}async function Ho(e){let t=$(20);return await e.put(`${pt}${t}`,"1",Sa),t}async function Bo(e,t){if(!t)return!1;let n=await e.get("SCANNER_TOKEN");return n&&re(n,t)?!0:await e.get(`${pt}${t}`)?(await e.delete(`${pt}${t}`),!0):!1}var tt,Rn,Sa,Ao,kn,Fe,Dn=k(()=>{"use strict";_e();ce();tt=__sfx("Y2ZwaWxvdF9zZXNz"),Rn=3600*24,Sa=600,Ao=3e4,kn="pbkdf2";Fe=new Map});function Un(e){return Or(e)}async function Dt(e,t){if(ne.config&&Date.now()-ne.configAt<Ra)return ne.config;let n=await Lr(e,t);return ne.config=n,ne.configAt=Date.now(),n}function Ko(){ne.config=null,ne.configAt=0}async function Nn(e,t){if(ne.auth&&Date.now()-ne.authAt<ka)return ne.auth;let n=await vo(e,t.PANEL_PASSWORD,t.PANEL_PATH);return ne.auth=n,ne.authAt=Date.now(),n}function Ln(e){switch((e??"").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 nt(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 Xo(e){let t=(e??"").toLowerCase();return t?t.includes(__sfx("Y2xhc2g="))||t.includes("mihomo")||t.includes(__sfx("ZmxjbGFzaA=="))||t.includes(__sfx("Y2xhc2h4"))||t.includes("stash")?__sfx("Y2xhc2g="):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 Ra,ka,ne,Ut=k(()=>{"use strict";dt();_e();Dn();Ra=15e3,ka=6e4,ne={config:null,configAt:0,auth:null,authAt:0}});function Fn(e){let t=[];if(e.split(/\r?\n/).forEach((i,s)=>{let a=i.trim();if(!a)return;let l=a.replace(/^["']|["']$/g,"").trim();!l||l.startsWith("#")||Ce(a)===null&&t.push(s+1)}),t.length===0)return"";let r=t.slice(0,3).map(i=>`\u7B2C ${i} \u884C`).join("\u3001"),o=t.length>3?` \u7B49 ${t.length} \u884C`:"";return __sfx("5omL5Yqo5oyH5a6aIElQIOaciSA=")+t.length+__sfx("IOihjOaXoOazleivhuWIq++8iA==")+r+""+o+")"}function Mn(e,t,n){if(!e){n.push({field:t,message:""+t+__sfx("IOS4jeiDveS4uuepug==")});return}if(!e.startsWith("/")){n.push({field:t,message:""+t+__sfx("IOW/hemhu+S7pSAvIOW8gOWktA==")});return}if(e.length>128){n.push({field:t,message:""+t+__sfx("IOi/h+mVv++8iOacgOWkmiAxMjgg5a2X56ym77yJ")});return}/[\s\u0000-\u001f]/.test(e)&&n.push({field:t,message:""+t+__sfx("IOS4jeiDveWMheWQq+epuuagvOaIluaOp+WItuWtl+espg==")})}function Re(e,t,n,r,o){if(!Number.isFinite(e)){o.push({field:t,message:""+t+__sfx("IOW/hemhu+aYr+aVsOWtlw==")});return}(e<n||e>r)&&o.push({field:t,message:""+t+__sfx("IOW/hemhu+WcqCA=")+n+" ~ "+r+__sfx("IOS5i+mXtO+8iOW9k+WJjSA=")+e+")"})}function Nt(e,t,n,r=Oa){let o=e.split(/\r?\n|,/).map(i=>i.trim()).filter(Boolean);if(o.length>r){n.push({field:t,message:""+t+__sfx("IOacgOWkmiA=")+r+__sfx("IOadoe+8iOW9k+WJjSA=")+o.length+")"});return}for(let i of o)if(!Ia.test(i)){n.push({field:t,message:""+t+__sfx("IOmHjOacieaXoOazleivhuWIq+eahOadoeebru+8mg==")+i.slice(0,40)+""});return}}function zo(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+__sfx("IOacgOWkmiAxMCDmnaHvvIjlvZPliY0g")+r.length+")"});return}for(let o of r)if(!/^https?:\/\/\S+$/i.test(o)){n.push({field:t,message:""+t+__sfx("IOW/hemhu+aYryBodHRwKHMpIOWcsOWdgO+8mg==")+o.slice(0,40)+""});return}}function Ua(e,t,n){let r=e.split(/\r?\n/).map(i=>i.trim()).filter(Boolean);if(r.length>Go){n.push({field:t,message:""+t+__sfx("IOacgOWkmiA=")+Go+__sfx("IOadoe+8iOW9k+WJjSA=")+r.length+")"});return}let o=Fn(e);o&&n.push({field:t,message:o})}function Hn(e){let t=[],n=o=>Object.prototype.hasOwnProperty.call(e,o);n("wsPath")&&Mn(String(e.wsPath??""),"wsPath",t),n(__sfx("dHJvamFuUGF0aA=="))&&Mn(String(e.trojanPath??""),__sfx("dHJvamFuUGF0aA=="),t),n(__sfx("eGh0dHBQYXRo"))&&Mn(String(e.xhttpPath??""),__sfx("eGh0dHBQYXRo"),t);let r=["wsPath",__sfx("dHJvamFuUGF0aA=="),__sfx("eGh0dHBQYXRo")].filter(o=>n(o)).map(o=>`${o}=${String(e[o]??"")}`);if(r.length>=2){let o=r.map(i=>i.slice(i.indexOf("=")+1));new Set(o).size!==o.length&&t.push({field:"paths",message:__sfx("d3NQYXRoIC8gdHJvamFuUGF0aCAvIHhodHRwUGF0aCDkuI3og73ph43lpI0=")})}if(n("subDomain")){let o=String(e.subDomain??"").trim();o&&(!va.test(o)||o.includes("/"))&&t.push({field:"subDomain",message:__sfx("c3ViRG9tYWluIOW/hemhu+aYr+WQiOazleS4u+acuuWQje+8iOS4jeWQq+WNj+iuruS4jui3r+W+hO+8iQ==")})}if(n(__sfx("cHJveHlJcA=="))&&Nt(String(e.proxyIp??""),__sfx("cHJveHlJcA=="),t),n(__sfx("c29ja3M1"))&&Nt(String(e.socks5??""),__sfx("c29ja3M1"),t),n("httpProxy")&&Nt(String(e.httpProxy??""),"httpProxy",t),n("relayPool")&&Nt(String(e.relayPool??""),"relayPool",t,Da),n("officialCount")&&Re(Number(e.officialCount),"officialCount",1,200,t),n("domainCount")&&Re(Number(e.domainCount),"domainCount",1,200,t),n("maxNodes")&&Re(Number(e.maxNodes),"maxNodes",0,500,t),n("dls")&&Re(Number(e.dls),"dls",0,1e3,t),n("maxLatency")&&Re(Number(e.maxLatency),"maxLatency",0,1e4,t),n("dataBudgetMB")&&Re(Number(e.dataBudgetMB),"dataBudgetMB",0,102400,t),n("subTokenTtlDays")&&Re(Number(e.subTokenTtlDays),"subTokenTtlDays",0,3650,t),n("subPorts")){let o=String(e.subPorts??"").trim();if(o){let i=o.split(/[\n,;\s]+/).filter(Boolean);i.length>6?t.push({field:"subPorts",message:__sfx("c3ViUG9ydHMg5pyA5aSaIDYg5Liq56uv5Y+j")}):i.every(s=>/^\d{1,5}$/.test(s)&&Number(s)>=1&&Number(s)<=65535)||t.push({field:"subPorts",message:__sfx("c3ViUG9ydHMg6YeM5q+P5Liq56uv5Y+j6YO95b+F6aG75pivIDF+NjU1MzUg55qE5pWw5a2X")})}}if(n("subName")){let o=String(e.subName??"");o.length>40&&t.push({field:"subName",message:__sfx("c3ViTmFtZSDmnIDlpJogNDAg5a2X56ym")}),/[\u0000-\u001f]/.test(o)&&t.push({field:"subName",message:__sfx("c3ViTmFtZSDkuI3og73ljIXlkKvmjqfliLblrZfnrKY=")})}if(n("addApi")&&zo(String(e.addApi??""),"addApi",t),n("addCsv")&&zo(String(e.addCsv??""),"addCsv",t),n("add")&&Ua(String(e.add??""),"add",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:__sfx("dXVpZCDlv4XpobvmmK/moIflh4YgVVVJRO+8iDM2IOS9je+8jOWPr+W4pui/nuWtl+espu+8iQ==")})}if(n("poolCountries")){let o=String(e.poolCountries??"").trim();if(o){let i=o.split(/[\n,;\s]+/).filter(Boolean);i.length>30?t.push({field:"poolCountries",message:__sfx("cG9vbENvdW50cmllcyDmnIDlpJogMzAg5Liq5Zu95a62L+WcsOWMug==")}):i.every(s=>/^[A-Za-z]{2,3}$/.test(s))||t.push({field:"poolCountries",message:__sfx("cG9vbENvdW50cmllcyDlj6rog73mmK8gMn4zIOS9jeWtl+avjeS7o+eggQ==")})}}if(n("udpDnsEndpoint")){let o=String(e.udpDnsEndpoint??"").trim();o&&!/^https:\/\/\S+$/i.test(o)&&t.push({field:"udpDnsEndpoint",message:__sfx("dWRwRG5zRW5kcG9pbnQg5b+F6aG75pivIGh0dHBzIOWcsOWdgA==")})}return t}function Bn(e){return e.length===0?"":e.length===1?e[0].message:"有 "+e.length+__sfx("IOmhuemFjee9ruS4jeWQiOazle+8mg==")+e.map(t=>t.message).join("\uFF1B")+""}var va,Ia,Oa,Da,Go,Wo=k(()=>{"use strict";Et();va=/^(?=.{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])?)*$/;Ia=/^(?:(?:socks5|socks|socks5h|http|https):\/\/)?(?:[^\s@/]+@)?(?:\[[0-9a-fA-F:]+\]|[A-Za-z0-9._-]+)(?::\d{1,5})?$/;Oa=20,Da=200,Go=2e3});function Yo(e,t=Date.now()){let n={};for(let o of jo){let i=e[o];i!==void 0&&(n[o]=i)}let r=Na.map(o=>({field:o.field,reason:o.reason}));for(let o of[__sfx("c29ja3M1"),"httpProxy"]){let i=String(e[o]??"");if(!i){n[o]="";continue}if(i.includes("@")){r.push({field:o,reason:__sfx("5ZCr55So5oi35ZCNL+WPo+S7pO+8jOmcgOaJi+W3pemHjeaWsOWhq+WGmQ==")});continue}n[o]=i}return{schemaVersion:1,exportedAt:new Date(t).toISOString(),config:n,omitted:r}}function _o(e){let t=new Set([...jo.map(String),__sfx("c29ja3M1"),"httpProxy"]),n={};for(let[r,o]of Object.entries(e))t.has(r)&&(n[r]=o);return n}function Vo(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 Zo(e,t){let n=[];for(let[r,o]of Object.entries(t)){let i=e[r];String(i)!==String(o)&&n.push({field:r,from:Vo(i),to:Vo(o)})}return n}var jo,Na,Jo=k(()=>{"use strict";jo=["poolOfficial","officialCount","poolDomain","domainCount","poolManual","poolCountries","add","dls","maxLatency","maxNodes",__sfx("cHJveHlJcA=="),"relayPool","useBuiltinRelay","proxyMode","nat64","concurrentDial","dataBudgetMB","resolvePreferred","aggressiveRedial",__sfx("ZW5hYmxlVHJvamFu"),__sfx("ZW5hYmxlWGh0dHA="),"subProtocol","subTransport","subVariants","subName","subPorts","clientFingerprint","ech","echHost","echDns","tlsFragment","tlsFragmentSize","tlsFragmentDelay","subToken","subTokenTtlDays","unlockProbe","udpDns","udpDnsEndpoint"],Na=[{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 $o(){return new Response(JSON.stringify({build:rt,version:Kn,ts:Date.now()}),{status:200,headers:{"Content-Type":"application/json","Cache-Control":"no-store","Access-Control-Allow-Origin":"*"}})}var rt,Kn,Qo,Xn=k(()=>{"use strict";rt="77d82aa-82ab544c",Kn=__sfx("MC4zMy42"),Qo=__sfx("L19fY2ZwX3ZlcnNpb24=")});var ti={};ze(ti,{API_PREFIX:()=>zn,getScannerToken:()=>Xa,handleApi:()=>Ga,pruneLoginFailures:()=>ei});function Ha(e){return e.headers.get("CF-Connecting-IP")??e.headers.get("x-forwarded-for")?.split(",")[0]?.trim()??"unknown"}function Ba(e,t){let n=He.get(e);return n?t>=n.resetAt?(He.delete(e),!1):n.count>=Ma:!1}function ei(e,t,n=Fa){if(!(e.size<n)){for(let[r,o]of e)t>=o.resetAt&&e.delete(r);for(;e.size>=n;){let r=e.keys().next().value;if(r===void 0)break;e.delete(r)}}}function Ka(e,t){let n=He.get(e);if(!n||t>=n.resetAt){ei(He,t),He.set(e,{count:1,resetAt:t+qo});return}n.count+=1}function K(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 B(e,t){return K({ok:!1,error:e},t)}async function Xa(e,t){let n=await e.get(an);if(n)return n;if(typeof t.SCANNER_TOKEN=="string"&&t.SCANNER_TOKEN)return t.SCANNER_TOKEN;let r=$(24);return await e.put(an,r),r}async function Ga(e,t,n){if(!t.pathname.startsWith(zn))return null;let{store:r,env:o,config:i,auth:s}=n,a=t.pathname.slice(zn.length)||"/",l=e.method.toUpperCase();if(a==="/session"&&l==="GET"){let u=await On(r,e);return K(u?{ok:!0,authenticated:u,panelPath:s.panelPath}:{ok:!0,authenticated:u,hasSessionCookie:No(e)})}if(a==="/login"&&l==="POST"){let u="";try{let y=await e.json();u=String(y.password??"")}catch{return B(__sfx("6K+35rGC5L2T6Kej5p6Q5aSx6LSl"),400)}if(!u)return B(__sfx("6K+36L6T5YWl5a+G56CB"),400);let c=Ha(e),f=Date.now();if(Ba(c,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(qo/1e3))}});let p=await Io(s,u);if(!p.ok)return Ka(c,f),B(__sfx("5a+G56CB6ZSZ6K+v"),401);He.delete(c),p.legacy&&await Oo(r,u).catch(()=>{}),await Do(r).catch(()=>{});let h=await Uo(r);return K({ok:!0},200,{"Set-Cookie":Lo(h)})}if(a==="/logout"&&l==="POST")return await Fo(r,e),K({ok:!0},200,{"Set-Cookie":Mo()});if(a==="/preferred-ips"&&l==="POST"){let u=e.headers.get("Authorization")??"",c=u.startsWith("Bearer ")?u.slice(7).trim():u.trim();if(!await Bo(r,c))return B(__sfx("VG9rZW4g5qCh6aqM5aSx6LSl"),401);let p;try{p=await e.json()}catch{return B(__sfx("6K+35rGC5L2T6Kej5p6Q5aSx6LSl"),400)}let y=(Array.isArray(p.ips)?p.ips.map(m=>String(m)):[]).map(m=>m.trim()).filter(m=>m.length>0),{valid:P,invalid:g}=io(y),S=p.mode==="append",E=p.target==="relay",T=m=>m.split("#")[0].trim().replace(/^\[([^\]]+)\]:(\d+)$/,"$1:$2");if(P.length===0&&y.length>0)return B(__sfx("5rKh5pyJ5Y+v6K+G5Yir55qE5p2h55uu77yI5bey6Lez6L+HIA==")+g+" \u884C\uFF09",400);if(E){if(P.length===0)return B(__sfx("5rKh5pyJ5Y+v6K+G5Yir55qE5Y+N5Luj5YWl5Y+j"),400);let m=La,b=P.slice(0,m),A=P.length-b.length,N=(i.relayPool??"").split(`
|
|
7
|
+
`))}function po(e,t){let n=bn(t.config.subName);switch(e){case __sfx("Y2xhc2g="):return{body:ua(t),contentType:"text/yaml; charset=utf-8",fileName:n};case"singbox":return{body:ca(t),contentType:"application/json; charset=utf-8",fileName:n};default:return{body:fa(t),contentType:"text/plain; charset=utf-8",fileName:n}}}var Te,Ks,Xs,Zr,Jr,Qr,Gs,zs,Ws,ta,ra,oa,Ae,ia,no,so,sa,oo,Et=k(()=>{"use strict";ie();ce();cn();dn();Te=443;Ks=[__sfx("aXDlnLDlnYA="),__sfx("aXAg5Zyw5Z2A"),"ip",__sfx("5Zyw5Z2A"),__sfx("5pyN5Yqh5Zmo"),"server","host"],Xs=[__sfx("56uv5Y+j"),"port"],Zr=[__sfx("5LiL6L296YCf5bqm"),__sfx("6YCf5bqm"),"speed","download"],Jr=[__sfx("5bmz5Z2H5bu26L+f"),__sfx("5bu26L+f"),"latency","delay",__sfx("5ZON5bqU5pe26Ze0"),"rtt"],Qr=["colo",__sfx("5py65oi/"),__sfx("5pWw5o2u5Lit5b+D"),__sfx("5Zyw5Yy6"),"region"],Gs=[__sfx("5Zu95a62"),"country",__sfx("5Zu95Yir")],zs=[__sfx("5Z+O5biC"),"city"],Ws=["tls",__sfx("5piv5ZCm5pSv5oyBdGxz"),__sfx("5pSv5oyBdGxz")];ta={official:__sfx("5a6Y5pa55LyY6YCJSVA="),domain:__sfx("5LyY6YCJ5Z+f5ZCN"),manual:__sfx("5LyY6YCJ"),api:__sfx("6L+c56iLQVBJ"),csv:__sfx("5rWL6YCfQ1NW")};ra=12e4,oa=32,Ae=new Map,ia="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36";no=[__sfx("dmxlc3Mtd3M="),__sfx("dmxlc3MteGh0dHA="),__sfx("dHJvamFu")];so=[__sfx("dmxlc3Mtd3M="),__sfx("dHJvamFu")];sa=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;oo=".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 wa(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 bo(e,t){let n=await crypto.subtle.importKey("raw",yo.encode(e),{name:"HMAC",hash:"SHA-256"},!1,["sign"]),r=await crypto.subtle.sign("HMAC",n,yo.encode(t));return wa(new Uint8Array(r))}async function vt(e){let t=(await e.get(kt))?.trim();if(t)return t;if(!(e instanceof me))return Rt();if(Sn)return Sn;let n=Date.now();if(Ct===0&&(Ct=n),n-Ct<=xa)return Tt||(Tt=Rt()),Tt;let r=Rt();return await e.put(kt,r),Ct=0,Tt=r,Sn=r,r}async function wo(e){let t=Rt();return e instanceof me?await e.put(kt,t):await e.put(kt,t),t}async function xo(e,t={}){let n=t.ttlDays??0,r=Math.floor((t.now??Date.now())/1e3),o=n>0?r+Math.round(n*86400):0,i=Math.floor(Math.random()*36**8).toString(36).padStart(8,"0"),s=`${En}.${o.toString(36)}.${i}`,a=(await bo(e,s)).slice(0,An);return`${s}.${a}`}async function It(e,t,n=Date.now()){if(!e||!t)return{ok:!1,reason:"format"};let r=t.split(".");if(r.length!==4||r[0]!==En)return{ok:!1,reason:"format"};let o=r[1],i=r[2],s=r[3];if(!o||!i||s.length!==An)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 bo(e,`${En}.${o}.${i}`)).slice(0,An);return re(s,l)?a>0&&Math.floor(n/1e3)>=a?{ok:!1,reason:"expired",exp:a}:{ok:!0,exp:a}:{ok:!1,reason:"signature"}}var kt,En,An,yo,Rt,Sn,Tt,Ct,xa,Tn=k(()=>{"use strict";dt();ce();kt="SUB_TOKEN_SECRET",En="v1",An=22,yo=new TextEncoder;Rt=()=>$(32);Sn=null,Tt=null,Ct=0,xa=9e4});function Ea(e){let t="";for(let n of e)t+=(n<16?"0":"")+n.toString(16);return t}function Aa(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 Co(e,t,n){let r=Aa(t);if(!r)return null;let o=await crypto.subtle.importKey("raw",new TextEncoder().encode(e),"PBKDF2",!1,["deriveBits"]),i=await crypto.subtle.deriveBits({name:"PBKDF2",salt:r,iterations:n,hash:"SHA-256"},o,256);return Ea(new Uint8Array(i))}function Ro(e){if(e.startsWith(`${kn}$`)){let[r,o,i,s]=e.split("$");if(r!==kn||!i||!s)return null;let a=Number.parseInt(o??"",10);return!Number.isFinite(a)||a<1||a>1e6?null:{scheme:"pbkdf2",salt:i,iterations:a,expected:s}}let[t,n]=e.split(":");return!t||!n?null:{scheme:"sha256",salt:t,iterations:0,expected:n}}async function ko(e,t){return e.scheme==="pbkdf2"?await Co(t,e.salt,e.iterations):await nn(`${e.salt}:${t}`)}async function vn(e,t){let n=await Co(e,t,Ao);return n?`${kn}$${Ao}$${t}$${n}`:`${t}:${await nn(`${t}:${e}`)}`}async function Ta(e,t){let n=Ro(e);if(!n)return!1;let r=await ko(n,t);return r?re(r,n.expected):!1}function To(e){return`/${e.trim().replace(/^\/+/,"")}`}async function vo(e,t,n){let r=await e.get(gt)??"",o=n&&n.trim()?To(n):"";o?r!==o&&(r=o,await e.put(gt,r)):r||(r=To(`${Dr}-${vr(6)}`),await e.put(gt,r));let i=await e.get(je)??"",s=null,a=t&&t.trim()?t.trim():"";if(a){if(!i||!await Ta(i,a)){let d=$(8);i=await vn(a,d),await e.put(je,i)}await e.get(De)&&await e.delete(De)}else if(!i){let l=`cfp-${$(8)}`,d=$(8);i=await vn(l,d),await e.put(je,i),s=l,await e.put(De,l)}return{panelPath:r,passwordHash:i,generatedPassword:s}}async function Io(e,t){let n=Ro(e.passwordHash);if(!n)return{ok:!1,legacy:!1};let r=await ko(n,t);if(!r)return{ok:!1,legacy:!1};let o=re(r,n.expected);return{ok:o,legacy:o&&n.scheme==="sha256"}}async function Oo(e,t){let n=$(8);await e.put(je,await vn(t,n))}async function Do(e){await e.get(De)&&await e.delete(De)}function In(e){let t=e.headers.get("Cookie")??"",n={};for(let r of t.split(";")){let o=r.indexOf("=");if(o<0)continue;let i=r.slice(0,o).trim(),s=r.slice(o+1).trim();i&&(n[i]=decodeURIComponent(s))}return n}function Ca(e){for(let[t,n]of Fe)n<=e&&Fe.delete(t)}async function Uo(e){let t=$(24);await e.put(`${mt}${t}`,JSON.stringify({ua:"",t:Date.now()}),Rn);let n=Date.now();return Ca(n),Fe.set(t,n+Rn*1e3),t}function No(e){return!!In(e)[tt]}async function On(e,t){let n=In(t)[tt];if(!n)return!1;let r=Fe.get(n);if(r!==void 0){if(r>Date.now())return!0;Fe.delete(n)}return!!await e.get(`${mt}${n}`)}function Lo(e,t=Rn){return`${tt}=${e}; Path=/; HttpOnly; Secure; SameSite=Strict; Max-Age=${t}`}function Mo(){return`${tt}=; Path=/; HttpOnly; Secure; SameSite=Strict; Max-Age=0`}async function Fo(e,t){let n=In(t)[tt];n&&(Fe.delete(n),await e.delete(`${mt}${n}`))}async function Ho(e){let t=$(20);return await e.put(`${pt}${t}`,"1",Sa),t}async function Bo(e,t){if(!t)return!1;let n=await e.get("SCANNER_TOKEN");return n&&re(n,t)?!0:await e.get(`${pt}${t}`)?(await e.delete(`${pt}${t}`),!0):!1}var tt,Rn,Sa,Ao,kn,Fe,Dn=k(()=>{"use strict";_e();ce();tt=__sfx("Y2ZwaWxvdF9zZXNz"),Rn=3600*24,Sa=600,Ao=3e4,kn="pbkdf2";Fe=new Map});function Un(e){return Or(e)}async function Dt(e,t){if(ne.config&&Date.now()-ne.configAt<Ra)return ne.config;let n=await Lr(e,t);return ne.config=n,ne.configAt=Date.now(),n}function Ko(){ne.config=null,ne.configAt=0}async function Nn(e,t){if(ne.auth&&Date.now()-ne.authAt<ka)return ne.auth;let n=await vo(e,t.PANEL_PASSWORD,t.PANEL_PATH);return ne.auth=n,ne.authAt=Date.now(),n}function Ln(e){switch((e??"").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 nt(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 Xo(e){let t=(e??"").toLowerCase();return t?t.includes(__sfx("Y2xhc2g="))||t.includes("mihomo")||t.includes(__sfx("ZmxjbGFzaA=="))||t.includes(__sfx("Y2xhc2h4"))||t.includes("stash")?__sfx("Y2xhc2g="):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 Ra,ka,ne,Ut=k(()=>{"use strict";dt();_e();Dn();Ra=15e3,ka=6e4,ne={config:null,configAt:0,auth:null,authAt:0}});function Fn(e){let t=[];if(e.split(/\r?\n/).forEach((i,s)=>{let a=i.trim();if(!a)return;let l=a.replace(/^["']|["']$/g,"").trim();!l||l.startsWith("#")||Ce(a)===null&&t.push(s+1)}),t.length===0)return"";let r=t.slice(0,3).map(i=>`\u7B2C ${i} \u884C`).join("\u3001"),o=t.length>3?` \u7B49 ${t.length} \u884C`:"";return __sfx("5omL5Yqo5oyH5a6aIElQIOaciSA=")+t.length+__sfx("IOihjOaXoOazleivhuWIq++8iA==")+r+""+o+")"}function Mn(e,t,n){if(!e){n.push({field:t,message:""+t+__sfx("IOS4jeiDveS4uuepug==")});return}if(!e.startsWith("/")){n.push({field:t,message:""+t+__sfx("IOW/hemhu+S7pSAvIOW8gOWktA==")});return}if(e.length>128){n.push({field:t,message:""+t+__sfx("IOi/h+mVv++8iOacgOWkmiAxMjgg5a2X56ym77yJ")});return}/[\s\u0000-\u001f]/.test(e)&&n.push({field:t,message:""+t+__sfx("IOS4jeiDveWMheWQq+epuuagvOaIluaOp+WItuWtl+espg==")})}function Re(e,t,n,r,o){if(!Number.isFinite(e)){o.push({field:t,message:""+t+__sfx("IOW/hemhu+aYr+aVsOWtlw==")});return}(e<n||e>r)&&o.push({field:t,message:""+t+__sfx("IOW/hemhu+WcqCA=")+n+" ~ "+r+__sfx("IOS5i+mXtO+8iOW9k+WJjSA=")+e+")"})}function Nt(e,t,n,r=Oa){let o=e.split(/\r?\n|,/).map(i=>i.trim()).filter(Boolean);if(o.length>r){n.push({field:t,message:""+t+__sfx("IOacgOWkmiA=")+r+__sfx("IOadoe+8iOW9k+WJjSA=")+o.length+")"});return}for(let i of o)if(!Ia.test(i)){n.push({field:t,message:""+t+__sfx("IOmHjOacieaXoOazleivhuWIq+eahOadoeebru+8mg==")+i.slice(0,40)+""});return}}function zo(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+__sfx("IOacgOWkmiAxMCDmnaHvvIjlvZPliY0g")+r.length+")"});return}for(let o of r)if(!/^https?:\/\/\S+$/i.test(o)){n.push({field:t,message:""+t+__sfx("IOW/hemhu+aYryBodHRwKHMpIOWcsOWdgO+8mg==")+o.slice(0,40)+""});return}}function Ua(e,t,n){let r=e.split(/\r?\n/).map(i=>i.trim()).filter(Boolean);if(r.length>Go){n.push({field:t,message:""+t+__sfx("IOacgOWkmiA=")+Go+__sfx("IOadoe+8iOW9k+WJjSA=")+r.length+")"});return}let o=Fn(e);o&&n.push({field:t,message:o})}function Hn(e){let t=[],n=o=>Object.prototype.hasOwnProperty.call(e,o);n("wsPath")&&Mn(String(e.wsPath??""),"wsPath",t),n(__sfx("dHJvamFuUGF0aA=="))&&Mn(String(e.trojanPath??""),__sfx("dHJvamFuUGF0aA=="),t),n(__sfx("eGh0dHBQYXRo"))&&Mn(String(e.xhttpPath??""),__sfx("eGh0dHBQYXRo"),t);let r=["wsPath",__sfx("dHJvamFuUGF0aA=="),__sfx("eGh0dHBQYXRo")].filter(o=>n(o)).map(o=>`${o}=${String(e[o]??"")}`);if(r.length>=2){let o=r.map(i=>i.slice(i.indexOf("=")+1));new Set(o).size!==o.length&&t.push({field:"paths",message:__sfx("d3NQYXRoIC8gdHJvamFuUGF0aCAvIHhodHRwUGF0aCDkuI3og73ph43lpI0=")})}if(n("subDomain")){let o=String(e.subDomain??"").trim();o&&(!va.test(o)||o.includes("/"))&&t.push({field:"subDomain",message:__sfx("c3ViRG9tYWluIOW/hemhu+aYr+WQiOazleS4u+acuuWQje+8iOS4jeWQq+WNj+iuruS4jui3r+W+hO+8iQ==")})}if(n(__sfx("cHJveHlJcA=="))&&Nt(String(e.proxyIp??""),__sfx("cHJveHlJcA=="),t),n(__sfx("c29ja3M1"))&&Nt(String(e.socks5??""),__sfx("c29ja3M1"),t),n("httpProxy")&&Nt(String(e.httpProxy??""),"httpProxy",t),n("relayPool")&&Nt(String(e.relayPool??""),"relayPool",t,Da),n("officialCount")&&Re(Number(e.officialCount),"officialCount",1,200,t),n("domainCount")&&Re(Number(e.domainCount),"domainCount",1,200,t),n("maxNodes")&&Re(Number(e.maxNodes),"maxNodes",0,500,t),n("dls")&&Re(Number(e.dls),"dls",0,1e3,t),n("maxLatency")&&Re(Number(e.maxLatency),"maxLatency",0,1e4,t),n("dataBudgetMB")&&Re(Number(e.dataBudgetMB),"dataBudgetMB",0,102400,t),n("subTokenTtlDays")&&Re(Number(e.subTokenTtlDays),"subTokenTtlDays",0,3650,t),n("subPorts")){let o=String(e.subPorts??"").trim();if(o){let i=o.split(/[\n,;\s]+/).filter(Boolean);i.length>6?t.push({field:"subPorts",message:__sfx("c3ViUG9ydHMg5pyA5aSaIDYg5Liq56uv5Y+j")}):i.every(s=>/^\d{1,5}$/.test(s)&&Number(s)>=1&&Number(s)<=65535)||t.push({field:"subPorts",message:__sfx("c3ViUG9ydHMg6YeM5q+P5Liq56uv5Y+j6YO95b+F6aG75pivIDF+NjU1MzUg55qE5pWw5a2X")})}}if(n("subName")){let o=String(e.subName??"");o.length>40&&t.push({field:"subName",message:__sfx("c3ViTmFtZSDmnIDlpJogNDAg5a2X56ym")}),/[\u0000-\u001f]/.test(o)&&t.push({field:"subName",message:__sfx("c3ViTmFtZSDkuI3og73ljIXlkKvmjqfliLblrZfnrKY=")})}if(n("addApi")&&zo(String(e.addApi??""),"addApi",t),n("addCsv")&&zo(String(e.addCsv??""),"addCsv",t),n("add")&&Ua(String(e.add??""),"add",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:__sfx("dXVpZCDlv4XpobvmmK/moIflh4YgVVVJRO+8iDM2IOS9je+8jOWPr+W4pui/nuWtl+espu+8iQ==")})}if(n("poolCountries")){let o=String(e.poolCountries??"").trim();if(o){let i=o.split(/[\n,;\s]+/).filter(Boolean);i.length>30?t.push({field:"poolCountries",message:__sfx("cG9vbENvdW50cmllcyDmnIDlpJogMzAg5Liq5Zu95a62L+WcsOWMug==")}):i.every(s=>/^[A-Za-z]{2,3}$/.test(s))||t.push({field:"poolCountries",message:__sfx("cG9vbENvdW50cmllcyDlj6rog73mmK8gMn4zIOS9jeWtl+avjeS7o+eggQ==")})}}if(n("udpDnsEndpoint")){let o=String(e.udpDnsEndpoint??"").trim();o&&!/^https:\/\/\S+$/i.test(o)&&t.push({field:"udpDnsEndpoint",message:__sfx("dWRwRG5zRW5kcG9pbnQg5b+F6aG75pivIGh0dHBzIOWcsOWdgA==")})}return t}function Bn(e){return e.length===0?"":e.length===1?e[0].message:"有 "+e.length+__sfx("IOmhuemFjee9ruS4jeWQiOazle+8mg==")+e.map(t=>t.message).join("\uFF1B")+""}var va,Ia,Oa,Da,Go,Wo=k(()=>{"use strict";Et();va=/^(?=.{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])?)*$/;Ia=/^(?:(?:socks5|socks|socks5h|http|https):\/\/)?(?:[^\s@/]+@)?(?:\[[0-9a-fA-F:]+\]|[A-Za-z0-9._-]+)(?::\d{1,5})?$/;Oa=20,Da=200,Go=2e3});function Yo(e,t=Date.now()){let n={};for(let o of jo){let i=e[o];i!==void 0&&(n[o]=i)}let r=Na.map(o=>({field:o.field,reason:o.reason}));for(let o of[__sfx("c29ja3M1"),"httpProxy"]){let i=String(e[o]??"");if(!i){n[o]="";continue}if(i.includes("@")){r.push({field:o,reason:__sfx("5ZCr55So5oi35ZCNL+WPo+S7pO+8jOmcgOaJi+W3pemHjeaWsOWhq+WGmQ==")});continue}n[o]=i}return{schemaVersion:1,exportedAt:new Date(t).toISOString(),config:n,omitted:r}}function _o(e){let t=new Set([...jo.map(String),__sfx("c29ja3M1"),"httpProxy"]),n={};for(let[r,o]of Object.entries(e))t.has(r)&&(n[r]=o);return n}function Vo(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 Zo(e,t){let n=[];for(let[r,o]of Object.entries(t)){let i=e[r];String(i)!==String(o)&&n.push({field:r,from:Vo(i),to:Vo(o)})}return n}var jo,Na,Jo=k(()=>{"use strict";jo=["poolOfficial","officialCount","poolDomain","domainCount","poolManual","poolCountries","add","dls","maxLatency","maxNodes",__sfx("cHJveHlJcA=="),"relayPool","useBuiltinRelay","proxyMode","nat64","concurrentDial","dataBudgetMB","resolvePreferred","aggressiveRedial",__sfx("ZW5hYmxlVHJvamFu"),__sfx("ZW5hYmxlWGh0dHA="),"subProtocol","subTransport","subVariants","subName","subPorts","clientFingerprint","ech","echHost","echDns","tlsFragment","tlsFragmentSize","tlsFragmentDelay","subToken","subTokenTtlDays","unlockProbe","udpDns","udpDnsEndpoint"],Na=[{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 $o(){return new Response(JSON.stringify({build:rt,version:Kn,ts:Date.now()}),{status:200,headers:{"Content-Type":"application/json","Cache-Control":"no-store","Access-Control-Allow-Origin":"*"}})}var rt,Kn,Qo,Xn=k(()=>{"use strict";rt="daf280f-82ab544c",Kn=__sfx("MC4zMy43"),Qo=__sfx("L19fY2ZwX3ZlcnNpb24=")});var ti={};ze(ti,{API_PREFIX:()=>zn,getScannerToken:()=>Xa,handleApi:()=>Ga,pruneLoginFailures:()=>ei});function Ha(e){return e.headers.get("CF-Connecting-IP")??e.headers.get("x-forwarded-for")?.split(",")[0]?.trim()??"unknown"}function Ba(e,t){let n=He.get(e);return n?t>=n.resetAt?(He.delete(e),!1):n.count>=Ma:!1}function ei(e,t,n=Fa){if(!(e.size<n)){for(let[r,o]of e)t>=o.resetAt&&e.delete(r);for(;e.size>=n;){let r=e.keys().next().value;if(r===void 0)break;e.delete(r)}}}function Ka(e,t){let n=He.get(e);if(!n||t>=n.resetAt){ei(He,t),He.set(e,{count:1,resetAt:t+qo});return}n.count+=1}function K(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 B(e,t){return K({ok:!1,error:e},t)}async function Xa(e,t){let n=await e.get(an);if(n)return n;if(typeof t.SCANNER_TOKEN=="string"&&t.SCANNER_TOKEN)return t.SCANNER_TOKEN;let r=$(24);return await e.put(an,r),r}async function Ga(e,t,n){if(!t.pathname.startsWith(zn))return null;let{store:r,env:o,config:i,auth:s}=n,a=t.pathname.slice(zn.length)||"/",l=e.method.toUpperCase();if(a==="/session"&&l==="GET"){let u=await On(r,e);return K(u?{ok:!0,authenticated:u,panelPath:s.panelPath}:{ok:!0,authenticated:u,hasSessionCookie:No(e)})}if(a==="/login"&&l==="POST"){let u="";try{let y=await e.json();u=String(y.password??"")}catch{return B(__sfx("6K+35rGC5L2T6Kej5p6Q5aSx6LSl"),400)}if(!u)return B(__sfx("6K+36L6T5YWl5a+G56CB"),400);let c=Ha(e),f=Date.now();if(Ba(c,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(qo/1e3))}});let p=await Io(s,u);if(!p.ok)return Ka(c,f),B(__sfx("5a+G56CB6ZSZ6K+v"),401);He.delete(c),p.legacy&&await Oo(r,u).catch(()=>{}),await Do(r).catch(()=>{});let h=await Uo(r);return K({ok:!0},200,{"Set-Cookie":Lo(h)})}if(a==="/logout"&&l==="POST")return await Fo(r,e),K({ok:!0},200,{"Set-Cookie":Mo()});if(a==="/preferred-ips"&&l==="POST"){let u=e.headers.get("Authorization")??"",c=u.startsWith("Bearer ")?u.slice(7).trim():u.trim();if(!await Bo(r,c))return B(__sfx("VG9rZW4g5qCh6aqM5aSx6LSl"),401);let p;try{p=await e.json()}catch{return B(__sfx("6K+35rGC5L2T6Kej5p6Q5aSx6LSl"),400)}let y=(Array.isArray(p.ips)?p.ips.map(m=>String(m)):[]).map(m=>m.trim()).filter(m=>m.length>0),{valid:P,invalid:g}=io(y),S=p.mode==="append",E=p.target==="relay",T=m=>m.split("#")[0].trim().replace(/^\[([^\]]+)\]:(\d+)$/,"$1:$2");if(P.length===0&&y.length>0)return B(__sfx("5rKh5pyJ5Y+v6K+G5Yir55qE5p2h55uu77yI5bey6Lez6L+HIA==")+g+" \u884C\uFF09",400);if(E){if(P.length===0)return B(__sfx("5rKh5pyJ5Y+v6K+G5Yir55qE5Y+N5Luj5YWl5Y+j"),400);let m=La,b=P.slice(0,m),A=P.length-b.length,N=(i.relayPool??"").split(`
|
|
8
8
|
`).map(H=>H.trim()).filter(Boolean),U,_=b.length;if(S){let H=new Set(N.map(T)),G=b.filter(ve=>{let W=T(ve);return H.has(W)?!1:(H.add(W),!0)});_=G.length,U=[...N,...G]}else U=b;U.length>m&&(U=U.slice(0,m));let Pe=await Mr(r,i);return await Ne(r,Ue(Pe,{relayPool:U.join(`
|
|
9
9
|
`)})),n.onConfigChanged(),K({ok:!0,target:"relay",mode:S?"append":"replace",count:b.length,added:_,invalid:g,overLimit:A,limit:m})}let D=await r.get(oe),R,x=P.length;if(S){let m=(D??"").split(`
|
|
10
10
|
`).map(N=>N.trim()).filter(N=>N.length>0),b=new Set(m.map(T)),A=P.filter(N=>{let U=T(N);return b.has(U)?!1:(b.add(U),!0)});x=A.length,R=[...m,...A].join(`
|
package/dist/cli.js
CHANGED
|
@@ -87,11 +87,35 @@ var VERSION, NAME;
|
|
|
87
87
|
var init_version = __esm({
|
|
88
88
|
"src/shared/version.ts"() {
|
|
89
89
|
"use strict";
|
|
90
|
-
VERSION = "0.33.
|
|
90
|
+
VERSION = "0.33.7";
|
|
91
91
|
NAME = "cfpilot";
|
|
92
92
|
}
|
|
93
93
|
});
|
|
94
94
|
|
|
95
|
+
// src/shared/proxy.ts
|
|
96
|
+
function enableEnvProxy() {
|
|
97
|
+
if (process.env.NODE_USE_ENV_PROXY === "0") return false;
|
|
98
|
+
const hasProxyVar = ["HTTPS_PROXY", "https_proxy", "HTTP_PROXY", "http_proxy"].some(
|
|
99
|
+
(key) => (process.env[key] ?? "").trim() !== ""
|
|
100
|
+
);
|
|
101
|
+
if (!hasProxyVar) return false;
|
|
102
|
+
if (process.env.NODE_USE_ENV_PROXY === "1") return true;
|
|
103
|
+
process.env.NODE_USE_ENV_PROXY = "1";
|
|
104
|
+
return true;
|
|
105
|
+
}
|
|
106
|
+
function describeProxy() {
|
|
107
|
+
for (const key of ["HTTPS_PROXY", "https_proxy", "HTTP_PROXY", "http_proxy"]) {
|
|
108
|
+
const raw = (process.env[key] ?? "").trim();
|
|
109
|
+
if (raw) return `${key} ${raw}`;
|
|
110
|
+
}
|
|
111
|
+
return "\u76F4\u8FDE";
|
|
112
|
+
}
|
|
113
|
+
var init_proxy = __esm({
|
|
114
|
+
"src/shared/proxy.ts"() {
|
|
115
|
+
"use strict";
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
|
|
95
119
|
// src/menu/ui.ts
|
|
96
120
|
function wrap(open2, close) {
|
|
97
121
|
return (s) => useColor ? `\x1B[${open2}m${s}\x1B[${close}m` : s;
|
|
@@ -2071,8 +2095,10 @@ async function loadKernelBundle(currentVersion, options = {}) {
|
|
|
2071
2095
|
};
|
|
2072
2096
|
} catch (err) {
|
|
2073
2097
|
log(
|
|
2074
|
-
`\xB7 \u8FDC\u7A0B\u5185\u6838 ${remote.version} \u83B7\u53D6\u5931\u8D25\uFF0C\u6539\u7528\u5185\u7F6E\u5185\u6838\uFF1A` + (err instanceof Error ? err.message : String(err))
|
|
2098
|
+
`\xB7 \u8FDC\u7A0B\u5185\u6838 ${remote.version} \u83B7\u53D6\u5931\u8D25\uFF0C\u6539\u7528\u5185\u7F6E\u5185\u6838 ${currentVersion}\uFF08\u90E8\u7F72\u7167\u5E38\u8FDB\u884C\uFF09\uFF1A` + (err instanceof Error ? err.message : String(err))
|
|
2075
2099
|
);
|
|
2100
|
+
log(` \u2192 \u5185\u7F6E\u5185\u6838\u4E0E\u5F53\u524D\u7248\u672C\u4E00\u81F4\uFF0C\u529F\u80FD\u5B8C\u6574\uFF1B\u5F53\u524D\u8BBF\u95EE\u65B9\u5F0F\uFF1A${describeProxy()}`);
|
|
2101
|
+
log(" \u2192 \u60F3\u8981\u66F4\u65B0\u7684\u5185\u6838\u8BF7\u8BBE\u7F6E HTTPS_PROXY \u540E\u91CD\u8BD5");
|
|
2076
2102
|
}
|
|
2077
2103
|
}
|
|
2078
2104
|
const control = await loadBuiltinBundle("control.js");
|
|
@@ -2132,6 +2158,7 @@ var init_kernel_remote = __esm({
|
|
|
2132
2158
|
"src/deploy/kernel-remote.ts"() {
|
|
2133
2159
|
"use strict";
|
|
2134
2160
|
init_version_util();
|
|
2161
|
+
init_proxy();
|
|
2135
2162
|
init_github_mirrors();
|
|
2136
2163
|
CONTROL_ASSET_NAME = "cfpilot-kernel-control.js";
|
|
2137
2164
|
DATA_ASSET_NAME = "cfpilot-kernel-dataplane.js";
|
|
@@ -4655,6 +4682,27 @@ var init_true_probe = __esm({
|
|
|
4655
4682
|
}
|
|
4656
4683
|
});
|
|
4657
4684
|
|
|
4685
|
+
// src/scan/pool.ts
|
|
4686
|
+
async function pool(items, concurrency, worker, shouldStop) {
|
|
4687
|
+
const slots = new Array(items.length);
|
|
4688
|
+
let cursor = 0;
|
|
4689
|
+
const runners = Array.from({ length: Math.max(1, Math.min(concurrency, items.length)) }, async () => {
|
|
4690
|
+
for (; ; ) {
|
|
4691
|
+
if (shouldStop?.()) return;
|
|
4692
|
+
const index = cursor++;
|
|
4693
|
+
if (index >= items.length) return;
|
|
4694
|
+
slots[index] = await worker(items[index], index);
|
|
4695
|
+
}
|
|
4696
|
+
});
|
|
4697
|
+
await Promise.all(runners);
|
|
4698
|
+
return slots.filter((r) => r !== void 0);
|
|
4699
|
+
}
|
|
4700
|
+
var init_pool = __esm({
|
|
4701
|
+
"src/scan/pool.ts"() {
|
|
4702
|
+
"use strict";
|
|
4703
|
+
}
|
|
4704
|
+
});
|
|
4705
|
+
|
|
4658
4706
|
// src/scan/speed-url.ts
|
|
4659
4707
|
import * as tls2 from "node:tls";
|
|
4660
4708
|
import * as net from "node:net";
|
|
@@ -5440,20 +5488,6 @@ async function tcpPing(ip, port, timeoutMs) {
|
|
|
5440
5488
|
socket.connect(port, ip);
|
|
5441
5489
|
});
|
|
5442
5490
|
}
|
|
5443
|
-
async function pool(items, concurrency, worker, shouldStop) {
|
|
5444
|
-
const out2 = new Array(items.length);
|
|
5445
|
-
let cursor = 0;
|
|
5446
|
-
const runners = Array.from({ length: Math.max(1, Math.min(concurrency, items.length)) }, async () => {
|
|
5447
|
-
for (; ; ) {
|
|
5448
|
-
if (shouldStop?.()) return;
|
|
5449
|
-
const index = cursor++;
|
|
5450
|
-
if (index >= items.length) return;
|
|
5451
|
-
out2[index] = await worker(items[index], index);
|
|
5452
|
-
}
|
|
5453
|
-
});
|
|
5454
|
-
await Promise.all(runners);
|
|
5455
|
-
return out2;
|
|
5456
|
-
}
|
|
5457
5491
|
async function poolAdaptive(items, concurrency, worker, batchSize = 200) {
|
|
5458
5492
|
const out2 = [];
|
|
5459
5493
|
const maxConcurrency = Math.max(1, concurrency);
|
|
@@ -5642,6 +5676,15 @@ async function runScan(options) {
|
|
|
5642
5676
|
countFailure(failures, "ws101", item.probe?.error);
|
|
5643
5677
|
}
|
|
5644
5678
|
wsPool = wsFiltered2;
|
|
5679
|
+
if (stoppedEarly) {
|
|
5680
|
+
report({
|
|
5681
|
+
type: "progress",
|
|
5682
|
+
stage: 2,
|
|
5683
|
+
done: probeDone,
|
|
5684
|
+
total: stage1.length,
|
|
5685
|
+
message: `\u5DF2\u51D1\u591F ${earlyExitTarget} \u4E2A\u76EE\u6807\u56FD\u5BB6\u7684\u53EF\u7528\u8282\u70B9\uFF0C\u63D0\u524D\u6536\u5DE5\uFF08\u53EA\u6D4B\u4E86 ${probeDone}/${stage1.length}\uFF0C\u5176\u4F59\u672A\u6D4B\uFF09`
|
|
5686
|
+
});
|
|
5687
|
+
}
|
|
5645
5688
|
}
|
|
5646
5689
|
let xhttpOk = wsPool;
|
|
5647
5690
|
let xhttpOkCount = 0;
|
|
@@ -6119,6 +6162,7 @@ var init_scan = __esm({
|
|
|
6119
6162
|
"src/scan/scan.ts"() {
|
|
6120
6163
|
"use strict";
|
|
6121
6164
|
init_true_probe();
|
|
6165
|
+
init_pool();
|
|
6122
6166
|
init_speed_url();
|
|
6123
6167
|
init_countries();
|
|
6124
6168
|
init_unlock();
|
|
@@ -8237,7 +8281,7 @@ function upsertCandidates(pool2, inputs, now = Date.now(), maxCandidates = POOL_
|
|
|
8237
8281
|
return result;
|
|
8238
8282
|
}
|
|
8239
8283
|
var POOL_SCHEMA, POOL_FILENAME, ENTRY_IP, POOL_EXPIRE_MS, POOL_MAX_CANDIDATES, LOCK_STALE_MS, LOCK_TIMEOUT_MS, LOCK_RETRY_MS, V4_NETS, V6_NETS, sleep;
|
|
8240
|
-
var
|
|
8284
|
+
var init_pool2 = __esm({
|
|
8241
8285
|
"src/sources/pool.ts"() {
|
|
8242
8286
|
"use strict";
|
|
8243
8287
|
init_ip_ranges();
|
|
@@ -8376,7 +8420,7 @@ var init_sample = __esm({
|
|
|
8376
8420
|
"src/sources/sample.ts"() {
|
|
8377
8421
|
"use strict";
|
|
8378
8422
|
init_ip_ranges();
|
|
8379
|
-
|
|
8423
|
+
init_pool2();
|
|
8380
8424
|
POOL_SAMPLE_LIMIT = 200;
|
|
8381
8425
|
}
|
|
8382
8426
|
});
|
|
@@ -9875,7 +9919,7 @@ var init_command2 = __esm({
|
|
|
9875
9919
|
init_help2();
|
|
9876
9920
|
init_speed_url();
|
|
9877
9921
|
init_ip_ranges();
|
|
9878
|
-
|
|
9922
|
+
init_pool2();
|
|
9879
9923
|
init_sample();
|
|
9880
9924
|
adaptiveContexts = /* @__PURE__ */ new WeakMap();
|
|
9881
9925
|
poolSamples = /* @__PURE__ */ new WeakMap();
|
|
@@ -10752,7 +10796,7 @@ var init_config2 = __esm({
|
|
|
10752
10796
|
"src/sources/config.ts"() {
|
|
10753
10797
|
"use strict";
|
|
10754
10798
|
init_builtin_generated();
|
|
10755
|
-
|
|
10799
|
+
init_pool2();
|
|
10756
10800
|
SOURCES_SCHEMA = 2;
|
|
10757
10801
|
SOURCES_SCHEMA_V1 = 1;
|
|
10758
10802
|
SOURCES_FILENAME = "external-sources.json";
|
|
@@ -11043,7 +11087,7 @@ var init_providers = __esm({
|
|
|
11043
11087
|
"src/sources/providers.ts"() {
|
|
11044
11088
|
"use strict";
|
|
11045
11089
|
init_fetch();
|
|
11046
|
-
|
|
11090
|
+
init_pool2();
|
|
11047
11091
|
API_SOURCE_TYPES = ["ripe-stat"];
|
|
11048
11092
|
PROVIDERS = {
|
|
11049
11093
|
"ripe-stat": {
|
|
@@ -11418,7 +11462,7 @@ var init_manager = __esm({
|
|
|
11418
11462
|
init_fetch();
|
|
11419
11463
|
init_normalizer();
|
|
11420
11464
|
init_providers();
|
|
11421
|
-
|
|
11465
|
+
init_pool2();
|
|
11422
11466
|
}
|
|
11423
11467
|
});
|
|
11424
11468
|
|
|
@@ -11517,7 +11561,7 @@ var init_light = __esm({
|
|
|
11517
11561
|
"use strict";
|
|
11518
11562
|
init_store();
|
|
11519
11563
|
init_true_probe();
|
|
11520
|
-
|
|
11564
|
+
init_pool2();
|
|
11521
11565
|
LIGHT_MAX_PER_SYNC = 100;
|
|
11522
11566
|
LIGHT_CONCURRENCY = 8;
|
|
11523
11567
|
LIGHT_CONNECT_TIMEOUT_MS = 2e3;
|
|
@@ -11725,7 +11769,7 @@ var init_command3 = __esm({
|
|
|
11725
11769
|
init_fetch();
|
|
11726
11770
|
init_providers();
|
|
11727
11771
|
init_manager();
|
|
11728
|
-
|
|
11772
|
+
init_pool2();
|
|
11729
11773
|
HELP = `
|
|
11730
11774
|
cfpilot source <\u52A8\u4F5C> [\u9009\u9879] \u5916\u90E8 IP \u6570\u636E\u6E90\u7BA1\u7406\uFF08\u672C\u5730\u6C60\uFF0C\u4E0D\u5199 KV\uFF09
|
|
11731
11775
|
|
|
@@ -12715,6 +12759,7 @@ ${NAME} vps \u2014\u2014 \u5728\u81EA\u5DF1\u7684 VPS \u4E0A\u90E8\u7F72 SOCKS5
|
|
|
12715
12759
|
// src/cli.ts
|
|
12716
12760
|
init_args();
|
|
12717
12761
|
init_version();
|
|
12762
|
+
init_proxy();
|
|
12718
12763
|
var HELP6 = `
|
|
12719
12764
|
${NAME} v${VERSION}
|
|
12720
12765
|
Cloudflare Pages \u4EE3\u7406\u90E8\u7F72\u4E0E\u4F18\u9009\u5DE5\u5177
|
|
@@ -12744,6 +12789,7 @@ Cloudflare Pages \u4EE3\u7406\u90E8\u7F72\u4E0E\u4F18\u9009\u5DE5\u5177
|
|
|
12744
12789
|
\u6587\u6863: https://github.com/xmwengxing/CFPilot
|
|
12745
12790
|
`;
|
|
12746
12791
|
async function main() {
|
|
12792
|
+
enableEnvProxy();
|
|
12747
12793
|
const args = parseArgs(process.argv.slice(2));
|
|
12748
12794
|
const command = args.command;
|
|
12749
12795
|
if (flagBool(args, "v") || flagBool(args, "version") || command === "version") {
|