cfpilot 0.12.5 → 0.12.6
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 +1 -1
- package/package.json +1 -1
package/assets/control.js
CHANGED
|
@@ -3,7 +3,7 @@ const __sfx=(()=>{const __t=new TextDecoder(),__c=new Map();return b=>{let v=__c
|
|
|
3
3
|
`))),a){let O=""+w+__sfx("IFRyb2phbg==");r.push(O),n.push([__sfx("ICAtIG5hbWU6IA==")+B(O)+"",__sfx("ICAgIHR5cGU6IHRyb2phbg=="),__sfx("ICAgIHBhc3N3b3JkOiA=")+B(t.config.trojanPassword)+"",__sfx("ICAgIHNlcnZlcjog")+d.ip+"",__sfx("ICAgIHBvcnQ6IA==")+F+"",__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(`
|
|
4
4
|
`))}}});e.push(__sfx("IyBDRlBpbG90IOiHquWKqOeUn+aIkOiuoumYhQ==")),e.push(__sfx("bWl4ZWQtcG9ydDogNzg5MA==")),e.push(__sfx("YWxsb3ctbGFuOiBmYWxzZQ==")),e.push(__sfx("bW9kZTogcnVsZQ==")),e.push(__sfx("bG9nLWxldmVsOiBpbmZv")),e.push(__sfx("dW5pZmllZC1kZWxheTogdHJ1ZQ==")),e.push(__sfx("dGNwLWNvbmN1cnJlbnQ6IHRydWU=")),e.push(""),e.push("dns:"),e.push(__sfx("ICBlbmFibGU6IHRydWU=")),e.push(__sfx("ICBpcHY2OiBmYWxzZQ==")),e.push(__sfx("ICBlbmhhbmNlZC1tb2RlOiBmYWtlLWlw")),e.push(__sfx("ICBmYWtlLWlwLXJhbmdlOiAxOTguMTguMC4xLzE2")),e.push(" default-nameserver:"),e.push(" - 223.5.5.5"),e.push(" - 119.29.29.29"),e.push(" nameserver:"),e.push(" - https://223.5.5.5/dns-query"),e.push(" - https://dns.alidns.com/dns-query"),e.push(" fallback:"),e.push(" - 8.8.4.4"),e.push(" - 1.1.1.1"),e.push(" fallback-filter:"),e.push(__sfx("ICAgIGdlb2lwOiB0cnVl")),e.push(__sfx("ICAgIGdlb2lwLWNvZGU6IENO")),e.push(""),i&&(e.push(" nameserver-policy:"),e.push(` ${B(c)}: ${p?B(p):"https://223.5.5.5/dns-query"}`),e.push(""));let u=Me(t.routeProfile??"",{mainGroup:__sfx("Q0ZQaWxvdA=="),autoGroup:__sfx("6Ieq5Yqo6YCJ5oup")});if(e.push("proxies:"),n.length===0?e.push(" []"):e.push(...n),e.push(""),e.push(__sfx("cHJveHktZ3JvdXBzOg==")),e.push(__sfx("ICAtIG5hbWU6ICJDRlBpbG90Ig==")),e.push(__sfx("ICAgIHR5cGU6IHNlbGVjdA==")),e.push(" proxies:"),e.push(__sfx("ICAgICAgLSAi6Ieq5Yqo6YCJ5oupIg==")),e.push(__sfx("ICAgICAgLSAi5pWF6Zqc6L2s56e7Ig==")),r.length===0)e.push(" []");else for(let f of r)e.push(` - ${B(f)}`);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 f of r)e.push(` - ${B(f)}`);e.push(""),e.push(__sfx("ICAtIG5hbWU6ICLmlYXpmpzovaznp7si")),e.push(__sfx("ICAgIHR5cGU6IGZhbGxiYWNr")),e.push(__sfx("ICAgIHVybDogImh0dHA6Ly93d3cuZ3N0YXRpYy5jb20vZ2VuZXJhdGVfMjA0Ig==")),e.push(__sfx("ICAgIGludGVydmFsOiAzMDA=")),e.push(" proxies:");for(let f of r)e.push(` - ${B(f)}`)}return u.groups.length>0&&(e.push(""),e.push(...u.groups)),e.push(""),e.push("rules:"),u.rules.length>0?(e.push(...u.rules),u.rules.some(f=>f.includes("MATCH,"))||e.push(__sfx("ICAtIE1BVENILENGUGlsb3Q="))):e.push(...Ue(__sfx("Q0ZQaWxvdA=="))),e.push(""),e.join(`
|
|
5
5
|
`)}function Br(t){let e=[],n=[],r=Vt(t.config.subVariants,t.config,Qe),o=r.some(l=>l===__sfx("dmxlc3Mtd3M=")),s=r.includes(__sfx("dHJvamFu")),a=t.config.ech,i=t.config.echHost.trim()||__sfx("Y2xvdWRmbGFyZS1lY2guY29t"),c=()=>a?{ech:{enabled:!0,query_server_name:i}}:{};for(let l of qt(t)){let u=[];l.entries.forEach((f,d)=>{let m=`${l.name} ${mt(f,"vless",d,"")}`;for(let h of Zt(f,t)){let F=t.ports.length>1?`:${h}`:"",N=`${m}${F}`,w=""+N+__sfx("IFRyb2phbg==");o&&u.push(N),s&&u.push(w),o&&e.push({type:__sfx("dmxlc3M="),tag:N,server:f.ip,server_port:h,uuid:t.config.uuid,tls:{enabled:!0,server_name:t.domain,insecure:!1,utls:{enabled:!0,fingerprint:t.config.clientFingerprint},...c()},transport:{type:"ws",path:t.config.wsPath,headers:{Host:t.domain}}}),s&&e.push({type:__sfx("dHJvamFu"),tag:w,server:f.ip,server_port:h,password:t.config.trojanPassword,tls:{enabled:!0,server_name:t.domain,insecure:!1,utls:{enabled:!0,fingerprint:t.config.clientFingerprint},...c()},transport:{type:"ws",path:t.config.trojanPath,headers:{Host:t.domain}}})}}),u.length>0&&n.push({tag:l.name,members:u})}e.push({type:"direct",tag:"direct"});for(let l of n)e.push({type:"selector",tag:l.tag,outbounds:l.members,default:l.members[0]});return e.push({type:"selector",tag:__sfx("Q0ZQaWxvdA=="),outbounds:n.length>0?n.map(l=>l.tag):["direct"],default:n.length>0?n[0].tag:"direct"}),JSON.stringify({log:{level:"info",timestamp:!0},dns:{servers:[{tag:"dns-out",address:"https://1.1.1.1/dns-query"},{tag:"local",address:"local"}],rules:[{domain_suffix:qe,server:"local"}]},inbounds:[{type:"mixed",tag:"mixed-in",listen:__sfx("MTI3LjAuMC4x"),listen_port:2080}],outbounds:e,route:{rules:[{ip_is_private:!0,outbound:"direct"},{domain_suffix:qe,outbound:"direct"}],final:__sfx("Q0ZQaWxvdA=="),auto_detect_interface:!0}},null,2)}function jr(t){let e=[],n=Vt(t.config.subVariants,t.config);for(let r of qt(t))r.entries.forEach((o,s)=>{let a=mt(o,__sfx("dmxlc3M="),s,r.name);for(let i of Zt(o,t)){let c=t.ports.length>1?`:${i}`:"",p=`${a}${c}`,l={...o,port:i};for(let u of n)u===__sfx("dmxlc3Mtd3M=")?e.push(Ve(l,t,"ws",`${p} WS`)):u===__sfx("dmxlc3MteGh0dHA=")?e.push(Ve(l,t,__sfx("eGh0dHA="),""+p+__sfx("IFhIVFRQ"))):e.push(Ur(l,t,""+p+__sfx("IFRyb2phbg==")))}});return Ee(e.join(`
|
|
6
|
-
`))}function en(t,e){let n=Qt(e.config.subName);switch(t){case __sfx("Y2xhc2g="):return{body:Mr(e),contentType:"text/yaml; charset=utf-8",fileName:n};case"singbox":return{body:Br(e),contentType:"application/json; charset=utf-8",fileName:n};default:return{body:jr(e),contentType:"text/plain; charset=utf-8",fileName:n}}}var $,gr,mr,je,He,Ke,hr,br,yr,Rr,Or,vr,_,kr,Ye,Qe,Lr,qe,Jt=R(()=>{"use strict";Ne();G();zt();Be();$=443;gr=[__sfx("aXDlnLDlnYA="),__sfx("aXAg5Zyw5Z2A"),"ip",__sfx("5Zyw5Z2A"),__sfx("5pyN5Yqh5Zmo"),"server","host"],mr=[__sfx("56uv5Y+j"),"port"],je=[__sfx("5LiL6L296YCf5bqm"),__sfx("6YCf5bqm"),"speed","download"],He=[__sfx("5bmz5Z2H5bu26L+f"),__sfx("5bu26L+f"),"latency","delay",__sfx("5ZON5bqU5pe26Ze0"),"rtt"],Ke=["colo",__sfx("5py65oi/"),__sfx("5pWw5o2u5Lit5b+D"),__sfx("5Zyw5Yy6"),"region"],hr=[__sfx("5Zu95a62"),"country",__sfx("5Zu95Yir")],br=[__sfx("5Z+O5biC"),"city"],yr=["tls",__sfx("5piv5ZCm5pSv5oyBdGxz"),__sfx("5pSv5oyBdGxz")];Rr={official:__sfx("5a6Y5pa55LyY6YCJSVA="),domain:__sfx("5LyY6YCJ5Z+f5ZCN"),manual:__sfx("5omL5Yqo5LyY6YCJSVA="),api:__sfx("6L+c56iLQVBJ"),csv:__sfx("5rWL6YCfQ1NW")};Or=12e4,vr=32,_=new Map,kr="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36";Ye=[__sfx("dmxlc3Mtd3M="),__sfx("dmxlc3MteGh0dHA="),__sfx("dHJvamFu")];Qe=[__sfx("dmxlc3Mtd3M="),__sfx("dHJvamFu")];Lr=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;qe=".cn,qq.com,tencent.com,weixin.qq.com,baidu.com,bdstatic.com,bilibili.com,hdslb.com,taobao.com,tmall.com,jd.com,aliyun.com,alicdn.com,alipay.com,163.com,126.net,zhihu.com,weibo.com,sina.com.cn,youku.com,iqiyi.com,douyin.com,xiaohongshu.com,mi.com,huawei.com,csdn.net,gitee.com,cnblogs.com".split(",")});function Vr(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 un(t,e){let n=await crypto.subtle.importKey("raw",an.encode(t),{name:"HMAC",hash:"SHA-256"},!1,["sign"]),r=await crypto.subtle.sign("HMAC",n,an.encode(e));return Vr(new Uint8Array(r))}async function It(t){let e=(await t.get(Dt))?.trim();if(e)return e;let n=ln();return t instanceof X&&await t.put(Dt,n),n}async function cn(t){let e=ln();return t instanceof X?await t.put(Dt,e):await t.put(Dt,e),e}async function fn(t,e={}){let n=e.ttlDays??0,r=Math.floor((e.now??Date.now())/1e3),o=n>0?r+Math.round(n*86400):0,s=Math.floor(Math.random()*36**8).toString(36).padStart(8,"0"),a=`${te}.${o.toString(36)}.${s}`,i=(await un(t,a)).slice(0,ee);return`${a}.${i}`}async function Rt(t,e,n=Date.now()){if(!t||!e)return{ok:!1,reason:"format"};let r=e.split(".");if(r.length!==4||r[0]!==te)return{ok:!1,reason:"format"};let o=r[1],s=r[2],a=r[3];if(!o||!s||a.length!==ee)return{ok:!1,reason:"format"};let i=Number.parseInt(o,36);if(!Number.isFinite(i)||i<0)return{ok:!1,reason:"format"};let c=(await un(t,`${te}.${o}.${s}`)).slice(0,ee);return W(a,c)?i>0&&Math.floor(n/1e3)>=i?{ok:!1,reason:"expired",exp:i}:{ok:!0,exp:i}:{ok:!1,reason:"signature"}}var Dt,te,ee,an,ln,ne=R(()=>{"use strict";bt();G();Dt="SUB_TOKEN_SECRET",te="v1",ee=22,an=new TextEncoder;ln=()=>k(32)});function Zr(t){let e="";for(let n of t)e+=(n<16?"0":"")+n.toString(16);return e}function Jr(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 yn(t,e,n){let r=Jr(e);if(!r)return null;let o=await crypto.subtle.importKey("raw",new TextEncoder().encode(t),"PBKDF2",!1,["deriveBits"]),s=await crypto.subtle.deriveBits({name:"PBKDF2",salt:r,iterations:n,hash:"SHA-256"},o,256);return Zr(new Uint8Array(s))}function Pn(t){if(t.startsWith(`${oe}$`)){let[r,o,s,a]=t.split("$");if(r!==oe||!s||!a)return null;let i=Number.parseInt(o??"",10);return!Number.isFinite(i)||i<1||i>1e6?null:{scheme:"pbkdf2",salt:s,iterations:i,expected:a}}let[e,n]=t.split(":");return!e||!n?null:{scheme:"sha256",salt:e,iterations:0,expected:n}}async function wn(t,e){return t.scheme==="pbkdf2"?await yn(e,t.salt,t.iterations):await Mt(`${t.salt}:${e}`)}async function se(t,e){let n=await yn(t,e,mn);return n?`${oe}$${mn}$${e}$${n}`:`${e}:${await Mt(`${e}:${t}`)}`}async function _r(t,e){let n=Pn(t);if(!n)return!1;let r=await wn(n,e);return r?W(r,n.expected):!1}function hn(t){return`/${t.trim().replace(/^\/+/,"")}`}async function En(t,e,n){let r=await t.get(wt)??"",o=n&&n.trim()?hn(n):"";o?r!==o&&(r=o,await t.put(wt,r)):r||(r=hn(`${Se}-${we(6)}`),await t.put(wt,r));let s=await t.get(it)??"",a=null,i=e&&e.trim()?e.trim():"";if(i){if(!s||!await _r(s,i)){let p=k(8);s=await se(i,p),await t.put(it,s)}await t.get(nt)&&await t.delete(nt)}else if(!s){let c=`cfp-${k(8)}`,p=k(8);s=await se(c,p),await t.put(it,s),a=c,await t.put(nt,c)}return{panelPath:r,passwordHash:s,generatedPassword:a}}async function An(t,e){let n=Pn(t.passwordHash);if(!n)return{ok:!1,legacy:!1};let r=await wn(n,e);if(!r)return{ok:!1,legacy:!1};let o=W(r,n.expected);return{ok:o,legacy:o&&n.scheme==="sha256"}}async function Cn(t,e){let n=k(8);await t.put(it,await se(e,n))}async function xn(t){await t.get(nt)&&await t.delete(nt)}function Sn(t){let e=t.headers.get("Cookie")??"",n={};for(let r of e.split(";")){let o=r.indexOf("=");if(o<0)continue;let s=r.slice(0,o).trim(),a=r.slice(o+1).trim();s&&(n[s]=decodeURIComponent(a))}return n}async function Tn(t){let e=k(24);return await t.put(`${Pt}${e}`,JSON.stringify({ua:"",t:Date.now()}),bn),e}async function ie(t,e){let n=Sn(e)[Ot];return n?!!await t.get(`${Pt}${n}`):!1}function Dn(t,e=bn){return`${Ot}=${t}; Path=/; HttpOnly; Secure; SameSite=Strict; Max-Age=${e}`}function In(){return`${Ot}=; Path=/; HttpOnly; Secure; SameSite=Strict; Max-Age=0`}async function Rn(t,e){let n=Sn(e)[Ot];n&&await t.delete(`${Pt}${n}`)}async function Nn(t){let e=k(20);return await t.put(`${yt}${e}`,"1",Qr),e}async function On(t,e){if(!e)return!1;let n=await t.get("SCANNER_TOKEN");return n&&W(n,e)?!0:await t.get(`${yt}${e}`)?(await t.delete(`${yt}${e}`),!0):!1}var Ot,bn,Qr,mn,oe,ae=R(()=>{"use strict";ft();G();Ot=__sfx("Y2ZwaWxvdF9zZXNz"),bn=3600*24,Qr=600,mn=3e4,oe="pbkdf2"});function vn(t){return Ae(t)}async function ue(t,e){if(L.config&&Date.now()-L.configAt<$r)return L.config;let n=await Ie(t,e);return L.config=n,L.configAt=Date.now(),n}function kn(){L.config=null,L.configAt=0}async function le(t,e){if(L.auth&&Date.now()-L.authAt<to)return L.auth;let n=await En(t,e.PANEL_PASSWORD,e.PANEL_PATH);return L.auth=n,L.authAt=Date.now(),n}function ce(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 ht(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 Ln(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 $r,to,L,vt=R(()=>{"use strict";bt();ft();ae();$r=15e3,to=6e4,L={config:null,configAt:0,auth:null,authAt:0}});function fe(t,e,n){if(!t){n.push({field:e,message:""+e+__sfx("IOS4jeiDveS4uuepug==")});return}if(!t.startsWith("/")){n.push({field:e,message:""+e+__sfx("IOW/hemhu+S7pSAvIOW8gOWktA==")});return}if(t.length>128){n.push({field:e,message:""+e+__sfx("IOi/h+mVv++8iOacgOWkmiAxMjgg5a2X56ym77yJ")});return}/[\s\u0000-\u001f]/.test(t)&&n.push({field:e,message:""+e+__sfx("IOS4jeiDveWMheWQq+epuuagvOaIluaOp+WItuWtl+espg==")})}function tt(t,e,n,r,o){if(!Number.isFinite(t)){o.push({field:e,message:""+e+__sfx("IOW/hemhu+aYr+aVsOWtlw==")});return}(t<n||t>r)&&o.push({field:e,message:""+e+__sfx("IOW/hemhu+WcqCA=")+n+" ~ "+r+__sfx("IOS5i+mXtO+8iOW9k+WJjSA=")+t+")"})}function kt(t,e,n){let r=t.split(/\r?\n|,/).map(o=>o.trim()).filter(Boolean);if(r.length>20){n.push({field:e,message:""+e+__sfx("IOacgOWkmiAyMCDmnaHvvIjlvZPliY0g")+r.length+")"});return}for(let o of r)if(!no.test(o)){n.push({field:e,message:""+e+__sfx("IOmHjOacieaXoOazleivhuWIq+eahOadoeebru+8mg==")+o.slice(0,40)+""});return}}function Fn(t,e,n){let r=t.split(/\r?\n|,/).map(o=>o.trim()).filter(Boolean);if(r.length>10){n.push({field:e,message:""+e+__sfx("IOacgOWkmiAxMCDmnaHvvIjlvZPliY0g")+r.length+")"});return}for(let o of r)if(!/^https?:\/\/\S+$/i.test(o)){n.push({field:e,message:""+e+__sfx("IOW/hemhu+aYryBodHRwKHMpIOWcsOWdgO+8mg==")+o.slice(0,40)+""});return}}function pe(t){let e=[],n=o=>Object.prototype.hasOwnProperty.call(t,o);n("wsPath")&&fe(String(t.wsPath??""),"wsPath",e),n(__sfx("dHJvamFuUGF0aA=="))&&fe(String(t.trojanPath??""),__sfx("dHJvamFuUGF0aA=="),e),n(__sfx("eGh0dHBQYXRo"))&&fe(String(t.xhttpPath??""),__sfx("eGh0dHBQYXRo"),e);let r=["wsPath",__sfx("dHJvamFuUGF0aA=="),__sfx("eGh0dHBQYXRo")].filter(o=>n(o)).map(o=>`${o}=${String(t[o]??"")}`);if(r.length>=2){let o=r.map(s=>s.slice(s.indexOf("=")+1));new Set(o).size!==o.length&&e.push({field:"paths",message:__sfx("d3NQYXRoIC8gdHJvamFuUGF0aCAvIHhodHRwUGF0aCDkuI3og73ph43lpI0=")})}if(n("subDomain")){let o=String(t.subDomain??"").trim();o&&(!eo.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=="))&&kt(String(t.proxyIp??""),__sfx("cHJveHlJcA=="),e),n(__sfx("c29ja3M1"))&&kt(String(t.socks5??""),__sfx("c29ja3M1"),e),n("httpProxy")&&kt(String(t.httpProxy??""),"httpProxy",e),n("relayPool")&&kt(String(t.relayPool??""),"relayPool",e),n("officialCount")&&tt(Number(t.officialCount),"officialCount",1,200,e),n("domainCount")&&tt(Number(t.domainCount),"domainCount",1,200,e),n("maxNodes")&&tt(Number(t.maxNodes),"maxNodes",0,500,e),n("dls")&&tt(Number(t.dls),"dls",0,1e3,e),n("maxLatency")&&tt(Number(t.maxLatency),"maxLatency",0,1e4,e),n("dataBudgetMB")&&tt(Number(t.dataBudgetMB),"dataBudgetMB",0,102400,e),n("subTokenTtlDays")&&tt(Number(t.subTokenTtlDays),"subTokenTtlDays",0,3650,e),n("subPorts")){let o=String(t.subPorts??"").trim();if(o){let s=o.split(/[\n,;\s]+/).filter(Boolean);s.length>6?e.push({field:"subPorts",message:__sfx("c3ViUG9ydHMg5pyA5aSaIDYg5Liq56uv5Y+j")}):s.every(a=>/^\d{1,5}$/.test(a)&&Number(a)>=1&&Number(a)<=65535)||e.push({field:"subPorts",message:__sfx("c3ViUG9ydHMg6YeM5q+P5Liq56uv5Y+j6YO95b+F6aG75pivIDF+NjU1MzUg55qE5pWw5a2X")})}}if(n("subName")){let o=String(t.subName??"");o.length>40&&e.push({field:"subName",message:__sfx("c3ViTmFtZSDmnIDlpJogNDAg5a2X56ym")}),/[\u0000-\u001f]/.test(o)&&e.push({field:"subName",message:__sfx("c3ViTmFtZSDkuI3og73ljIXlkKvmjqfliLblrZfnrKY=")})}if(n("addApi")&&Fn(String(t.addApi??""),"addApi",e),n("addCsv")&&Fn(String(t.addCsv??""),"addCsv",e),n("uuid")){let o=String(t.uuid??"").trim();o&&!/^[0-9a-fA-F]{8}-?[0-9a-fA-F]{4}-?[0-9a-fA-F]{4}-?[0-9a-fA-F]{4}-?[0-9a-fA-F]{12}$/.test(o)&&e.push({field:"uuid",message:__sfx("dXVpZCDlv4XpobvmmK/moIflh4YgVVVJRO+8iDM2IOS9je+8jOWPr+W4pui/nuWtl+espu+8iQ==")})}if(n("poolCountries")){let o=String(t.poolCountries??"").trim();if(o){let s=o.split(/[\n,;\s]+/).filter(Boolean);s.length>30?e.push({field:"poolCountries",message:__sfx("cG9vbENvdW50cmllcyDmnIDlpJogMzAg5Liq5Zu95a62L+WcsOWMug==")}):s.every(a=>/^[A-Za-z]{2,3}$/.test(a))||e.push({field:"poolCountries",message:__sfx("cG9vbENvdW50cmllcyDlj6rog73mmK8gMn4zIOS9jeWtl+avjeS7o+eggQ==")})}}if(n("udpDnsEndpoint")){let o=String(t.udpDnsEndpoint??"").trim();o&&!/^https:\/\/\S+$/i.test(o)&&e.push({field:"udpDnsEndpoint",message:__sfx("dWRwRG5zRW5kcG9pbnQg5b+F6aG75pivIGh0dHBzIOWcsOWdgA==")})}return e}function de(t){return t.length===0?"":t.length===1?t[0].message:"有 "+t.length+__sfx("IOmhuemFjee9ruS4jeWQiOazle+8mg==")+t.map(e=>e.message).join("\uFF1B")+""}var eo,no,Un=R(()=>{"use strict";eo=/^(?=.{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])?)*$/,no=/^(?:(?:socks5|socks|socks5h|http|https):\/\/)?(?:[^\s@/]+@)?(?:\[[0-9a-fA-F:]+\]|[A-Za-z0-9._-]+)(?::\d{1,5})?$/});function jn(t,e=Date.now()){let n={};for(let o of Bn){let s=t[o];s!==void 0&&(n[o]=s)}let r=ro.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 Hn(t){let e=new Set([...Bn.map(String),__sfx("c29ja3M1"),"httpProxy"]),n={};for(let[r,o]of Object.entries(t))e.has(r)&&(n[r]=o);return n}function Mn(t){if(t==null)return"\uFF08\u7A7A\uFF09";if(typeof t=="string"){let e=t.replace(/\s+/g," ").trim();return e.length>60?`${e.slice(0,60)}\u2026`:e||"\uFF08\u7A7A\uFF09"}return String(t)}function Kn(t,e){let n=[];for(let[r,o]of Object.entries(e)){let s=t[r];String(s)!==String(o)&&n.push({field:r,from:Mn(s),to:Mn(o)})}return n}var Bn,ro,Wn=R(()=>{"use strict";Bn=["poolOfficial","officialCount","poolDomain","domainCount","poolManual","poolCountries","add","dls","maxLatency","maxNodes",__sfx("cHJveHlJcA=="),"relayPool","useBuiltinRelay","proxyMode","nat64","concurrentDial","dataBudgetMB","resolvePreferred",__sfx("ZW5hYmxlVHJvamFu"),__sfx("ZW5hYmxlWGh0dHA="),"subProtocol","subTransport","subVariants","subName","subPorts","clientFingerprint","ech","echHost","echDns","tlsFragment","tlsFragmentSize","tlsFragmentDelay","subToken","subTokenTtlDays","unlockProbe","udpDns","udpDnsEndpoint"],ro=[{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 Gn(){return new Response(JSON.stringify({build:ge,version:me,ts:Date.now()}),{status:200,headers:{"Content-Type":"application/json","Cache-Control":"no-store","Access-Control-Allow-Origin":"*"}})}var ge,me,zn,he=R(()=>{"use strict";ge="6cf3fc8-2d5c8203",me=__sfx("MC4xMi41"),zn=__sfx("L19fY2ZwX3ZlcnNpb24=")});var Vn={};tr(Vn,{API_PREFIX:()=>be,getScannerToken:()=>uo,handleApi:()=>lo});function so(t){return t.headers.get("CF-Connecting-IP")??t.headers.get("x-forwarded-for")?.split(",")[0]?.trim()??"unknown"}function io(t,e){let n=K.get(t);return n?e>=n.resetAt?(K.delete(t),!1):n.count>=oo:!1}function ao(t,e){let n=K.get(t);if(!n||e>=n.resetAt){if(K.size>=Xn){for(let[r,o]of K)e>=o.resetAt&&K.delete(r);K.size>=Xn&&K.clear()}K.set(t,{count:1,resetAt:e+Yn});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 uo(t,e){let n=await t.get(Ht);if(n)return n;if(typeof e.SCANNER_TOKEN=="string"&&e.SCANNER_TOKEN)return e.SCANNER_TOKEN;let r=k(24);return await t.put(Ht,r),r}async function lo(t,e,n){if(!e.pathname.startsWith(be))return null;let{store:r,env:o,config:s,auth:a}=n,i=e.pathname.slice(be.length)||"/",c=t.method.toUpperCase();if(i==="/session"&&c==="GET"){let l=await ie(r,t);return C({ok:!0,authenticated:l,panelPath:a.panelPath})}if(i==="/login"&&c==="POST"){let l="";try{let h=await t.json();l=String(h.password??"")}catch{return S(__sfx("6K+35rGC5L2T6Kej5p6Q5aSx6LSl"),400)}if(!l)return S(__sfx("6K+36L6T5YWl5a+G56CB"),400);let u=so(t),f=Date.now();if(io(u,f))return new Response(JSON.stringify({ok:!1,error:__sfx("5bCd6K+V6L+H5LqO6aKR57mB77yM6K+356iN5ZCO5YaN6K+V")}),{status:429,headers:{"Content-Type":"application/json; charset=utf-8","Cache-Control":"no-store","Retry-After":String(Math.ceil(Yn/1e3))}});let d=await An(a,l);if(!d.ok)return ao(u,f),S(__sfx("5a+G56CB6ZSZ6K+v"),401);K.delete(u),d.legacy&&await Cn(r,l).catch(()=>{}),await xn(r).catch(()=>{});let m=await Tn(r);return C({ok:!0},200,{"Set-Cookie":Dn(m)})}if(i==="/logout"&&c==="POST")return await Rn(r,t),C({ok:!0},200,{"Set-Cookie":In()});if(i==="/preferred-ips"&&c==="POST"){let l=t.headers.get("Authorization")??"",u=l.startsWith("Bearer ")?l.slice(7).trim():l.trim();if(!await On(r,u))return S(__sfx("VG9rZW4g5qCh6aqM5aSx6LSl"),401);let d;try{d=await t.json()}catch{return S(__sfx("6K+35rGC5L2T6Kej5p6Q5aSx6LSl"),400)}let m=Array.isArray(d.ips)?d.ips.map(U=>String(U)):[],h=m.map(U=>U.trim()).filter(U=>U.length>0).join(`
|
|
6
|
+
`))}function en(t,e){let n=Qt(e.config.subName);switch(t){case __sfx("Y2xhc2g="):return{body:Mr(e),contentType:"text/yaml; charset=utf-8",fileName:n};case"singbox":return{body:Br(e),contentType:"application/json; charset=utf-8",fileName:n};default:return{body:jr(e),contentType:"text/plain; charset=utf-8",fileName:n}}}var $,gr,mr,je,He,Ke,hr,br,yr,Rr,Or,vr,_,kr,Ye,Qe,Lr,qe,Jt=R(()=>{"use strict";Ne();G();zt();Be();$=443;gr=[__sfx("aXDlnLDlnYA="),__sfx("aXAg5Zyw5Z2A"),"ip",__sfx("5Zyw5Z2A"),__sfx("5pyN5Yqh5Zmo"),"server","host"],mr=[__sfx("56uv5Y+j"),"port"],je=[__sfx("5LiL6L296YCf5bqm"),__sfx("6YCf5bqm"),"speed","download"],He=[__sfx("5bmz5Z2H5bu26L+f"),__sfx("5bu26L+f"),"latency","delay",__sfx("5ZON5bqU5pe26Ze0"),"rtt"],Ke=["colo",__sfx("5py65oi/"),__sfx("5pWw5o2u5Lit5b+D"),__sfx("5Zyw5Yy6"),"region"],hr=[__sfx("5Zu95a62"),"country",__sfx("5Zu95Yir")],br=[__sfx("5Z+O5biC"),"city"],yr=["tls",__sfx("5piv5ZCm5pSv5oyBdGxz"),__sfx("5pSv5oyBdGxz")];Rr={official:__sfx("5a6Y5pa55LyY6YCJSVA="),domain:__sfx("5LyY6YCJ5Z+f5ZCN"),manual:__sfx("5omL5Yqo5LyY6YCJSVA="),api:__sfx("6L+c56iLQVBJ"),csv:__sfx("5rWL6YCfQ1NW")};Or=12e4,vr=32,_=new Map,kr="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36";Ye=[__sfx("dmxlc3Mtd3M="),__sfx("dmxlc3MteGh0dHA="),__sfx("dHJvamFu")];Qe=[__sfx("dmxlc3Mtd3M="),__sfx("dHJvamFu")];Lr=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;qe=".cn,qq.com,tencent.com,weixin.qq.com,baidu.com,bdstatic.com,bilibili.com,hdslb.com,taobao.com,tmall.com,jd.com,aliyun.com,alicdn.com,alipay.com,163.com,126.net,zhihu.com,weibo.com,sina.com.cn,youku.com,iqiyi.com,douyin.com,xiaohongshu.com,mi.com,huawei.com,csdn.net,gitee.com,cnblogs.com".split(",")});function Vr(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 un(t,e){let n=await crypto.subtle.importKey("raw",an.encode(t),{name:"HMAC",hash:"SHA-256"},!1,["sign"]),r=await crypto.subtle.sign("HMAC",n,an.encode(e));return Vr(new Uint8Array(r))}async function It(t){let e=(await t.get(Dt))?.trim();if(e)return e;let n=ln();return t instanceof X&&await t.put(Dt,n),n}async function cn(t){let e=ln();return t instanceof X?await t.put(Dt,e):await t.put(Dt,e),e}async function fn(t,e={}){let n=e.ttlDays??0,r=Math.floor((e.now??Date.now())/1e3),o=n>0?r+Math.round(n*86400):0,s=Math.floor(Math.random()*36**8).toString(36).padStart(8,"0"),a=`${te}.${o.toString(36)}.${s}`,i=(await un(t,a)).slice(0,ee);return`${a}.${i}`}async function Rt(t,e,n=Date.now()){if(!t||!e)return{ok:!1,reason:"format"};let r=e.split(".");if(r.length!==4||r[0]!==te)return{ok:!1,reason:"format"};let o=r[1],s=r[2],a=r[3];if(!o||!s||a.length!==ee)return{ok:!1,reason:"format"};let i=Number.parseInt(o,36);if(!Number.isFinite(i)||i<0)return{ok:!1,reason:"format"};let c=(await un(t,`${te}.${o}.${s}`)).slice(0,ee);return W(a,c)?i>0&&Math.floor(n/1e3)>=i?{ok:!1,reason:"expired",exp:i}:{ok:!0,exp:i}:{ok:!1,reason:"signature"}}var Dt,te,ee,an,ln,ne=R(()=>{"use strict";bt();G();Dt="SUB_TOKEN_SECRET",te="v1",ee=22,an=new TextEncoder;ln=()=>k(32)});function Zr(t){let e="";for(let n of t)e+=(n<16?"0":"")+n.toString(16);return e}function Jr(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 yn(t,e,n){let r=Jr(e);if(!r)return null;let o=await crypto.subtle.importKey("raw",new TextEncoder().encode(t),"PBKDF2",!1,["deriveBits"]),s=await crypto.subtle.deriveBits({name:"PBKDF2",salt:r,iterations:n,hash:"SHA-256"},o,256);return Zr(new Uint8Array(s))}function Pn(t){if(t.startsWith(`${oe}$`)){let[r,o,s,a]=t.split("$");if(r!==oe||!s||!a)return null;let i=Number.parseInt(o??"",10);return!Number.isFinite(i)||i<1||i>1e6?null:{scheme:"pbkdf2",salt:s,iterations:i,expected:a}}let[e,n]=t.split(":");return!e||!n?null:{scheme:"sha256",salt:e,iterations:0,expected:n}}async function wn(t,e){return t.scheme==="pbkdf2"?await yn(e,t.salt,t.iterations):await Mt(`${t.salt}:${e}`)}async function se(t,e){let n=await yn(t,e,mn);return n?`${oe}$${mn}$${e}$${n}`:`${e}:${await Mt(`${e}:${t}`)}`}async function _r(t,e){let n=Pn(t);if(!n)return!1;let r=await wn(n,e);return r?W(r,n.expected):!1}function hn(t){return`/${t.trim().replace(/^\/+/,"")}`}async function En(t,e,n){let r=await t.get(wt)??"",o=n&&n.trim()?hn(n):"";o?r!==o&&(r=o,await t.put(wt,r)):r||(r=hn(`${Se}-${we(6)}`),await t.put(wt,r));let s=await t.get(it)??"",a=null,i=e&&e.trim()?e.trim():"";if(i){if(!s||!await _r(s,i)){let p=k(8);s=await se(i,p),await t.put(it,s)}await t.get(nt)&&await t.delete(nt)}else if(!s){let c=`cfp-${k(8)}`,p=k(8);s=await se(c,p),await t.put(it,s),a=c,await t.put(nt,c)}return{panelPath:r,passwordHash:s,generatedPassword:a}}async function An(t,e){let n=Pn(t.passwordHash);if(!n)return{ok:!1,legacy:!1};let r=await wn(n,e);if(!r)return{ok:!1,legacy:!1};let o=W(r,n.expected);return{ok:o,legacy:o&&n.scheme==="sha256"}}async function Cn(t,e){let n=k(8);await t.put(it,await se(e,n))}async function xn(t){await t.get(nt)&&await t.delete(nt)}function Sn(t){let e=t.headers.get("Cookie")??"",n={};for(let r of e.split(";")){let o=r.indexOf("=");if(o<0)continue;let s=r.slice(0,o).trim(),a=r.slice(o+1).trim();s&&(n[s]=decodeURIComponent(a))}return n}async function Tn(t){let e=k(24);return await t.put(`${Pt}${e}`,JSON.stringify({ua:"",t:Date.now()}),bn),e}async function ie(t,e){let n=Sn(e)[Ot];return n?!!await t.get(`${Pt}${n}`):!1}function Dn(t,e=bn){return`${Ot}=${t}; Path=/; HttpOnly; Secure; SameSite=Strict; Max-Age=${e}`}function In(){return`${Ot}=; Path=/; HttpOnly; Secure; SameSite=Strict; Max-Age=0`}async function Rn(t,e){let n=Sn(e)[Ot];n&&await t.delete(`${Pt}${n}`)}async function Nn(t){let e=k(20);return await t.put(`${yt}${e}`,"1",Qr),e}async function On(t,e){if(!e)return!1;let n=await t.get("SCANNER_TOKEN");return n&&W(n,e)?!0:await t.get(`${yt}${e}`)?(await t.delete(`${yt}${e}`),!0):!1}var Ot,bn,Qr,mn,oe,ae=R(()=>{"use strict";ft();G();Ot=__sfx("Y2ZwaWxvdF9zZXNz"),bn=3600*24,Qr=600,mn=3e4,oe="pbkdf2"});function vn(t){return Ae(t)}async function ue(t,e){if(L.config&&Date.now()-L.configAt<$r)return L.config;let n=await Ie(t,e);return L.config=n,L.configAt=Date.now(),n}function kn(){L.config=null,L.configAt=0}async function le(t,e){if(L.auth&&Date.now()-L.authAt<to)return L.auth;let n=await En(t,e.PANEL_PASSWORD,e.PANEL_PATH);return L.auth=n,L.authAt=Date.now(),n}function ce(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 ht(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 Ln(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 $r,to,L,vt=R(()=>{"use strict";bt();ft();ae();$r=15e3,to=6e4,L={config:null,configAt:0,auth:null,authAt:0}});function fe(t,e,n){if(!t){n.push({field:e,message:""+e+__sfx("IOS4jeiDveS4uuepug==")});return}if(!t.startsWith("/")){n.push({field:e,message:""+e+__sfx("IOW/hemhu+S7pSAvIOW8gOWktA==")});return}if(t.length>128){n.push({field:e,message:""+e+__sfx("IOi/h+mVv++8iOacgOWkmiAxMjgg5a2X56ym77yJ")});return}/[\s\u0000-\u001f]/.test(t)&&n.push({field:e,message:""+e+__sfx("IOS4jeiDveWMheWQq+epuuagvOaIluaOp+WItuWtl+espg==")})}function tt(t,e,n,r,o){if(!Number.isFinite(t)){o.push({field:e,message:""+e+__sfx("IOW/hemhu+aYr+aVsOWtlw==")});return}(t<n||t>r)&&o.push({field:e,message:""+e+__sfx("IOW/hemhu+WcqCA=")+n+" ~ "+r+__sfx("IOS5i+mXtO+8iOW9k+WJjSA=")+t+")"})}function kt(t,e,n){let r=t.split(/\r?\n|,/).map(o=>o.trim()).filter(Boolean);if(r.length>20){n.push({field:e,message:""+e+__sfx("IOacgOWkmiAyMCDmnaHvvIjlvZPliY0g")+r.length+")"});return}for(let o of r)if(!no.test(o)){n.push({field:e,message:""+e+__sfx("IOmHjOacieaXoOazleivhuWIq+eahOadoeebru+8mg==")+o.slice(0,40)+""});return}}function Fn(t,e,n){let r=t.split(/\r?\n|,/).map(o=>o.trim()).filter(Boolean);if(r.length>10){n.push({field:e,message:""+e+__sfx("IOacgOWkmiAxMCDmnaHvvIjlvZPliY0g")+r.length+")"});return}for(let o of r)if(!/^https?:\/\/\S+$/i.test(o)){n.push({field:e,message:""+e+__sfx("IOW/hemhu+aYryBodHRwKHMpIOWcsOWdgO+8mg==")+o.slice(0,40)+""});return}}function pe(t){let e=[],n=o=>Object.prototype.hasOwnProperty.call(t,o);n("wsPath")&&fe(String(t.wsPath??""),"wsPath",e),n(__sfx("dHJvamFuUGF0aA=="))&&fe(String(t.trojanPath??""),__sfx("dHJvamFuUGF0aA=="),e),n(__sfx("eGh0dHBQYXRo"))&&fe(String(t.xhttpPath??""),__sfx("eGh0dHBQYXRo"),e);let r=["wsPath",__sfx("dHJvamFuUGF0aA=="),__sfx("eGh0dHBQYXRo")].filter(o=>n(o)).map(o=>`${o}=${String(t[o]??"")}`);if(r.length>=2){let o=r.map(s=>s.slice(s.indexOf("=")+1));new Set(o).size!==o.length&&e.push({field:"paths",message:__sfx("d3NQYXRoIC8gdHJvamFuUGF0aCAvIHhodHRwUGF0aCDkuI3og73ph43lpI0=")})}if(n("subDomain")){let o=String(t.subDomain??"").trim();o&&(!eo.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=="))&&kt(String(t.proxyIp??""),__sfx("cHJveHlJcA=="),e),n(__sfx("c29ja3M1"))&&kt(String(t.socks5??""),__sfx("c29ja3M1"),e),n("httpProxy")&&kt(String(t.httpProxy??""),"httpProxy",e),n("relayPool")&&kt(String(t.relayPool??""),"relayPool",e),n("officialCount")&&tt(Number(t.officialCount),"officialCount",1,200,e),n("domainCount")&&tt(Number(t.domainCount),"domainCount",1,200,e),n("maxNodes")&&tt(Number(t.maxNodes),"maxNodes",0,500,e),n("dls")&&tt(Number(t.dls),"dls",0,1e3,e),n("maxLatency")&&tt(Number(t.maxLatency),"maxLatency",0,1e4,e),n("dataBudgetMB")&&tt(Number(t.dataBudgetMB),"dataBudgetMB",0,102400,e),n("subTokenTtlDays")&&tt(Number(t.subTokenTtlDays),"subTokenTtlDays",0,3650,e),n("subPorts")){let o=String(t.subPorts??"").trim();if(o){let s=o.split(/[\n,;\s]+/).filter(Boolean);s.length>6?e.push({field:"subPorts",message:__sfx("c3ViUG9ydHMg5pyA5aSaIDYg5Liq56uv5Y+j")}):s.every(a=>/^\d{1,5}$/.test(a)&&Number(a)>=1&&Number(a)<=65535)||e.push({field:"subPorts",message:__sfx("c3ViUG9ydHMg6YeM5q+P5Liq56uv5Y+j6YO95b+F6aG75pivIDF+NjU1MzUg55qE5pWw5a2X")})}}if(n("subName")){let o=String(t.subName??"");o.length>40&&e.push({field:"subName",message:__sfx("c3ViTmFtZSDmnIDlpJogNDAg5a2X56ym")}),/[\u0000-\u001f]/.test(o)&&e.push({field:"subName",message:__sfx("c3ViTmFtZSDkuI3og73ljIXlkKvmjqfliLblrZfnrKY=")})}if(n("addApi")&&Fn(String(t.addApi??""),"addApi",e),n("addCsv")&&Fn(String(t.addCsv??""),"addCsv",e),n("uuid")){let o=String(t.uuid??"").trim();o&&!/^[0-9a-fA-F]{8}-?[0-9a-fA-F]{4}-?[0-9a-fA-F]{4}-?[0-9a-fA-F]{4}-?[0-9a-fA-F]{12}$/.test(o)&&e.push({field:"uuid",message:__sfx("dXVpZCDlv4XpobvmmK/moIflh4YgVVVJRO+8iDM2IOS9je+8jOWPr+W4pui/nuWtl+espu+8iQ==")})}if(n("poolCountries")){let o=String(t.poolCountries??"").trim();if(o){let s=o.split(/[\n,;\s]+/).filter(Boolean);s.length>30?e.push({field:"poolCountries",message:__sfx("cG9vbENvdW50cmllcyDmnIDlpJogMzAg5Liq5Zu95a62L+WcsOWMug==")}):s.every(a=>/^[A-Za-z]{2,3}$/.test(a))||e.push({field:"poolCountries",message:__sfx("cG9vbENvdW50cmllcyDlj6rog73mmK8gMn4zIOS9jeWtl+avjeS7o+eggQ==")})}}if(n("udpDnsEndpoint")){let o=String(t.udpDnsEndpoint??"").trim();o&&!/^https:\/\/\S+$/i.test(o)&&e.push({field:"udpDnsEndpoint",message:__sfx("dWRwRG5zRW5kcG9pbnQg5b+F6aG75pivIGh0dHBzIOWcsOWdgA==")})}return e}function de(t){return t.length===0?"":t.length===1?t[0].message:"有 "+t.length+__sfx("IOmhuemFjee9ruS4jeWQiOazle+8mg==")+t.map(e=>e.message).join("\uFF1B")+""}var eo,no,Un=R(()=>{"use strict";eo=/^(?=.{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])?)*$/,no=/^(?:(?:socks5|socks|socks5h|http|https):\/\/)?(?:[^\s@/]+@)?(?:\[[0-9a-fA-F:]+\]|[A-Za-z0-9._-]+)(?::\d{1,5})?$/});function jn(t,e=Date.now()){let n={};for(let o of Bn){let s=t[o];s!==void 0&&(n[o]=s)}let r=ro.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 Hn(t){let e=new Set([...Bn.map(String),__sfx("c29ja3M1"),"httpProxy"]),n={};for(let[r,o]of Object.entries(t))e.has(r)&&(n[r]=o);return n}function Mn(t){if(t==null)return"\uFF08\u7A7A\uFF09";if(typeof t=="string"){let e=t.replace(/\s+/g," ").trim();return e.length>60?`${e.slice(0,60)}\u2026`:e||"\uFF08\u7A7A\uFF09"}return String(t)}function Kn(t,e){let n=[];for(let[r,o]of Object.entries(e)){let s=t[r];String(s)!==String(o)&&n.push({field:r,from:Mn(s),to:Mn(o)})}return n}var Bn,ro,Wn=R(()=>{"use strict";Bn=["poolOfficial","officialCount","poolDomain","domainCount","poolManual","poolCountries","add","dls","maxLatency","maxNodes",__sfx("cHJveHlJcA=="),"relayPool","useBuiltinRelay","proxyMode","nat64","concurrentDial","dataBudgetMB","resolvePreferred",__sfx("ZW5hYmxlVHJvamFu"),__sfx("ZW5hYmxlWGh0dHA="),"subProtocol","subTransport","subVariants","subName","subPorts","clientFingerprint","ech","echHost","echDns","tlsFragment","tlsFragmentSize","tlsFragmentDelay","subToken","subTokenTtlDays","unlockProbe","udpDns","udpDnsEndpoint"],ro=[{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 Gn(){return new Response(JSON.stringify({build:ge,version:me,ts:Date.now()}),{status:200,headers:{"Content-Type":"application/json","Cache-Control":"no-store","Access-Control-Allow-Origin":"*"}})}var ge,me,zn,he=R(()=>{"use strict";ge="b109ac3-2d5c8203",me=__sfx("MC4xMi42"),zn=__sfx("L19fY2ZwX3ZlcnNpb24=")});var Vn={};tr(Vn,{API_PREFIX:()=>be,getScannerToken:()=>uo,handleApi:()=>lo});function so(t){return t.headers.get("CF-Connecting-IP")??t.headers.get("x-forwarded-for")?.split(",")[0]?.trim()??"unknown"}function io(t,e){let n=K.get(t);return n?e>=n.resetAt?(K.delete(t),!1):n.count>=oo:!1}function ao(t,e){let n=K.get(t);if(!n||e>=n.resetAt){if(K.size>=Xn){for(let[r,o]of K)e>=o.resetAt&&K.delete(r);K.size>=Xn&&K.clear()}K.set(t,{count:1,resetAt:e+Yn});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 uo(t,e){let n=await t.get(Ht);if(n)return n;if(typeof e.SCANNER_TOKEN=="string"&&e.SCANNER_TOKEN)return e.SCANNER_TOKEN;let r=k(24);return await t.put(Ht,r),r}async function lo(t,e,n){if(!e.pathname.startsWith(be))return null;let{store:r,env:o,config:s,auth:a}=n,i=e.pathname.slice(be.length)||"/",c=t.method.toUpperCase();if(i==="/session"&&c==="GET"){let l=await ie(r,t);return C({ok:!0,authenticated:l,panelPath:a.panelPath})}if(i==="/login"&&c==="POST"){let l="";try{let h=await t.json();l=String(h.password??"")}catch{return S(__sfx("6K+35rGC5L2T6Kej5p6Q5aSx6LSl"),400)}if(!l)return S(__sfx("6K+36L6T5YWl5a+G56CB"),400);let u=so(t),f=Date.now();if(io(u,f))return new Response(JSON.stringify({ok:!1,error:__sfx("5bCd6K+V6L+H5LqO6aKR57mB77yM6K+356iN5ZCO5YaN6K+V")}),{status:429,headers:{"Content-Type":"application/json; charset=utf-8","Cache-Control":"no-store","Retry-After":String(Math.ceil(Yn/1e3))}});let d=await An(a,l);if(!d.ok)return ao(u,f),S(__sfx("5a+G56CB6ZSZ6K+v"),401);K.delete(u),d.legacy&&await Cn(r,l).catch(()=>{}),await xn(r).catch(()=>{});let m=await Tn(r);return C({ok:!0},200,{"Set-Cookie":Dn(m)})}if(i==="/logout"&&c==="POST")return await Rn(r,t),C({ok:!0},200,{"Set-Cookie":In()});if(i==="/preferred-ips"&&c==="POST"){let l=t.headers.get("Authorization")??"",u=l.startsWith("Bearer ")?l.slice(7).trim():l.trim();if(!await On(r,u))return S(__sfx("VG9rZW4g5qCh6aqM5aSx6LSl"),401);let d;try{d=await t.json()}catch{return S(__sfx("6K+35rGC5L2T6Kej5p6Q5aSx6LSl"),400)}let m=Array.isArray(d.ips)?d.ips.map(U=>String(U)):[],h=m.map(U=>U.trim()).filter(U=>U.length>0).join(`
|
|
7
7
|
`);await r.get(H)!==h&&await r.put(H,h);let w={};(s.add??"").trim()!==""&&(w.add=""),s.poolManual||(w.poolManual=!0);let O=!1;return Object.keys(w).length>0&&(await ut(r,at(s,w)),n.onConfigChanged(),O=w.add!==void 0),C({ok:!0,count:m.length,clearedManual:O,enabledManual:w.poolManual===!0})}if(!await ie(r,t))return S(__sfx("5pyq55m75b2V5oiW5Lya6K+d5bey6L+H5pyf"),401);if(i==="/status"&&c==="GET"){let l=await lt(r),u=gt(l),f=ht(s.subDomain||o.DATA_HOST||e.hostname);return C({ok:!0,panelPath:a.panelPath,domain:e.hostname,nodeDomain:f,dataHost:o.DATA_HOST??"",colo:t.cf?.colo??"UNK",coloLabel:dt(t.cf?.colo??""),localIps:u.length,generatedPassword:a.generatedPassword,version:ge,pkgVersion:me,readAt:Date.now()})}if(i==="/config"&&c==="GET")return C({ok:!0,config:s});if(i==="/config"&&c==="PUT"){let l;try{l=await t.json()}catch{return S(__sfx("6K+35rGC5L2T6Kej5p6Q5aSx6LSl"),400)}if(!l.config||typeof l.config!="object")return S(__sfx("57y65bCR6YWN572u5a+56LGh"),400);let u=pe(l.config);if(u.length>0)return S(de(u),400);let f=at(s,l.config);return await ut(r,f),n.onConfigChanged(),C({ok:!0,config:f})}if(i==="/config/export"&&c==="GET")return C({ok:!0,...jn(s)});if(i==="/config/import"&&c==="POST"){let l;try{l=await t.json()}catch{return S(__sfx("6K+35rGC5L2T6Kej5p6Q5aSx6LSl"),400)}if(!l.config||typeof l.config!="object")return S(__sfx("57y65bCR6YWN572u5a+56LGh"),400);let u=Hn(l.config);if(Object.keys(u).length===0)return S(__sfx("5rKh5pyJ5Y+v5a+85YWl55qE5a2X5q6177yI56Gu6K6k5piv5pys6aG555uu5a+85Ye655qE6YWN572u5paH5Lu277yf77yJ"),400);let f=pe(u);if(f.length>0)return S(de(f),400);let d=Kn(s,u);if(l.dryRun)return C({ok:!0,dryRun:!0,diff:d,count:d.length});if(d.length===0)return C({ok:!0,applied:0,diff:[],config:s});let m=at(s,u);return await ut(r,m),n.onConfigChanged(),C({ok:!0,applied:d.length,diff:d,config:m})}if(i==="/ips"&&c==="GET"){let l=await lt(r),u=gt(l);return C({ok:!0,raw:l,count:u.length,entries:u})}if(i==="/ips"&&c==="DELETE")return await r.delete(H),C({ok:!0});if(i==="/ips"&&c==="PUT"){let l;try{l=await t.json()}catch{return S(__sfx("6K+35rGC5L2T6Kej5p6Q5aSx6LSl"),400)}if(typeof l.raw!="string")return S(__sfx("57y65bCRIHJhdyDlrZfmrrU="),400);let u=l.raw.split(/\r?\n/).map(f=>f.trim()).filter(f=>f.length>0).join(`
|
|
8
8
|
`);return u?await r.put(H,u):await r.get(H)!==null&&await r.delete(H),C({ok:!0,count:u?u.split(`
|
|
9
9
|
`).length:0})}if(i==="/nodes"&&c==="GET"){let l=await lt(r),u=await ct(r),f=new rt(8),d=await Tt(s,l,{budget:f,domainPool:u.length>0?u:void 0,bypassRemoteCache:!0});return C({ok:!0,count:d.nodes.length,nodes:d.nodes.slice(0,200).map(m=>({...m,coloLabel:m.colo?dt(m.colo):""})),groups:d.groups.map(m=>({key:m.key,name:m.name,count:m.entries.length})),stats:d.stats})}if(i==="/pool/meta"&&c==="GET"){let l=await ct(r);return C({ok:!0,countries:Fe.map(u=>({code:u,name:ve[u]??u})),limits:{officialCount:200,domainCount:100},builtin:{cidrs:Et.length,domains:pt.length},customDomains:l})}if(i==="/pool/library"&&c==="PUT"){let l;try{l=await t.json()}catch{return S(__sfx("6K+35rGC5L2T6Kej5p6Q5aSx6LSl"),400)}let u=Array.isArray(l.domains)?l.domains.map(f=>String(f)):[];return await Re(r,u),C({ok:!0,count:u.filter(f=>f.trim()).length})}if(i==="/scanner-token"&&c==="POST"){let l=await Nn(r);return C({ok:!0,token:l,expiresIn:600})}if(i==="/sub-token"&&(c==="GET"||c==="POST")){let l=c==="POST",u=l?await cn(r):await It(r),f=await fn(u,{ttlDays:s.subTokenTtlDays}),d=await Rt(u,f);return C({ok:!0,rotated:l,mode:s.subToken,ttlDays:s.subTokenTtlDays,token:f,link:`${e.origin}/sub/${f}`,expiresAt:(d.exp??0)*1e3})}return i==="/events"&&c==="GET"?await co(t,r):S(__sfx("5o6l5Y+j5LiN5a2Y5Zyo"),404)}async function co(t,e){let n=new TextEncoder,r="",o,s=new ReadableStream({async start(a){let i=()=>{o&&clearTimeout(o);try{a.close()}catch{}};t.signal.addEventListener("abort",i);let c=async()=>{try{let p=await lt(e);if(p!==r){r=p;let l=gt(p).length;a.enqueue(n.encode(__sfx("ZXZlbnQ6IGlwcwpkYXRhOiA=")+JSON.stringify({count:l})+"\n\n"))}else a.enqueue(n.encode(`: keepalive
|
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 l=Date.now()+Ge,u="";for(;;){let T=s.peek(),x=sr(T);if(x>=0){u=new TextDecoder().decode(T.subarray(0,x)),s.skip(x+4);break}if(T.byteLength>8192)throw new Error(__sfx("SFRUUCDku6PnkIblk43lupTlpLTotoXov4cgODE5MiDlrZfoioI="));let p=l-Date.now();if(p<=0)throw new Error(__sfx("SFRUUCDku6PnkIbmj6HmiYvotoXml7bvvIg=")+Ge+__sfx("bXMg5peg5ZON5bqU77yJ"));let b=await Promise.race([s.fill(),new Promise(S=>setTimeout(()=>S("timeout"),p))]);if(b==="timeout")throw new Error(__sfx("SFRUUCDku6PnkIbmj6HmiYvotoXml7bvvIg=")+Ge+__sfx("bXMg5peg5ZON5bqU77yJ"));if(b===null)throw new Error(__sfx("SFRUUCDku6PnkIblk43lupTkuI3lrozmlbTvvIjov57mjqXooqvmj5DliY3lhbPpl63vvIk="))}let h=u.split(`\r
|
|
3
3
|
`)[0]??"",g=/^HTTP\/1\.[01]\s+(\d{3})/.exec(h);if(!g)throw new Error(__sfx("SFRUUCDku6PnkIblk43lupTpnZ7ms5U="));if(g[1]!=="200")throw new Error(__sfx("SFRUUCDku6PnkIYgQ09OTkVDVCDlpLHotKXvvJo=")+g[1]+"");return s.release()}finally{try{i.releaseLock()}catch{}}}var or,Ge,Bt=E(()=>{"use strict";oe();or=[13,10,13,10];Ge=6e3});function lr(e){return/^\d{1,3}(\.\d{1,3}){3}$/.test(e)?!0:e.includes(":")&&/^[0-9a-fA-F:.]+$/.test(e)}function cr(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 ur(e,t,n,o=zt){try{let r=`${e}?name=${encodeURIComponent(t)}&type=${n}`,s=await fetch(r,{headers:{accept:"application/dns-json"},signal:AbortSignal.timeout(o)});if(!s.ok)return[];let i=await s.json();if(!i||i.Status!==0||!Array.isArray(i.Answer))return[];let a=n==="TXT"?16:n==="A"?1:28;return i.Answer.filter(c=>c.type===a).map(c=>String(c.data))}catch{return[]}}async function Kt(e,t,n={}){for(let o of ir){if(n.deadline!==void 0&&Date.now()>=n.deadline)break;let r=n.timeoutMs??zt,s=n.deadline!==void 0?n.deadline-Date.now():Number[__sfx("UE9TSVRJVkVfSU5GSU5JVFk=")],i=Math.max(50,Math.min(r,s)),a=await ur(o,e,t,i);if(a.length>0)return a}return[]}function fr(e,t){let n=[],o=String(e).replace(/^"|"$/g,"").replace(/\\010/g,",").replace(/\\n/g,",").trim();if(!o||o===Wt)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:c}=cr(i,t);if(!O(a)&&!Y(a))return[];n.push({hostname:a,port:c})}return n}async function we(e,t,n={}){let o=e.trim();if(!o)return[];if(lr(o))return[{hostname:o,port:t}];let r=`${o}:${t}`,s=Ht.get(r);if(s&&Date.now()-s.at<ar)return s.ips;let i=[],[a,c]=await Promise.all([n.skipTxt?Promise.resolve([]):Kt(o,"TXT",n),Kt(o,"A",n)]);if(!n.skipTxt)for(let u of a){let d=fr(u,t);if(d.length>0){i.push(...d);break}if(String(u).replace(/^"|"$/g,"").replace(/\\010/g,",").trim()===Wt)break}if(i.length===0)for(let u of c)O(u)&&i.push({hostname:u,port:t});let f=[],l=new Set;for(let u of i){let d=`${u.hostname}:${u.port}`;l.has(d)||(l.add(d),f.push(u))}return f.length>0&&Ht.set(r,{at:Date.now(),ips:f}),f}var Wt,ir,zt,ar,Ht,Xe=E(()=>{"use strict";j();Wt=__sfx("QGVkZ2V0dW5uZWw="),ir=["https://cloudflare-dns.com/dns-query","https://dns.alidns.com/resolve","https://doh.pub/dns-query"],zt=4e3,ar=300*1e3,Ht=new Map});var _e={};he(_e,{[__sfx("QlVJTFRJTl9SRUxBWV9ET01BSU5T")]:()=>Yt,[__sfx("QlVJTFRJTl9SRUxBWV9SRUdJT04=")]:()=>Ae,[__sfx("Q09MT19UT19DT1VOVFJZ")]:()=>Vt,[__sfx("UkVHSU9OX0FESkFDRU5DWQ==")]:()=>Gt,[__sfx("UkVHSU9OX09SREVS")]:()=>Ve,[__sfx("UkVMQVlfQkFUQ0hfU0laRQ==")]:()=>J,[__sfx("UkVMQVlfRE9NQUlOX0xJTUlU")]:()=>Ze,[__sfx("VU5LTk9XTl9SRUdJT04=")]:()=>jt,clearRelayCache:()=>hr,collectRelayEndpoints:()=>se,coloToCountry:()=>xe,rankRegions:()=>Je,regionOfEntry:()=>Ye,resolveRelayEntry:()=>Qe,selectRelayDomains:()=>Qt,sortEndpointsByRegion:()=>Xt});function Ye(e){let n=e.trim().toLowerCase().replace(/:\d{1,5}$/,"");return Ae[n]??jt}function Je(e){let t=(e??"").trim().toUpperCase();if(!t)return[...Ve];let n=Gt[t]??[],o=Ve.filter(r=>r!==t&&!n.includes(r));return[t,...n,...o]}function Xt(e,t){let n=Je(t),o=r=>{let s=n.indexOf(r);return s>=0?s:n.length};return e.map((r,s)=>({e:r,i:s})).sort((r,s)=>{let i=o(r.e.regionCode),a=o(s.e.regionCode);return i!==a?i-a:r.i-s.i}).map(r=>r.e)}function xe(e){let t=String(e??"").toUpperCase();return t?Vt[t]??(/^[A-Z]{2}$/.test(t)?t:"US"):"US"}async function Qe(e,t=443,n=qt,o={}){let r=e.trim();if(!r)return[];let s=`${r}:${t}:${n}`,i=qe.get(s);if(i&&Date.now()-i.at<mr)return i.ips;let a=r,c=t,f=(r.match(/:/g)??[]).length;if(f===1){let u=/^(.*):(\d{1,5})$/.exec(r);u&&(a=u[1],c=Number(u[2]))}else if(f>1&&r.startsWith("[")){let u=/^\[([^\]]+)\]:(\d{1,5})$/.exec(r);u&&(a=u[1],c=Number(u[2]))}let l=[];if(O(a)||Y(a))l=[{ip:a,port:Number.isInteger(c)&&c>0?c:t,label:r,regionCode:Ye(r)}];else try{l=(await we(a,c,{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}`,regionCode:Ye(r)}))}catch{l=[]}return l.length>0&&qe.set(s,{at:Date.now(),ips:l}),l}function Qt(e,t=Ze){let n=xe(e),o=Je(n),r=s=>{let i=Ae[s];if(!i)return o.length+1;let a=o.indexOf(i);return a>=0?a:o.length};return Yt.map((s,i)=>({d:s,i,rank:r(s)})).sort((s,i)=>s.rank!==i.rank?s.rank-i.rank:s.i-i.i).map(s=>s.d).slice(0,Math.max(0,t))}async function se(e={}){let t=e.perDomain??qt,n=[],o=new Set,r=p=>{for(let b of p){let S=`${b.ip}:${b.port}`;o.has(S)||(o.add(S),n.push(b))}},s=(e.userEntries??"").trim(),i=s?s.split(/[\n,;]+/).map(p=>p.trim()).filter(Boolean):[],a=e.domainLimit??Ze,c=e.useBuiltin!==!1?Qt(e.colo,a):[],f=p=>e.perDomain!==void 0?t:Ae[p]===xe(e.colo)?pr:dr,l=await Promise.all([...i.map(p=>Qe(p,443,t,{deadline:e.deadline,timeoutMs:e.timeoutMs})),...c.map(p=>Qe(p,443,f(p),{skipTxt:!0,deadline:e.deadline,timeoutMs:e.timeoutMs}))]),u=n.length;for(let p=0;p<i.length;p++)r(l[p]);let d=n.length-u,h=l.slice(i.length),g=h.reduce((p,b)=>Math.max(p,b.length),0);for(let p=0;p<g;p++)for(let b of h)p<b.length&&r([b[p]]);let T=n.slice(0,d),x=Xt(n.slice(d),xe(e.colo));return[...T,...x]}function hr(){qe.clear()}var jt,Gt,Ve,Ae,Yt,Vt,qt,J,Ze,pr,dr,mr,qe,ie=E(()=>{"use strict";j();Xe();jt="??";Gt={[__sfx("VVM=")]:["SG","JP","KR"],[__sfx("U0c=")]:["JP","KR","US"],[__sfx("SlA=")]:["SG","KR","US"],[__sfx("S1I=")]:["JP","SG","US"],[__sfx("REU=")]:["NL","GB","SE","FI"],[__sfx("U0U=")]:["DE","NL","FI","GB"],[__sfx("Tkw=")]:["DE","GB","SE","FI"],[__sfx("Rkk=")]:["SE","DE","NL","GB"],[__sfx("R0I=")]:["DE","NL","SE","FI"]},Ve=["US","SG","JP","KR","DE","SE","NL","FI","GB"];Ae={[__sfx("cHJveHlpcC5oay5jbWxpdXNzc3MubmV0")]:"HK",[__sfx("cHJveHlpcC51cy5jbWxpdXNzc3MubmV0")]:"US",[__sfx("cHJveHlpcC5zZy5jbWxpdXNzc3MubmV0")]:"SG",[__sfx("cHJveHlpcC5qcC5jbWxpdXNzc3MubmV0")]:"JP",[__sfx("cHJveHlpcC5rci5jbWxpdXNzc3MubmV0")]:"KR",[__sfx("cHJveHlpcC5kZS5jbWxpdXNzc3MubmV0")]:"DE",[__sfx("cHJveHlpcC5zZS5jbWxpdXNzc3MubmV0")]:"SE",[__sfx("cHJveHlpcC5ubC5jbWxpdXNzc3MubmV0")]:"NL",[__sfx("cHJveHlpcC5maS5jbWxpdXNzc3MubmV0")]:"FI",[__sfx("cHJveHlpcC5nYi5jbWxpdXNzc3MubmV0")]:"GB",[__sfx("cHJveHlpcC5vcmFjbGUuY21saXVzc3NzLm5ldA==")]:"Oracle",[__sfx("cHJveHlpcC5kaWdpdGFsb2NlYW4uY21saXVzc3NzLm5ldA==")]:"DigitalOcean",[__sfx("cHJveHlpcC52dWx0ci5jbWxpdXNzc3MubmV0")]:"Vultr",[__sfx("cHJveHlpcC5tdWx0YWNvbS5jbWxpdXNzc3MubmV0")]:"Multacom"},Yt=[__sfx("cHJveHlpcC5oay5jbWxpdXNzc3MubmV0"),__sfx("cHJveHlpcC5qcC5jbWxpdXNzc3MubmV0"),__sfx("cHJveHlpcC5zZy5jbWxpdXNzc3MubmV0"),__sfx("cHJveHlpcC51cy5jbWxpdXNzc3MubmV0"),__sfx("cHJveHlpcC5kZS5jbWxpdXNzc3MubmV0"),__sfx("cHJveHlpcC5nYi5jbWxpdXNzc3MubmV0"),__sfx("cHJveHlpcC5rci5jbWxpdXNzc3MubmV0"),__sfx("cHJveHlpcC5ubC5jbWxpdXNzc3MubmV0"),__sfx("cHJveHlpcC5zZS5jbWxpdXNzc3MubmV0"),__sfx("cHJveHlpcC5maS5jbWxpdXNzc3MubmV0"),__sfx("cHJveHlpcC5vcmFjbGUuY21saXVzc3NzLm5ldA=="),__sfx("cHJveHlpcC5kaWdpdGFsb2NlYW4uY21saXVzc3NzLm5ldA=="),__sfx("cHJveHlpcC52dWx0ci5jbWxpdXNzc3MubmV0"),__sfx("cHJveHlpcC5tdWx0YWNvbS5jbWxpdXNzc3MubmV0")],Vt={[__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"};qt=4,J=6,Ze=3,pr=2,dr=1,mr=30*1e3,qe=new Map});function Jt(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 Z(e){let t=Jt(e);if(t===null)return!1;for(let[n,o]of gr){let r=Jt(n);if(r===null)continue;let s=o===0?0:4294967295<<32-o>>>0;if((t&s)===(r&s))return!0}return!1}function Zt(e){let t=[],n=new Set,o=l=>{let u=`${l.source}|${l.host}|${l.port}`;n.has(u)||(n.add(u),t.push(l))};for(let l of e.proxies??[])l.kind==="direct"?o({source:"proxy",host:l.host,port:l.port,label:__sfx("UHJveHlJUCA=")+l.host+":"+l.port+"",via:{kind:"direct",host:l.host,port:l.port}}):o({source:"proxy",host:l.host,port:l.port,label:`${l.kind.toUpperCase()} ${l.host}:${l.port}`,via:{kind:l.kind,host:l.host,port:l.port,username:l.username,password:l.password,serverName:l.serverName}});let s=Z(e.targetHost)||e.deprioritizeDirect===!0;o({source:"direct",host:e.targetHost,port:e.targetPort,label:__sfx("55u06L+eIA==")+e.targetHost+":"+e.targetPort+"",deprioritized:s});let i=e.optimizedIps??[],a=i.filter(l=>!Z(l.ip)),c=i.filter(l=>Z(l.ip));for(let l of a)o({source:"optimized",host:l.ip,port:l.port,label:__sfx("5LyY6YCJIA==")+l.ip+":"+l.port+""});for(let l of c)o({source:"optimized",host:l.ip,port:l.port,label:__sfx("5LyY6YCJIA==")+l.ip+":"+l.port+__sfx("77yIQ2xvdWRmbGFyZSDnvZHmrrXvvIzlj6/og73kuI3lj6/ovr7vvIk="),deprioritized:!0});let f=e.relay??[];for(let l of f)o({source:"relay",host:l.ip,port:l.port,label:__sfx("5Y+N5LujIA==")+l.label+"",deprioritized:!e.relayAsPrimary});return t.map((l,u)=>({candidate:l,index:u})).sort((l,u)=>{let d=+!!l.candidate.deprioritized-+!!u.candidate.deprioritized;return d!==0?d:l.index-u.index}).map(l=>l.candidate)}function _t(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 $t(e,t){let n=e instanceof Error?e.message:String(e);return/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 en(e){switch(e.kind){case"blocked":return __sfx("5Ye656uZ6KKrIENsb3VkZmxhcmUg5ouS57ud77yI")+e.candidate+"):"+e.message+__sfx("CiAg5bi46KeB5Y6f5Zug77ya55uu5qCH5Zyw5Z2A5ZyoIENsb3VkZmxhcmUg6Ieq5a62572R5q6177yIV29ya2VyIOS4jeiDveS4u+WKqOi/nuWbniBDRiDoh6rlt7HnmoTlhaXlj6PvvInjgIIKICDihpIg5o2i5LiA5Liq56ys5LiJ5pa5IElQ77yM5oiW5pS555So5Luj55CG6JC95Zyw44CC");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 gr,$e=E(()=>{"use strict";gr=[[__sfx("MTA0LjE2LjAuMA=="),13],[__sfx("MTA0LjI0LjAuMA=="),14],[__sfx("MTA0LjMxLjAuMA=="),15],[__sfx("MTcyLjY0LjAuMA=="),13],[__sfx("MTYyLjE1OC4wLjA="),15],[__sfx("MTg4LjExNC45Ni4w"),20],[__sfx("MTQxLjEwMS42NC4w"),18],[__sfx("MTA4LjE2Mi4xOTIuMA=="),18],[__sfx("MTAzLjIxLjI0NC4w"),22],[__sfx("MTAzLjIyLjIwMC4w"),22],[__sfx("MTAzLjMxLjQuMA=="),22],[__sfx("MTMxLjAuNzIuMA=="),22],[__sfx("MTk3LjIzNC4yNDAuMA=="),22],[__sfx("MTk4LjQxLjEyOC4w"),17],[__sfx("MTkyLjAuMC4w"),24],[__sfx("MTkyLjAuMi4w"),24],[__sfx("MTkyLjg4Ljk5LjA="),24],[__sfx("MTk5LjI3LjEyOC4w"),21],[__sfx("MjIzLjUuNS4w"),24],[__sfx("MS4wLjAuMA=="),24],[__sfx("MS4xLjEuMA=="),24]]});function tn(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 h=s[1].toLowerCase();r=n.slice(s[0].length),h===__sfx("c29ja3M1")||h===__sfx("c29ja3M=")||h===__sfx("c29ja3M1aA==")?o=__sfx("c29ja3M1"):h==="https"?o="https":h==="http"&&(o="http")}let i=r.lastIndexOf("@"),a={};if(i>=0){let h=r.slice(0,i);r=r.slice(i+1);let g=h.indexOf(":");g>=0?a={username:h.slice(0,g),password:h.slice(g+1)}:a={username:h}}let c,f=/#sni=([^/#]+)/i.exec(r);f&&(c=f[1].trim(),r=r.slice(0,f.index)+r.slice(f.index+f[0].length));let l=r.lastIndexOf(":");if(l<0)return null;let u=r.slice(0,l).replace(/^\[|\]$/g,""),d=Number(r.slice(l+1));return!u||!Number.isInteger(d)||d<=0||d>65535?null:(!c&&o==="https"&&!yr(u)&&(c=u),{host:u,port:d,kind:o,...a,...c?{serverName:c}:{}})}function yr(e){return/^\d{1,3}(\.\d{1,3}){3}$/.test(e)}function ae(e,t="direct"){let n=[];for(let o of e.split(/[\n,;]+/)){let r=o.trim();if(!r)continue;let s=tn(r,t);s&&n.push(s)}return n}var et=E(()=>{"use strict"});async function br(){return tt||(tt=(async()=>(await import("cloudflare:sockets")).connect)()),await tt}function xr(e,t){if(!O(e))return null;let n=e.split(".").map(i=>Number(i)),o=(n[0]<<8|n[1]).toString(16),r=(n[2]<<8|n[3]).toString(16);return`${t.replace(/:+$/,"")}::${o}:${r}`}async function Ee(e,t,n,o,r){let i=(await br())({hostname:e,port:t},o?{secureTransport:o}:void 0),a=async(f,l)=>{let u,d=new Promise((h,g)=>{u=setTimeout(()=>g(new Error(""+l+__sfx("6LaF5pe277ya")+e+":"+t+"")),n)});try{return await Promise.race([f,d])}finally{u&&clearTimeout(u)}},c;try{if(await a(i.opened,__sfx("6L+e5o6l")),o==="starttls"){if(c=i.startTls?.(r?{expectedServerHostname:r}:void 0),!c)throw new Error(__sfx("5b2T5YmN6L+Q6KGM5pe25LiN5pSv5oyBIHN0YXJ0VGxz"));return await a(c.opened,__sfx("VExTIOaPoeaJiw==")),c}return i}catch(f){try{await(c??i).close()}catch{}throw f}}async function Ar(e){let t=e.timeoutMs??ot;try{let n=await Ee(e.hostname,e.port,t);return{readable:n.readable,writable:n.writable,via:"direct",endpoint:`${e.hostname}:${e.port}`,close:()=>{try{n.close()}catch{}}}}catch(n){if(e.nat64&&O(e.hostname)){let o=xr(e.hostname,e.nat64);if(o){let r=await Ee(o,e.port,t);return{readable:r.readable,writable:r.writable,via:"nat64",endpoint:`${o}:${e.port}`,close:()=>{try{r.close()}catch{}}}}}throw n}}async function Er(e,t){let n=e.timeoutMs??ot;if(t.kind==="direct"){let s=await Ee(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 Ee(t.host,t.port,n,o,t.kind==="https"?t.serverName:void 0);try{return t.kind==="http"||t.kind==="https"?{readable:await Ft(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 Nt(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 rn(e){return e instanceof Error?e.message:typeof e=="string"?e:String(e)}function Sr(e){if(e.length===0)return __sfx("5pyq55+l5Y6f5Zug");let t=e.map(rn),n=t.slice(-Pr),o=t.length-n.length;return`${o>0?`\uFF08\u5171 ${t.length} \u6761\uFF0C\u7701\u7565\u524D ${o} \u6761\uFF09`:""}${n.join("\uFF1B")}`}function Cr(e){return e.length===0?Promise.reject(new Error(__sfx("5rKh5pyJ5Y+v55So55qE5Ye656uZ5ouo5Y+35pa55byP"))):new Promise((t,n)=>{let o=e.length,r=!1,s=[];for(let i of e)i().then(a=>{if(r){try{a.writable.getWriter().close()}catch{}return}r=!0,t(a)},a=>{s.push(a),o-=1,o===0&&!r&&(r=!0,n(new Error(__sfx("5pys5om5IA==")+e.length+__sfx("IOS4quWAmemAieWFqOmDqOWksei0pe+8mg==")+Sr(s)+"")))})})}async function rt(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+=nt){let i=e.slice(s,s+nt);try{return await Cr(i)}catch(a){o=a,n.push(rn(a))}}throw new Error(__sfx("5YWo6YOoIA==")+e.length+__sfx("IOS4quWAmemAieWdh+Wksei0pe+8iOWIhiA=")+n.length+__sfx("IOaJue+8jOavj+aJueacgOWkmiA=")+nt+__sfx("IOS4quW5tuWPke+8ie+8mgo=")+n.join(`
|
|
4
4
|
`),{cause:o})}async function nn(e,t){let n=[...e];if(!t)return n;try{let o=await se(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 Tr(e,t,n){if(e.length===0)return null;for(let o=0;o<e.length;o+=J){let s=e.slice(o,o+J).map(i=>t({source:"relay",host:i.ip,port:i.port,label:__sfx("5Y+N5LujIA==")+i.label+""}));try{return await rt(s,n)}catch{}}return null}async function le(e){let t=e.proxies??[],n=e.concurrent??!0,o=e.budgetMs??wr,r=Date.now()+o,s=[...e.optimizedIps??[]],i=!1;if(e.resolvePreferred)try{let y=await we(e.hostname,e.port,{deadline:r});if(y.length>0){i=!0;for(let C of y)s.push({ip:C.hostname,port:C.port})}}catch{}let a=Z(e.hostname),c=i&&s.length>0&&s.every(y=>Z(y.ip)),f=[...e.relay??[]],l=c||a;l&&e.relayPool&&(f=await nn(f,{...e.relayPool,deadline:r}));let u=l?f.slice(0,J):[],d=l?f.slice(J):[],h=Zt({targetHost:e.hostname,targetPort:e.port,optimizedIps:s,proxies:t,deprioritizeDirect:a||c,relay:u,relayAsPrimary:u.length>0});if(h.length===0)throw new Error(__sfx("5rKh5pyJ5Y+v55So55qE5Ye656uZ5ouo5Y+35pa55byP"));let g=y=>async()=>{let C=r-Date.now();if(C<=0)throw new Error(__sfx("5ouo5Y+36aKE566X5bey55So5bC977yI")+o+"ms):"+e.hostname+":"+e.port+"");let v=Math.max(200,Math.min(e.timeoutMs??ot,C)),W={...e,timeoutMs:v};try{return y.source==="proxy"&&y.via?await Er(W,{host:y.via.host,port:y.via.port,kind:y.via.kind,username:y.via.username,password:y.via.password,serverName:y.via.serverName}):await Ar({...W,hostname:y.host,port:y.port})}catch(ne){let pe=$t(ne,y.label);throw e.onFailure?.(pe),ne}},T=_t(h),{landing:x,[__sfx("cHJveHlJcA==")]:p,direct:b,fallback:S}=T,R=x.length>0||p.length>0,X=async()=>{if(x.length===0)throw new Error(__sfx("5pyq6YWN572u6JC95Zyw5Luj55CG"));let y;for(let C of x)try{return await g(C)()}catch(v){y=v}throw y??new Error(__sfx("6JC95Zyw5Luj55CG5YWo6YOo5aSx6LSl"))},k=async()=>{if(p.length===0)throw new Error(__sfx("5pyq6YWN572uIFByb3h5SVA="));return await rt(p.map(g),!0)},H=async()=>{let y;if(x.length>0)try{return await X()}catch(C){y=C}if(p.length>0)try{return await k()}catch(C){y=C}throw y??new Error(__sfx("5rKh5pyJ5Y+v55So55qE5Luj55CG"))},Q=async()=>await rt(b.map(g),n),M=async()=>{let y=d;return y.length===0&&e.relayPool&&(y=await nn([],{...e.relayPool,deadline:r})),await Tr(y,g,n)},F=async()=>{for(let y of S)try{return await g(y)()}catch{}return null};if(!R)try{return await Q()}catch(y){let C=await M();if(C)return C;let v=await F();if(v)return v;throw y}let K=e.proxyMode??"only",fe=a||c;if(K==="only")try{return await H()}catch(y){let C=await M();if(C)return C;let v=await F();if(v)return v;throw y}if(K==="global"||K==="smart"&&fe)try{return await H()}catch(y){if(K==="global")try{return await Q()}catch{}let C=await M();if(C)return C;let v=await F();if(v)return v;throw y}try{return await Q()}catch(y){try{return await H()}catch{}let C=await M();if(C)return C;let v=await F();if(v)return v;throw y}}var tt,ot,wr,nt,Pr,st=E(()=>{"use strict";Mt();Bt();j();Xe();ie();$e();et();tt=null;ot=8e3,wr=15e3;nt=6,Pr=8});async function on(e,t,n,o=!0,r){let s=e.getReader(),i=t.getWriter();try{for(;!n?.exhausted;){let{done:a,value:c}=await s.read();if(a)break;if(!(!c||c.byteLength===0)){if(r?.(c.byteLength))break;await i.write(c)}}}catch{}finally{if(o)try{await i.close()}catch{}else try{i.releaseLock()}catch{}try{s.releaseLock()}catch{}}}var _,Pe=E(()=>{"use strict";_=class{constructor(t){this.limitBytes=t}limitBytes;total=0;get enabled(){return this.limitBytes>0}get bytes(){return this.total}add(t){return this.limitBytes<=0||t<=0?!1:(this.total+=t,this.total>this.limitBytes)}}});var pn={};he(pn,{[__sfx("aGFuZGxlV2ViU29ja2V0")]:()=>Te,recentDiagnostics:()=>vr,recordDiagnostics:()=>$,truncateCloseReason:()=>fn});function fn(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 $(e,t,n){Ce.unshift({at:Date.now(),target:e,failures:t,summary:n}),Ce.length>un&&(Ce.length=un)}function vr(){return Ce}function Ur(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 Te(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 c=Ur(e.headers.get(__sfx("c2VjLXdlYnNvY2tldC1wcm90b2NvbA=="))),f=!1,l=null,u=null,d=null,h=null,g=!1,T=!1,x=null,p=null,b=m=>{try{a.send(m)}catch{}},S=m=>{let A=new Uint8Array(2+m.byteLength);A[0]=0,A[1]=m.byteLength,A.set(m,2),b(A)},R=(m,A)=>{g=!0;try{a.close(m,fn(A))}catch{}X()},X=()=>{if(!T){if(T=!0,fe(),d&&(clearTimeout(d),d=null),k&&(clearTimeout(k),k=null),h){let m=h;h=null;try{m.cancel()}catch{}}if(l){let m=l.close;if(m)try{m()}catch{}else try{l.writable.close()}catch{}}}},k=null,H=new Set,Q=0,M=[],F=0,K=m=>{if(!(m.byteLength===0||W>0)){if(F+m.byteLength>cn){R(1009,__sfx("5pyq56Gu6K6k6YCa6Lev55qE5LiK6KGM5pWw5o2u6L+H5aSa"));return}if(Se+m.byteLength>Dr){R(1009,__sfx("5a6e5L6L5YaF5a2Y6aKE566X5bey5ruh77yM6K+36YeN6K+V"));return}M.push(m),F+=m.byteLength,Se+=m.byteLength}},fe=()=>{Se=Math.max(0,Se-F),M=[],F=0},y=0,C=()=>{y+=1},v=async()=>{if(!l)return;let m=++y,A=l.readable.getReader();h=A,k&&clearTimeout(k);let P=setTimeout(()=>{k===P&&(k=null),!(W>0)&&F!==0&&($(`${x.hostname}:${x.port}`,[],__sfx("55u06L+eIA==")+an+__sfx("bXMg5peg5LiL6KGM5pWw5o2u77yM5pS56LWw5Y+N5Luj5YWl5Y+j")),Mn())},an);k=P;try{for(;;){let{done:L,value:I}=await A.read();if(L)break;if(I&&I.byteLength>0){let U=W===0;if(W+=I.byteLength,U&&fe(),ne.add(I.byteLength)){pe();return}b(I)}}}catch{}finally{try{A.releaseLock()}catch{}clearTimeout(P),k===P&&(k=null),h===A&&(h=null),m===y&&!g&&R(1e3,"done")}},W=0,ne=new _((n.dataBudgetMB||0)*1024*1024),pe=()=>{let m=__sfx("5Y2V6L+e5o6l5rWB6YeP6LaF6L+HIA==")+n.dataBudgetMB+__sfx("TUIg5LiK6ZmQ");$(x?`${x.hostname}:${x.port}`:__sfx("5pyq5bu656uL5Ye656uZ"),[],m),R(1009,m)},Oe=async m=>{if(u)try{await u.write(m)}catch{X()}},kn=async()=>{if(!u||c.byteLength===0)return;let m=c;c=new Uint8Array(0),K(m),await Oe(m)},gt=m=>{if(t===__sfx("dmxlc3M=")){let P=Tt(m,n.uuid);return P?{command:P.header.command,port:P.header.port,hostname:P.header.hostname,headerLength:P.consumed}:null}let A=Lt(m,n[__sfx("dHJvamFuUGFzc3dvcmQ=")]);return A?{command:A.header.command,port:A.header.port,hostname:A.header.hostname,headerLength:A.consumed}:null},On=()=>{d&&(clearTimeout(d),d=null)},Nn=async()=>{if(!(g||f)){if(gt(c)){await Ne();return}R(1008,c.byteLength===0?__sfx("5o+h5omL6LaF5pe277ya5pyq5pS25Yiw5Y2P6K6u5aS0"):__sfx("5o+h5omL6LaF5pe277ya5Y2P6K6u5aS05LiN5a6M5pW05oiW6K6k6K+B5aSx6LSl"))}},Ne=async()=>{if(g||f)return;let m=gt(c);if(!m){c.byteLength>0&&!d&&(d=setTimeout(()=>{d=null,Nn().catch(U=>R(1011,String(U)))},Ir));return}if(On(),f)return;f=!0,x=m;let A=t===__sfx("dmxlc3M=")?Pt:Ut;if(m.command===A){if(t===__sfx("dmxlc3M=")&&n.udpDns==="doh"&&m.port===53){S(new Uint8Array(0)),p=new be({endpoint:n.udpDnsEndpoint,send:b});let U=c.subarray(m.headerLength);U.byteLength>0&&p.push(U);return}R(1002,n.udpDns==="doh"?__sfx("VURQIOS7heaUr+aMgSBETlPvvIg1MyDnq6/lj6PvvIk="):__sfx("VURQIOacquWQr+eUqO+8iOmdouadv+WPr+W8gOWQryBETlMgb3ZlciBEb0jvvIk="));return}t===__sfx("dmxlc3M=")&&S(new Uint8Array(0));let P=[],L=null;try{l=await le({hostname:m.hostname,port:m.port,proxies:o,timeoutMs:sn,concurrent:n.concurrentDial,nat64:n.nat64||void 0,proxyMode:n.proxyMode,resolvePreferred:n.resolvePreferred,relayPool:{userEntries:n.relayPool||void 0,useBuiltin:n.useBuiltinRelay,colo:typeof e.cf?.colo=="string"?e.cf.colo:void 0},onFailure:U=>{P.push(U),s?.failures.push(U)}})}catch(U){L=U}if(!l){let U=P.length>0?P.map(de=>en(de)).join(`
|
|
5
|
-
`):__sfx("5Ye656uZ6L+e5o6l5aSx6LSl77ya")+String(L)+"";$(`${m.hostname}:${m.port}`,P,U),R(1011,U);return}u=l.writable.getWriter();let I=c.byteLength>m.headerLength?c.subarray(m.headerLength):new Uint8Array(0);I.byteLength>0&&(K(I),await Oe(I)),c=new Uint8Array(0),r?.waitUntil(v())},Mn=async()=>{let m=x;if(!m){R(1011,__sfx("5Ye656uZ5peg5pWw5o2u77ya55uu5qCH5pyq6Kej5p6Q"));return}if(Q>=ln){R(1011,__sfx("5Ye656uZ5peg5pWw5o2u77ya55u06L+e5LiO5Y+N5Luj5YWl5Y+j5Z2H5peg5ZON5bqU"));return}Q++;let A=[];try{A=await se({userEntries:n.relayPool||void 0,useBuiltin:n.useBuiltinRelay,colo:typeof e.cf?.colo=="string"?e.cf.colo:void 0})}catch{A=[]}let P=A.filter(L=>!H.has(`${L.ip}:${L.port}`));if(P.length===0){R(1011,__sfx("5Ye656uZ5peg5pWw5o2u77ya5peg5Y+N5Luj5YWl5Y+j5Y+v55So"));return}for(let L of P.slice(0,ln)){if(H.add(`${L.ip}:${L.port}`),C(),l){let I=l;if(I.close)try{I.close()}catch{}}u=null,W=0;try{let I=await le({hostname:L.ip,port:L.port,timeoutMs:sn,resolvePreferred:!1});if(!I)continue;if(l=I,u=I.writable.getWriter(),M.length>0){let U=0;for(let me of M)U+=me.byteLength;let de=new Uint8Array(U),bt=0;for(let me of M)de.set(me,bt),bt+=me.byteLength;await u.write(de)}await kn(),$(`${m.hostname}:${m.port}`,[],__sfx("5bey5YiH5o2i5Y+N5Luj5YWl5Y+jIA==")+L.ip+":"+L.port+""),r?.waitUntil(v());return}catch(I){$(`${m.hostname}:${m.port}`,[],__sfx("5Y+N5Luj5YWl5Y+jIA==")+L.ip+":"+L.port+__sfx("IOWksei0pe+8mg==")+String(I)+"")}}R(1011,__sfx("5Ye656uZ5peg5pWw5o2u77ya5omA5pyJ5Y+N5Luj5YWl5Y+j5Z2H5aSx6LSl"))};a.addEventListener("message",m=>{(async()=>{let A=m.data,P=typeof A=="string"?new TextEncoder().encode(A):new Uint8Array(A);if(P.byteLength!==0){if(ne.add(P.byteLength)){pe();return}if(!f){if(c=je(c,P),c.byteLength>Rr){R(1009,__sfx("5o+h5omL5aS06LaF6L+HIDY0S0I="));return}await Ne();return}if(p){p.push(P);return}if(!u){if(c=je(c,P),c.byteLength>cn){R(1009,__sfx("5ouo5Y+35pyf6Ze05pWw5o2u6L+H5aSa"));return}return}K(P),await Oe(P)}})()});let yt=()=>{X()};a.addEventListener("close",yt),a.addEventListener("error",yt),c.byteLength>0&&Ne().catch(m=>R(1011,String(m)));try{return new Response(null,{status:101,[__sfx("d2ViU29ja2V0")]:i})}catch(m){return console.error(__sfx("W+iHqueglOaVsOaNrumdol0gMTAxIOWTjeW6lOaehOmAoOWksei0pe+8mg=="),m),new Response(null,{status:200})}}var sn,an,ln,Rr,cn,Dr,Se,Ce,un,Ir,it=E(()=>{"use strict";We();kt();Ot();oe();st();Pe();$e();ie();sn=5e3,an=2500,ln=2,Rr=64*1024,cn=8*1024*1024,Dr=32*1024*1024,Se=0;Ce=[],un=20;Ir=2e3});var dn={};he(dn,{[__sfx("aGFuZGxlWGh0dHA=")]:()=>at,[__sfx("cmVjZW50WGh0dHBEaWFnbm9zdGljcw==")]:()=>Or,[__sfx("cmVjb3JkWGh0dHBEaWFnbm9zdGljcw==")]:()=>De});function kr(e,t){return new Promise(n=>{let o=setTimeout(()=>n(null),t);e.then(r=>{clearTimeout(o),n(r)},()=>{clearTimeout(o),n(null)})})}function De(e,t,n){Re.unshift({at:Date.now(),target:e,...t,summary:n}),Re.length>20&&(Re.length=20)}function Or(){return Re}async function at(e,t,n){let o=e.body;if(!o)return new Response(__sfx("57y65bCR6K+35rGC5L2T"),{status:400});let r=new G(o),s=await kr(Ct(r,t.uuid),Lr);if(!s)return await r.cancel("header timeout"),new Response(__sfx("VkxFU1Mg5aS06Kej5p6Q5aSx6LSl"),{status:400});if(s.header.command!==Et)return await s.payload.cancel("unsupported UDP"),new Response(__sfx("WEhUVFAg5pqC5LiN5pSv5oyBIFVEUA=="),{status:400});let i;try{i=await le({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=>{De(`${s.header.hostname}:${s.header.port}`,p,__sfx("WEhUVFAg5Ye656uZ5aSx6LSl77yI")+p.candidate+"):"+p.message+"")}})}catch(p){De(`${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 c=new Uint8Array(2+a.byteLength);c[0]=s.header.version,c[1]=a.byteLength,c.set(a,2);let f=!1,l=null,u=!1,d=new _((t.dataBudgetMB||0)*1024*1024),h=null,g=()=>{if(u)return;u=!0;let p=__sfx("5Y2V6L+e5o6l5rWB6YeP6LaF6L+HIA==")+t.dataBudgetMB+__sfx("TUIg5LiK6ZmQ");if(De(`${s.header.hostname}:${s.header.port}`,{kind:"budget",message:p,candidate:"traffic"},p),i.close)try{i.close()}catch{}try{h?.close()}catch{}},T=p=>d.add(p)?(g(),!0):!1;on(s.payload,i.writable,void 0,!1,T).catch(()=>{});let x=new ReadableStream({start(p){h=p,p.enqueue(c),f=!0},async pull(p){if(!(u||!f)){l||(l=i.readable.getReader());try{let{done:b,value:S}=await l.read();if(u)return;if(b){if(i.close)try{i.close()}catch{}p.close();return}if(S&&S.byteLength>0){if(d.add(S.byteLength)){g();return}p.enqueue(S)}}catch(b){if(u)return;if(i.close)try{i.close()}catch{}try{p.error(b)}catch{}}}},cancel(p){u=!0;try{i.readable.cancel(p)}catch{}if(i.close)try{i.close()}catch{}}});return new Response(x,{status:200,headers:{"Content-Type":"text/event-stream","Cache-Control":"no-store","X-Accel-Buffering":"no"}})}var Lr,Re,lt=E(()=>{"use strict";oe();We();Pe();st();Lr=2e3;Re=[]});function Ie(){return new Response(JSON.stringify({build:ct,version:Nr,ts:Date.now()}),{status:200,headers:{"Content-Type":"application/json","Cache-Control":"no-store","Access-Control-Allow-Origin":"*"}})}var ct,Nr,ve,ut=E(()=>{"use strict";ct="6cf3fc8-2d5c8203",Nr=__sfx("MC4xMi41"),ve=__sfx("L19fY2ZwX3ZlcnNpb24=")});function mn(e){return e[__sfx("S1Y=")]?new ee(e[__sfx("S1Y=")]):new ft}var ee,ft,Ue=E(()=>{"use strict";ee=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}},ft=class{data=new Map;async get(t){let n=this.data.get(t);return n?n.expiresAt>0&&n.expiresAt<=Date.now()?(this.data.delete(t),null):n.value:null}async put(t,n,o){let r=o?Date.now()+o*1e3:0;this.data.set(t,{value:n,expiresAt:r})}async delete(t){this.data.delete(t)}async list(t){return[...this.data.keys()].filter(n=>n.startsWith(t))}}});function q(e,t){if(e==null)return t;let n=String(e).trim();if(n==="")return t;let o=Number(n);return Number.isFinite(o)?o:t}function N(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 Mr(e){let t=e.trim().toLowerCase();return t==="global"||t==="fallback"||t==="smart"?t:"only"}function gn(e){return e.trim().toLowerCase()==="signed"?"signed":"legacy"}function yn(e){return e.trim().toLowerCase()==="doh"?"doh":"off"}function D(e,t){return e==null?t:String(e)}function Fr(e){return{uuid:D(e[__sfx("VVVJRA==")],""),[__sfx("dHJvamFuUGFzc3dvcmQ=")]:D(e[__sfx("VFJPSkFOX1BBU1NXT1JE")],""),wsPath:D(e[__sfx("V1NfUEFUSA==")]||e[__sfx("UEFUSA==")],w.wsPath),[__sfx("dHJvamFuUGF0aA==")]:w[__sfx("dHJvamFuUGF0aA==")],[__sfx("eGh0dHBQYXRo")]:w[__sfx("eGh0dHBQYXRo")],add:D(e[__sfx("QURE")],""),addApi:D(e[__sfx("QUREQVBJ")],""),addCsv:D(e[__sfx("QUREX0NTVg==")],""),poolOfficial:N(e[__sfx("T0ZGSUNJQUxfSVA=")],w.poolOfficial),officialCount:q(e[__sfx("T0ZGSUNJQUxfSVBfQ09VTlQ=")],w.officialCount),poolDomain:N(e[__sfx("UFJFRkVSUkVEX0RPTUFJTg==")],w.poolDomain),domainCount:q(e[__sfx("UFJFRkVSUkVEX0RPTUFJTl9DT1VOVA==")],w.domainCount),poolManual:N(e[__sfx("TUFOVUFMX0lQ")],w.poolManual),poolCountries:D(e[__sfx("UE9PTF9DT1VOVFJJRVM=")],w.poolCountries),dls:q(e[__sfx("RExT")],0),maxLatency:q(e[__sfx("TUFYX0xBVEVOQ1k=")],0),maxNodes:0,[__sfx("cHJveHlJcA==")]:D(e[__sfx("UFJPWFlJUA==")],""),[__sfx("c29ja3M1")]:D(e[__sfx("U09DS1M1")],""),httpProxy:D(e[__sfx("SFRUUF9QUk9YWQ==")],""),proxyMode:Mr(D(e[__sfx("UFJPWFlfTU9ERQ==")],"")),nat64:D(e[__sfx("TkFUNjQ=")],""),concurrentDial:N(e[__sfx("VENQX0NPTkNVUlJFTlRfRElBTA==")],!0),dataBudgetMB:q(e[__sfx("REFUQV9CVURHRVRfTUI=")],w.dataBudgetMB),resolvePreferred:N(e[__sfx("UkVTT0xWRV9QUkVGRVJSRUQ=")],w.resolvePreferred),relayPool:D(e[__sfx("UkVMQVlfUE9PTA==")],""),useBuiltinRelay:N(e[__sfx("VVNFX0JVSUxUSU5fUkVMQVk=")],w.useBuiltinRelay),[__sfx("ZW5hYmxlVHJvamFu")]:N(e[__sfx("RU5BQkxFX1RST0pBTg==")]??e[__sfx("VFJPSkFO")],w[__sfx("ZW5hYmxlVHJvamFu")]),[__sfx("ZW5hYmxlWGh0dHA=")]:N(e[__sfx("RU5BQkxFX1hIVFRQ")]??e[__sfx("WEhUVFA=")],w[__sfx("ZW5hYmxlWGh0dHA=")]),subDomain:"",subProtocol:"both",subTransport:"both",subVariants:D(e[__sfx("U1VCX1ZBUklBTlRT")],w.subVariants),subName:D(e[__sfx("U1VCX05BTUU=")],w.subName).trim()||w.subName,subPorts:D(e[__sfx("U1VCX1BPUlRT")],w.subPorts),clientFingerprint:w.clientFingerprint,ech:N(e[__sfx("RUNI")],w.ech),echHost:D(e[__sfx("RUNIX0hPU1Q=")],w.echHost),echDns:D(e[__sfx("RUNIX0ROUw==")],w.echDns),tlsFragment:!1,tlsFragmentSize:w.tlsFragmentSize,tlsFragmentDelay:w.tlsFragmentDelay,subToken:gn(D(e[__sfx("U1VCX1RPS0VOX01PREU=")],"")),subTokenTtlDays:q(e[__sfx("U1VCX1RPS0VOX1RUTF9EQVlT")],w.subTokenTtlDays),unlockProbe:N(e[__sfx("VU5MT0NLX1BST0JF")],w.unlockProbe),udpDns:yn(D(e[__sfx("VURQX0ROUw==")],"")),udpDnsEndpoint:D(e[__sfx("VURQX0ROU19FTkRQT0lOVA==")],w.udpDnsEndpoint)}}function Br(e,t){let n={...e};for(let[o,r]of Object.entries(t))if(r!=null)if(o==="dls"||o==="maxLatency"||o==="maxNodes"||o==="officialCount"||o==="domainCount"||o==="dataBudgetMB"||o==="subTokenTtlDays")n[o]=q(r,0);else if(o==="concurrentDial"||o==="resolvePreferred"||o==="useBuiltinRelay"||o===__sfx("ZW5hYmxlVHJvamFu")||o===__sfx("ZW5hYmxlWGh0dHA=")||o==="tlsFragment"||o==="ech"||o==="poolOfficial"||o==="poolDomain"||o==="poolManual"||o==="unlockProbe")n[o]=N(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]=gn(String(r)):o==="udpDns"?n[o]=yn(String(r)):n[o]=String(r);return n}async function bn(e,t){let n=Fr(t),o=await e.get(hn),r={};if(o)try{r=JSON.parse(o)}catch{r={}}let s=Br(n,r),i=!1,a=e instanceof ee;return!s.uuid&&a&&(s.uuid=Me(),i=!0),!s[__sfx("dHJvamFuUGFzc3dvcmQ=")]&&a&&(s[__sfx("dHJvamFuUGFzc3dvcmQ=")]=Me().replace(/-/g,"").slice(0,16),i=!0),s.officialCount<1&&(s.officialCount=w.officialCount,i=!0),s.domainCount<1&&(s.domainCount=w.domainCount,i=!0),i&&await Hr(e,s),s}async function Hr(e,t){await e.put(hn,JSON.stringify(t))}var hn,w,Le=E(()=>{"use strict";z();Ue();hn="CONFIG",w={uuid:"",[__sfx("dHJvamFuUGFzc3dvcmQ=")]:"",wsPath:__sfx("L3ZsZXNz"),[__sfx("dHJvamFuUGF0aA==")]:__sfx("L3Ryb2phbg=="),[__sfx("eGh0dHBQYXRo")]:__sfx("L3hodHRw"),add:"",addApi:"",addCsv:"",poolOfficial:!0,officialCount:20,poolDomain:!0,domainCount:10,poolManual:!0,poolCountries:"",dls:0,maxLatency:0,maxNodes:0,[__sfx("cHJveHlJcA==")]:"",[__sfx("c29ja3M1")]:"",httpProxy:"",proxyMode:"only",nat64:"",concurrentDial:!0,dataBudgetMB:0,resolvePreferred:!0,relayPool:"",useBuiltinRelay:!0,[__sfx("ZW5hYmxlVHJvamFu")]:!0,[__sfx("ZW5hYmxlWGh0dHA=")]:!0,subDomain:"",subProtocol:__sfx("dmxlc3M="),subTransport:"ws",subVariants:__sfx("dmxlc3Mtd3M="),subName:__sfx("Q0ZQaWxvdA=="),subPorts:"443",clientFingerprint:"chrome",ech:!1,echHost:__sfx("Y2xvdWRmbGFyZS1lY2guY29t"),echDns:"",tlsFragment:!1,tlsFragmentSize:"10-20",tlsFragmentDelay:"10-20",subToken:"legacy",subTokenTtlDays:0,unlockProbe:!1,udpDns:"off",udpDnsEndpoint:"https://dns.google/dns-query"}});var wn,Kr,Zo,Wr,_o,xn=E(()=>{"use strict";wn={[__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"]},Kr=__sfx("SEtH6aaZ5rivLFRQReWPsOWMlyxOUlTkuJzkuqwsS0lY5aSn6ZiqLElDTummluWwlCxTSU7mlrDliqDlnaEsS1VM5ZCJ6ZqG5Z2hLEJLS+abvOiwtyxTR07og6Hlv5fmmI7luIIsTU5M6ams5bC85ouJLFNZROaCieWwvCxNRUzloqjlsJTmnKwsTEFY5rSb5p2J55+2LFNKQ+Wco+S9leWhnixTRUHopb/pm4Xlm74sT1JE6Iqd5Yqg5ZOlLElBROWNjuebm+mhvyxFV1Lnur3nk6blhYssWVla5aSa5Lym5aSaLFlWUua4qeWTpeWNjixMSFLkvKbmlaYsRlJB5rOV5YWw5YWL56aPLENER+W3tOm7jixBTVPpmL/lp4bmlq/nibnkuLksTUFE6ams5b636YeMLEFSTuaWr+W+t+WTpeWwlOaRqSxJU1TkvIrmlq/lnabluIPlsJQsRFhC6L+q5ouc"),Zo=(()=>{let e={};for(let t of Kr.split(","))t.length>3&&(e[t.slice(0,3)]=t.slice(3));return e})(),Wr=new Map;for(let[e,t]of Object.entries(wn))for(let n of t)Wr.set(n,e);_o=Object.keys(wn)});var An=E(()=>{"use strict"});var ms,En=E(()=>{"use strict";j();z();xn();An();ms=".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 bs,Pn=E(()=>{"use strict";Ue();z();bs=new TextEncoder});var Ns,Sn=E(()=>{"use strict";Le();z();Ns=3600*24});function Cn(e){return mn(e)}async function Tn(e,t){if(ce.config&&Date.now()-ce.configAt<zr)return ce.config;let n=await bn(e,t);return ce.config=n,ce.configAt=Date.now(),n}var zr,ce,dt=E(()=>{"use strict";Ue();Le();Sn();zr=15e3,ce={config:null,configAt:0,auth:null,authAt:0}});var Dn={};he(Dn,{clearUnlockCache:()=>Zr,runUnlockProbe:()=>Jr});function qr(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 Qr(e){let t=Date.now(),n=new AbortController,o=setTimeout(()=>n.abort(),Xr);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:qr(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 Jr(e,t){let n=e||"UNK",o=Date.now(),r=te.get(n);if(r&&o-r.at<Yr)return{...r.data,cached:!0};let s=await Promise.all(Gr.map(a=>Qr(a))),i={colo:n,region:t,cached:!1,at:o,targets:s};if(te.size>=Vr){let a="",c=Number[__sfx("UE9TSVRJVkVfSU5GSU5JVFk=")];for(let[f,l]of te)l.at<c&&(c=l.at,a=f);a&&te.delete(a)}return te.set(n,{at:o,data:i}),i}function Zr(){te.clear()}var Gr,Xr,Yr,Vr,te,vn=E(()=>{"use strict";Gr=[{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"}],Xr=4e3,Yr=600*1e3,Vr=16,te=new Map});z();var Bn=8*1024*1024,Hn=2*1024*1024,xt=600*1e3,Kn=6*1024*1024*1024,Fe=Date.now(),Be=0;function At(e){e-Fe>=xt&&(Fe=e,Be=0)}function Wn(e,t=Date.now()){At(t),Be+=e}function wt(e){return At(e),Kn-Be}var zn=(()=>{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})(),jn=5e3;function Gn(e,t=jn){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 He(e){let t=new URL(e.url);if(e.headers.get("Upgrade")?.toLowerCase()===__sfx("d2Vic29ja2V0")){let f=new WebSocketPair,[l,u]=Object.values(f);u.accept();let d=Gn((h,g)=>u.close(h,g));return u.addEventListener("message",h=>{let g=typeof h.data=="string"?h.data:"";if(g==="PING"||g==="ping"){d.cancel(),u.send(JSON.stringify({pong:!0,colo:e.cf?.colo??"UNK",clientIp:e.headers.get("CF-Connecting-IP")??""}));try{u.close(1e3,"Probe complete")}catch{}return}d.cancel();try{u.close(1e3,"Probe aborted")}catch{}}),u.addEventListener("close",()=>d.cancel()),u.addEventListener("error",()=>d.cancel()),new Response(null,{status:101,[__sfx("d2ViU29ja2V0")]:l})}let o=Number.parseInt(t.searchParams.get("bytes")??"",10),r=Number.isFinite(o)&&o>0?Math.min(o,Bn):Hn,s=Date.now();if(wt(s)<=0){let f=Math.max(1e3,Fe+xt-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=zn,a=0,c=new ReadableStream({pull(f){let l=wt(Date.now());if(a>=r||l<=0){f.close();return}let u=Math.min(i.byteLength,r-a,l);f.enqueue(i.subarray(0,u)),a+=u,Wn(u)}});return new Response(c,{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":ye(4)}})}it();lt();et();ut();z();Le();Pe();En();Pn();z();function pt(e){let t=e===200?"Welcome":e===404?"Not Found":"Service Unavailable",n=`<!DOCTYPE html><html lang="zh-CN"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>${t}</title><style>body{margin:0;min-height:100vh;display:flex;align-items:center;justify-content:center;background:#f7f8fa;color:#333;font-family:-apple-system,"Segoe UI","PingFang SC",sans-serif}.c{text-align:center}h1{font-size:22px;font-weight:600;margin:0 0 10px}p{color:#888;font-size:14px;margin:0}</style></head><body><div class="c"><h1>${t}</h1><p>This site is up and running.</p></div></body></html>`;return new Response(n,{status:e,headers:{"Content-Type":"text/html; charset=utf-8","Cache-Control":"no-store","X-Content-Type-Options":"nosniff"}})}dt();dt();async function Rn(e){let t=Cn(e);return await Tn(t,e)}function mt(e){let t=[];return t.push(...ae(e[__sfx("cHJveHlJcA==")],"direct")),t.push(...ae(e[__sfx("c29ja3M1")],__sfx("c29ja3M1"))),t.push(...ae(e.httpProxy,"http")),t}var ht=6e4,_r=10,ue=0,ke=0;function In(e){return e>=ke?(ue=0,ke=e+ht,!1):ue>=_r}function Un(e,t,n){if(!n)return!1;let o=(e.headers.get(__sfx("eC1jZnBpbG90LXRva2Vu"))??t.searchParams.get("token")??"").trim();if(!o)return!1;let r=Date.now();return re(o,n)?(ue=0,!0):(r>=ke&&(ke=r+ht,ue=0),ue+=1,!1)}async function Ln(e,t,n){let o=new URL(e.url);if(o.pathname===__sfx("L19fZWRnZV9wcm9iZQ=="))return He(e);if(o.pathname===ve||o.pathname===__sfx("L19fdmVyc2lvbg=="))return Ie();if(o.pathname==="/region"&&e.method==="GET"){let{coloToCountry:i,rankRegions:a}=await Promise.resolve().then(()=>(ie(),_e)),c=e.cf?.colo??"",f=c?i(c):"";return new Response(JSON.stringify({ok:!0,colo:c,region:f,relayPreference:f?a(f):[],timestamp:new Date().toISOString()},null,2),{status:200,headers:{"Content-Type":"application/json; charset=utf-8"}})}let r=await Rn(t);if(o.pathname===__sfx("L19fZGlhZw==")){if(In(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(ht/1e3))}});if(!Un(e,o,r.uuid))return null;let{recentDiagnostics:i}=await Promise.resolve().then(()=>(it(),pn)),{[__sfx("cmVjZW50WGh0dHBEaWFnbm9zdGljcw==")]:a}=await Promise.resolve().then(()=>(lt(),dn));return new Response(JSON.stringify({ok:!0,impl:"self",build:ct,recent:i(),[__sfx("eGh0dHA=")]:a()},null,2),{status:200,headers:{"Content-Type":"application/json; charset=utf-8","Cache-Control":"no-store"}})}if(o.pathname==="/__unlock_probe"){if(!r.unlockProbe)return null;if(In(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(!Un(e,o,r.uuid))return null;let{coloToCountry:i}=await Promise.resolve().then(()=>(ie(),_e)),{runUnlockProbe:a}=await Promise.resolve().then(()=>(vn(),Dn)),c=e.cf?.colo??"",f=c?i(c):"",l=await a(c,f);return new Response(JSON.stringify({ok:!0,...l},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 Te(e,__sfx("dmxlc3M="),r,mt(r),n):r[__sfx("ZW5hYmxlVHJvamFu")]&&o.pathname===r[__sfx("dHJvamFuUGF0aA==")]?s!==__sfx("d2Vic29ja2V0")?null:await Te(e,__sfx("dHJvamFu"),r,mt(r),n):r[__sfx("ZW5hYmxlWGh0dHA=")]&&o.pathname===r[__sfx("eGh0dHBQYXRo")]?e.method!=="POST"?null:await at(e,r,mt(r)):null}ut();var Ri={async fetch(e,t,n){try{return new URL(e.url).pathname===ve?Ie():await Ln(e,t,n)??pt(200)}catch{return pt(500)}}};export{Ri as default};
|
|
5
|
+
`):__sfx("5Ye656uZ6L+e5o6l5aSx6LSl77ya")+String(L)+"";$(`${m.hostname}:${m.port}`,P,U),R(1011,U);return}u=l.writable.getWriter();let I=c.byteLength>m.headerLength?c.subarray(m.headerLength):new Uint8Array(0);I.byteLength>0&&(K(I),await Oe(I)),c=new Uint8Array(0),r?.waitUntil(v())},Mn=async()=>{let m=x;if(!m){R(1011,__sfx("5Ye656uZ5peg5pWw5o2u77ya55uu5qCH5pyq6Kej5p6Q"));return}if(Q>=ln){R(1011,__sfx("5Ye656uZ5peg5pWw5o2u77ya55u06L+e5LiO5Y+N5Luj5YWl5Y+j5Z2H5peg5ZON5bqU"));return}Q++;let A=[];try{A=await se({userEntries:n.relayPool||void 0,useBuiltin:n.useBuiltinRelay,colo:typeof e.cf?.colo=="string"?e.cf.colo:void 0})}catch{A=[]}let P=A.filter(L=>!H.has(`${L.ip}:${L.port}`));if(P.length===0){R(1011,__sfx("5Ye656uZ5peg5pWw5o2u77ya5peg5Y+N5Luj5YWl5Y+j5Y+v55So"));return}for(let L of P.slice(0,ln)){if(H.add(`${L.ip}:${L.port}`),C(),l){let I=l;if(I.close)try{I.close()}catch{}}u=null,W=0;try{let I=await le({hostname:L.ip,port:L.port,timeoutMs:sn,resolvePreferred:!1});if(!I)continue;if(l=I,u=I.writable.getWriter(),M.length>0){let U=0;for(let me of M)U+=me.byteLength;let de=new Uint8Array(U),bt=0;for(let me of M)de.set(me,bt),bt+=me.byteLength;await u.write(de)}await kn(),$(`${m.hostname}:${m.port}`,[],__sfx("5bey5YiH5o2i5Y+N5Luj5YWl5Y+jIA==")+L.ip+":"+L.port+""),r?.waitUntil(v());return}catch(I){$(`${m.hostname}:${m.port}`,[],__sfx("5Y+N5Luj5YWl5Y+jIA==")+L.ip+":"+L.port+__sfx("IOWksei0pe+8mg==")+String(I)+"")}}R(1011,__sfx("5Ye656uZ5peg5pWw5o2u77ya5omA5pyJ5Y+N5Luj5YWl5Y+j5Z2H5aSx6LSl"))};a.addEventListener("message",m=>{(async()=>{let A=m.data,P=typeof A=="string"?new TextEncoder().encode(A):new Uint8Array(A);if(P.byteLength!==0){if(ne.add(P.byteLength)){pe();return}if(!f){if(c=je(c,P),c.byteLength>Rr){R(1009,__sfx("5o+h5omL5aS06LaF6L+HIDY0S0I="));return}await Ne();return}if(p){p.push(P);return}if(!u){if(c=je(c,P),c.byteLength>cn){R(1009,__sfx("5ouo5Y+35pyf6Ze05pWw5o2u6L+H5aSa"));return}return}K(P),await Oe(P)}})()});let yt=()=>{X()};a.addEventListener("close",yt),a.addEventListener("error",yt),c.byteLength>0&&Ne().catch(m=>R(1011,String(m)));try{return new Response(null,{status:101,[__sfx("d2ViU29ja2V0")]:i})}catch(m){return console.error(__sfx("W+iHqueglOaVsOaNrumdol0gMTAxIOWTjeW6lOaehOmAoOWksei0pe+8mg=="),m),new Response(null,{status:200})}}var sn,an,ln,Rr,cn,Dr,Se,Ce,un,Ir,it=E(()=>{"use strict";We();kt();Ot();oe();st();Pe();$e();ie();sn=5e3,an=2500,ln=2,Rr=64*1024,cn=8*1024*1024,Dr=32*1024*1024,Se=0;Ce=[],un=20;Ir=2e3});var dn={};he(dn,{[__sfx("aGFuZGxlWGh0dHA=")]:()=>at,[__sfx("cmVjZW50WGh0dHBEaWFnbm9zdGljcw==")]:()=>Or,[__sfx("cmVjb3JkWGh0dHBEaWFnbm9zdGljcw==")]:()=>De});function kr(e,t){return new Promise(n=>{let o=setTimeout(()=>n(null),t);e.then(r=>{clearTimeout(o),n(r)},()=>{clearTimeout(o),n(null)})})}function De(e,t,n){Re.unshift({at:Date.now(),target:e,...t,summary:n}),Re.length>20&&(Re.length=20)}function Or(){return Re}async function at(e,t,n){let o=e.body;if(!o)return new Response(__sfx("57y65bCR6K+35rGC5L2T"),{status:400});let r=new G(o),s=await kr(Ct(r,t.uuid),Lr);if(!s)return await r.cancel("header timeout"),new Response(__sfx("VkxFU1Mg5aS06Kej5p6Q5aSx6LSl"),{status:400});if(s.header.command!==Et)return await s.payload.cancel("unsupported UDP"),new Response(__sfx("WEhUVFAg5pqC5LiN5pSv5oyBIFVEUA=="),{status:400});let i;try{i=await le({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=>{De(`${s.header.hostname}:${s.header.port}`,p,__sfx("WEhUVFAg5Ye656uZ5aSx6LSl77yI")+p.candidate+"):"+p.message+"")}})}catch(p){De(`${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 c=new Uint8Array(2+a.byteLength);c[0]=s.header.version,c[1]=a.byteLength,c.set(a,2);let f=!1,l=null,u=!1,d=new _((t.dataBudgetMB||0)*1024*1024),h=null,g=()=>{if(u)return;u=!0;let p=__sfx("5Y2V6L+e5o6l5rWB6YeP6LaF6L+HIA==")+t.dataBudgetMB+__sfx("TUIg5LiK6ZmQ");if(De(`${s.header.hostname}:${s.header.port}`,{kind:"budget",message:p,candidate:"traffic"},p),i.close)try{i.close()}catch{}try{h?.close()}catch{}},T=p=>d.add(p)?(g(),!0):!1;on(s.payload,i.writable,void 0,!1,T).catch(()=>{});let x=new ReadableStream({start(p){h=p,p.enqueue(c),f=!0},async pull(p){if(!(u||!f)){l||(l=i.readable.getReader());try{let{done:b,value:S}=await l.read();if(u)return;if(b){if(i.close)try{i.close()}catch{}p.close();return}if(S&&S.byteLength>0){if(d.add(S.byteLength)){g();return}p.enqueue(S)}}catch(b){if(u)return;if(i.close)try{i.close()}catch{}try{p.error(b)}catch{}}}},cancel(p){u=!0;try{i.readable.cancel(p)}catch{}if(i.close)try{i.close()}catch{}}});return new Response(x,{status:200,headers:{"Content-Type":"text/event-stream","Cache-Control":"no-store","X-Accel-Buffering":"no"}})}var Lr,Re,lt=E(()=>{"use strict";oe();We();Pe();st();Lr=2e3;Re=[]});function Ie(){return new Response(JSON.stringify({build:ct,version:Nr,ts:Date.now()}),{status:200,headers:{"Content-Type":"application/json","Cache-Control":"no-store","Access-Control-Allow-Origin":"*"}})}var ct,Nr,ve,ut=E(()=>{"use strict";ct="b109ac3-2d5c8203",Nr=__sfx("MC4xMi42"),ve=__sfx("L19fY2ZwX3ZlcnNpb24=")});function mn(e){return e[__sfx("S1Y=")]?new ee(e[__sfx("S1Y=")]):new ft}var ee,ft,Ue=E(()=>{"use strict";ee=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}},ft=class{data=new Map;async get(t){let n=this.data.get(t);return n?n.expiresAt>0&&n.expiresAt<=Date.now()?(this.data.delete(t),null):n.value:null}async put(t,n,o){let r=o?Date.now()+o*1e3:0;this.data.set(t,{value:n,expiresAt:r})}async delete(t){this.data.delete(t)}async list(t){return[...this.data.keys()].filter(n=>n.startsWith(t))}}});function q(e,t){if(e==null)return t;let n=String(e).trim();if(n==="")return t;let o=Number(n);return Number.isFinite(o)?o:t}function N(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 Mr(e){let t=e.trim().toLowerCase();return t==="global"||t==="fallback"||t==="smart"?t:"only"}function gn(e){return e.trim().toLowerCase()==="signed"?"signed":"legacy"}function yn(e){return e.trim().toLowerCase()==="doh"?"doh":"off"}function D(e,t){return e==null?t:String(e)}function Fr(e){return{uuid:D(e[__sfx("VVVJRA==")],""),[__sfx("dHJvamFuUGFzc3dvcmQ=")]:D(e[__sfx("VFJPSkFOX1BBU1NXT1JE")],""),wsPath:D(e[__sfx("V1NfUEFUSA==")]||e[__sfx("UEFUSA==")],w.wsPath),[__sfx("dHJvamFuUGF0aA==")]:w[__sfx("dHJvamFuUGF0aA==")],[__sfx("eGh0dHBQYXRo")]:w[__sfx("eGh0dHBQYXRo")],add:D(e[__sfx("QURE")],""),addApi:D(e[__sfx("QUREQVBJ")],""),addCsv:D(e[__sfx("QUREX0NTVg==")],""),poolOfficial:N(e[__sfx("T0ZGSUNJQUxfSVA=")],w.poolOfficial),officialCount:q(e[__sfx("T0ZGSUNJQUxfSVBfQ09VTlQ=")],w.officialCount),poolDomain:N(e[__sfx("UFJFRkVSUkVEX0RPTUFJTg==")],w.poolDomain),domainCount:q(e[__sfx("UFJFRkVSUkVEX0RPTUFJTl9DT1VOVA==")],w.domainCount),poolManual:N(e[__sfx("TUFOVUFMX0lQ")],w.poolManual),poolCountries:D(e[__sfx("UE9PTF9DT1VOVFJJRVM=")],w.poolCountries),dls:q(e[__sfx("RExT")],0),maxLatency:q(e[__sfx("TUFYX0xBVEVOQ1k=")],0),maxNodes:0,[__sfx("cHJveHlJcA==")]:D(e[__sfx("UFJPWFlJUA==")],""),[__sfx("c29ja3M1")]:D(e[__sfx("U09DS1M1")],""),httpProxy:D(e[__sfx("SFRUUF9QUk9YWQ==")],""),proxyMode:Mr(D(e[__sfx("UFJPWFlfTU9ERQ==")],"")),nat64:D(e[__sfx("TkFUNjQ=")],""),concurrentDial:N(e[__sfx("VENQX0NPTkNVUlJFTlRfRElBTA==")],!0),dataBudgetMB:q(e[__sfx("REFUQV9CVURHRVRfTUI=")],w.dataBudgetMB),resolvePreferred:N(e[__sfx("UkVTT0xWRV9QUkVGRVJSRUQ=")],w.resolvePreferred),relayPool:D(e[__sfx("UkVMQVlfUE9PTA==")],""),useBuiltinRelay:N(e[__sfx("VVNFX0JVSUxUSU5fUkVMQVk=")],w.useBuiltinRelay),[__sfx("ZW5hYmxlVHJvamFu")]:N(e[__sfx("RU5BQkxFX1RST0pBTg==")]??e[__sfx("VFJPSkFO")],w[__sfx("ZW5hYmxlVHJvamFu")]),[__sfx("ZW5hYmxlWGh0dHA=")]:N(e[__sfx("RU5BQkxFX1hIVFRQ")]??e[__sfx("WEhUVFA=")],w[__sfx("ZW5hYmxlWGh0dHA=")]),subDomain:"",subProtocol:"both",subTransport:"both",subVariants:D(e[__sfx("U1VCX1ZBUklBTlRT")],w.subVariants),subName:D(e[__sfx("U1VCX05BTUU=")],w.subName).trim()||w.subName,subPorts:D(e[__sfx("U1VCX1BPUlRT")],w.subPorts),clientFingerprint:w.clientFingerprint,ech:N(e[__sfx("RUNI")],w.ech),echHost:D(e[__sfx("RUNIX0hPU1Q=")],w.echHost),echDns:D(e[__sfx("RUNIX0ROUw==")],w.echDns),tlsFragment:!1,tlsFragmentSize:w.tlsFragmentSize,tlsFragmentDelay:w.tlsFragmentDelay,subToken:gn(D(e[__sfx("U1VCX1RPS0VOX01PREU=")],"")),subTokenTtlDays:q(e[__sfx("U1VCX1RPS0VOX1RUTF9EQVlT")],w.subTokenTtlDays),unlockProbe:N(e[__sfx("VU5MT0NLX1BST0JF")],w.unlockProbe),udpDns:yn(D(e[__sfx("VURQX0ROUw==")],"")),udpDnsEndpoint:D(e[__sfx("VURQX0ROU19FTkRQT0lOVA==")],w.udpDnsEndpoint)}}function Br(e,t){let n={...e};for(let[o,r]of Object.entries(t))if(r!=null)if(o==="dls"||o==="maxLatency"||o==="maxNodes"||o==="officialCount"||o==="domainCount"||o==="dataBudgetMB"||o==="subTokenTtlDays")n[o]=q(r,0);else if(o==="concurrentDial"||o==="resolvePreferred"||o==="useBuiltinRelay"||o===__sfx("ZW5hYmxlVHJvamFu")||o===__sfx("ZW5hYmxlWGh0dHA=")||o==="tlsFragment"||o==="ech"||o==="poolOfficial"||o==="poolDomain"||o==="poolManual"||o==="unlockProbe")n[o]=N(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]=gn(String(r)):o==="udpDns"?n[o]=yn(String(r)):n[o]=String(r);return n}async function bn(e,t){let n=Fr(t),o=await e.get(hn),r={};if(o)try{r=JSON.parse(o)}catch{r={}}let s=Br(n,r),i=!1,a=e instanceof ee;return!s.uuid&&a&&(s.uuid=Me(),i=!0),!s[__sfx("dHJvamFuUGFzc3dvcmQ=")]&&a&&(s[__sfx("dHJvamFuUGFzc3dvcmQ=")]=Me().replace(/-/g,"").slice(0,16),i=!0),s.officialCount<1&&(s.officialCount=w.officialCount,i=!0),s.domainCount<1&&(s.domainCount=w.domainCount,i=!0),i&&await Hr(e,s),s}async function Hr(e,t){await e.put(hn,JSON.stringify(t))}var hn,w,Le=E(()=>{"use strict";z();Ue();hn="CONFIG",w={uuid:"",[__sfx("dHJvamFuUGFzc3dvcmQ=")]:"",wsPath:__sfx("L3ZsZXNz"),[__sfx("dHJvamFuUGF0aA==")]:__sfx("L3Ryb2phbg=="),[__sfx("eGh0dHBQYXRo")]:__sfx("L3hodHRw"),add:"",addApi:"",addCsv:"",poolOfficial:!0,officialCount:20,poolDomain:!0,domainCount:10,poolManual:!0,poolCountries:"",dls:0,maxLatency:0,maxNodes:0,[__sfx("cHJveHlJcA==")]:"",[__sfx("c29ja3M1")]:"",httpProxy:"",proxyMode:"only",nat64:"",concurrentDial:!0,dataBudgetMB:0,resolvePreferred:!0,relayPool:"",useBuiltinRelay:!0,[__sfx("ZW5hYmxlVHJvamFu")]:!0,[__sfx("ZW5hYmxlWGh0dHA=")]:!0,subDomain:"",subProtocol:__sfx("dmxlc3M="),subTransport:"ws",subVariants:__sfx("dmxlc3Mtd3M="),subName:__sfx("Q0ZQaWxvdA=="),subPorts:"443",clientFingerprint:"chrome",ech:!1,echHost:__sfx("Y2xvdWRmbGFyZS1lY2guY29t"),echDns:"",tlsFragment:!1,tlsFragmentSize:"10-20",tlsFragmentDelay:"10-20",subToken:"legacy",subTokenTtlDays:0,unlockProbe:!1,udpDns:"off",udpDnsEndpoint:"https://dns.google/dns-query"}});var wn,Kr,Zo,Wr,_o,xn=E(()=>{"use strict";wn={[__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"]},Kr=__sfx("SEtH6aaZ5rivLFRQReWPsOWMlyxOUlTkuJzkuqwsS0lY5aSn6ZiqLElDTummluWwlCxTSU7mlrDliqDlnaEsS1VM5ZCJ6ZqG5Z2hLEJLS+abvOiwtyxTR07og6Hlv5fmmI7luIIsTU5M6ams5bC85ouJLFNZROaCieWwvCxNRUzloqjlsJTmnKwsTEFY5rSb5p2J55+2LFNKQ+Wco+S9leWhnixTRUHopb/pm4Xlm74sT1JE6Iqd5Yqg5ZOlLElBROWNjuebm+mhvyxFV1Lnur3nk6blhYssWVla5aSa5Lym5aSaLFlWUua4qeWTpeWNjixMSFLkvKbmlaYsRlJB5rOV5YWw5YWL56aPLENER+W3tOm7jixBTVPpmL/lp4bmlq/nibnkuLksTUFE6ams5b636YeMLEFSTuaWr+W+t+WTpeWwlOaRqSxJU1TkvIrmlq/lnabluIPlsJQsRFhC6L+q5ouc"),Zo=(()=>{let e={};for(let t of Kr.split(","))t.length>3&&(e[t.slice(0,3)]=t.slice(3));return e})(),Wr=new Map;for(let[e,t]of Object.entries(wn))for(let n of t)Wr.set(n,e);_o=Object.keys(wn)});var An=E(()=>{"use strict"});var ms,En=E(()=>{"use strict";j();z();xn();An();ms=".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 bs,Pn=E(()=>{"use strict";Ue();z();bs=new TextEncoder});var Ns,Sn=E(()=>{"use strict";Le();z();Ns=3600*24});function Cn(e){return mn(e)}async function Tn(e,t){if(ce.config&&Date.now()-ce.configAt<zr)return ce.config;let n=await bn(e,t);return ce.config=n,ce.configAt=Date.now(),n}var zr,ce,dt=E(()=>{"use strict";Ue();Le();Sn();zr=15e3,ce={config:null,configAt:0,auth:null,authAt:0}});var Dn={};he(Dn,{clearUnlockCache:()=>Zr,runUnlockProbe:()=>Jr});function qr(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 Qr(e){let t=Date.now(),n=new AbortController,o=setTimeout(()=>n.abort(),Xr);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:qr(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 Jr(e,t){let n=e||"UNK",o=Date.now(),r=te.get(n);if(r&&o-r.at<Yr)return{...r.data,cached:!0};let s=await Promise.all(Gr.map(a=>Qr(a))),i={colo:n,region:t,cached:!1,at:o,targets:s};if(te.size>=Vr){let a="",c=Number[__sfx("UE9TSVRJVkVfSU5GSU5JVFk=")];for(let[f,l]of te)l.at<c&&(c=l.at,a=f);a&&te.delete(a)}return te.set(n,{at:o,data:i}),i}function Zr(){te.clear()}var Gr,Xr,Yr,Vr,te,vn=E(()=>{"use strict";Gr=[{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"}],Xr=4e3,Yr=600*1e3,Vr=16,te=new Map});z();var Bn=8*1024*1024,Hn=2*1024*1024,xt=600*1e3,Kn=6*1024*1024*1024,Fe=Date.now(),Be=0;function At(e){e-Fe>=xt&&(Fe=e,Be=0)}function Wn(e,t=Date.now()){At(t),Be+=e}function wt(e){return At(e),Kn-Be}var zn=(()=>{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})(),jn=5e3;function Gn(e,t=jn){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 He(e){let t=new URL(e.url);if(e.headers.get("Upgrade")?.toLowerCase()===__sfx("d2Vic29ja2V0")){let f=new WebSocketPair,[l,u]=Object.values(f);u.accept();let d=Gn((h,g)=>u.close(h,g));return u.addEventListener("message",h=>{let g=typeof h.data=="string"?h.data:"";if(g==="PING"||g==="ping"){d.cancel(),u.send(JSON.stringify({pong:!0,colo:e.cf?.colo??"UNK",clientIp:e.headers.get("CF-Connecting-IP")??""}));try{u.close(1e3,"Probe complete")}catch{}return}d.cancel();try{u.close(1e3,"Probe aborted")}catch{}}),u.addEventListener("close",()=>d.cancel()),u.addEventListener("error",()=>d.cancel()),new Response(null,{status:101,[__sfx("d2ViU29ja2V0")]:l})}let o=Number.parseInt(t.searchParams.get("bytes")??"",10),r=Number.isFinite(o)&&o>0?Math.min(o,Bn):Hn,s=Date.now();if(wt(s)<=0){let f=Math.max(1e3,Fe+xt-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=zn,a=0,c=new ReadableStream({pull(f){let l=wt(Date.now());if(a>=r||l<=0){f.close();return}let u=Math.min(i.byteLength,r-a,l);f.enqueue(i.subarray(0,u)),a+=u,Wn(u)}});return new Response(c,{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":ye(4)}})}it();lt();et();ut();z();Le();Pe();En();Pn();z();function pt(e){let t=e===200?"Welcome":e===404?"Not Found":"Service Unavailable",n=`<!DOCTYPE html><html lang="zh-CN"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>${t}</title><style>body{margin:0;min-height:100vh;display:flex;align-items:center;justify-content:center;background:#f7f8fa;color:#333;font-family:-apple-system,"Segoe UI","PingFang SC",sans-serif}.c{text-align:center}h1{font-size:22px;font-weight:600;margin:0 0 10px}p{color:#888;font-size:14px;margin:0}</style></head><body><div class="c"><h1>${t}</h1><p>This site is up and running.</p></div></body></html>`;return new Response(n,{status:e,headers:{"Content-Type":"text/html; charset=utf-8","Cache-Control":"no-store","X-Content-Type-Options":"nosniff"}})}dt();dt();async function Rn(e){let t=Cn(e);return await Tn(t,e)}function mt(e){let t=[];return t.push(...ae(e[__sfx("cHJveHlJcA==")],"direct")),t.push(...ae(e[__sfx("c29ja3M1")],__sfx("c29ja3M1"))),t.push(...ae(e.httpProxy,"http")),t}var ht=6e4,_r=10,ue=0,ke=0;function In(e){return e>=ke?(ue=0,ke=e+ht,!1):ue>=_r}function Un(e,t,n){if(!n)return!1;let o=(e.headers.get(__sfx("eC1jZnBpbG90LXRva2Vu"))??t.searchParams.get("token")??"").trim();if(!o)return!1;let r=Date.now();return re(o,n)?(ue=0,!0):(r>=ke&&(ke=r+ht,ue=0),ue+=1,!1)}async function Ln(e,t,n){let o=new URL(e.url);if(o.pathname===__sfx("L19fZWRnZV9wcm9iZQ=="))return He(e);if(o.pathname===ve||o.pathname===__sfx("L19fdmVyc2lvbg=="))return Ie();if(o.pathname==="/region"&&e.method==="GET"){let{coloToCountry:i,rankRegions:a}=await Promise.resolve().then(()=>(ie(),_e)),c=e.cf?.colo??"",f=c?i(c):"";return new Response(JSON.stringify({ok:!0,colo:c,region:f,relayPreference:f?a(f):[],timestamp:new Date().toISOString()},null,2),{status:200,headers:{"Content-Type":"application/json; charset=utf-8"}})}let r=await Rn(t);if(o.pathname===__sfx("L19fZGlhZw==")){if(In(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(ht/1e3))}});if(!Un(e,o,r.uuid))return null;let{recentDiagnostics:i}=await Promise.resolve().then(()=>(it(),pn)),{[__sfx("cmVjZW50WGh0dHBEaWFnbm9zdGljcw==")]:a}=await Promise.resolve().then(()=>(lt(),dn));return new Response(JSON.stringify({ok:!0,impl:"self",build:ct,recent:i(),[__sfx("eGh0dHA=")]:a()},null,2),{status:200,headers:{"Content-Type":"application/json; charset=utf-8","Cache-Control":"no-store"}})}if(o.pathname==="/__unlock_probe"){if(!r.unlockProbe)return null;if(In(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(!Un(e,o,r.uuid))return null;let{coloToCountry:i}=await Promise.resolve().then(()=>(ie(),_e)),{runUnlockProbe:a}=await Promise.resolve().then(()=>(vn(),Dn)),c=e.cf?.colo??"",f=c?i(c):"",l=await a(c,f);return new Response(JSON.stringify({ok:!0,...l},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 Te(e,__sfx("dmxlc3M="),r,mt(r),n):r[__sfx("ZW5hYmxlVHJvamFu")]&&o.pathname===r[__sfx("dHJvamFuUGF0aA==")]?s!==__sfx("d2Vic29ja2V0")?null:await Te(e,__sfx("dHJvamFu"),r,mt(r),n):r[__sfx("ZW5hYmxlWGh0dHA=")]&&o.pathname===r[__sfx("eGh0dHBQYXRo")]?e.method!=="POST"?null:await at(e,r,mt(r)):null}ut();var Ri={async fetch(e,t,n){try{return new URL(e.url).pathname===ve?Ie():await Ln(e,t,n)??pt(200)}catch{return pt(500)}}};export{Ri as default};
|
package/assets/worker.js
CHANGED
|
@@ -3,7 +3,7 @@ var ss=Object.defineProperty;var R=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(
|
|
|
3
3
|
`))),i){let P=`${w} Trojan`;r.push(P),n.push([` - name: ${$(P)}`," type: trojan",` password: ${$(e.config.trojanPassword)}`,` server: ${m.ip}`,` port: ${A}`," network: ws"," tls: true",` sni: ${e.domain}`,` client-fingerprint: ${e.config.clientFingerprint}`,...l()," ws-opts:",` path: ${$(e.config.trojanPath)}`," headers:",` Host: ${e.domain}`].join(`
|
|
4
4
|
`))}}});t.push("# CFPilot \u81EA\u52A8\u751F\u6210\u8BA2\u9605"),t.push("mixed-port: 7890"),t.push("allow-lan: false"),t.push("mode: rule"),t.push("log-level: info"),t.push("unified-delay: true"),t.push("tcp-concurrent: true"),t.push(""),t.push("dns:"),t.push(" enable: true"),t.push(" ipv6: false"),t.push(" enhanced-mode: fake-ip"),t.push(" fake-ip-range: 198.18.0.1/16"),t.push(" default-nameserver:"),t.push(" - 223.5.5.5"),t.push(" - 119.29.29.29"),t.push(" nameserver:"),t.push(" - https://223.5.5.5/dns-query"),t.push(" - https://dns.alidns.com/dns-query"),t.push(" fallback:"),t.push(" - 8.8.4.4"),t.push(" - 1.1.1.1"),t.push(" fallback-filter:"),t.push(" geoip: true"),t.push(" geoip-code: CN"),t.push(""),a&&(t.push(" nameserver-policy:"),t.push(` ${$(c)}: ${f?$(f):"https://223.5.5.5/dns-query"}`),t.push(""));let u=Zn(e.routeProfile??"",{mainGroup:"CFPilot",autoGroup:"\u81EA\u52A8\u9009\u62E9"});if(t.push("proxies:"),n.length===0?t.push(" []"):t.push(...n),t.push(""),t.push("proxy-groups:"),t.push(' - name: "CFPilot"'),t.push(" type: select"),t.push(" proxies:"),t.push(' - "\u81EA\u52A8\u9009\u62E9"'),t.push(' - "\u6545\u969C\u8F6C\u79FB"'),r.length===0)t.push(" []");else for(let d of r)t.push(` - ${$(d)}`);if(r.length>0){t.push(""),t.push(' - name: "\u81EA\u52A8\u9009\u62E9"'),t.push(" type: url-test"),t.push(' url: "http://www.gstatic.com/generate_204"'),t.push(" interval: 300"),t.push(" tolerance: 50"),t.push(" proxies:");for(let d of r)t.push(` - ${$(d)}`);t.push(""),t.push(' - name: "\u6545\u969C\u8F6C\u79FB"'),t.push(" type: fallback"),t.push(' url: "http://www.gstatic.com/generate_204"'),t.push(" interval: 300"),t.push(" proxies:");for(let d of r)t.push(` - ${$(d)}`)}return u.groups.length>0&&(t.push(""),t.push(...u.groups)),t.push(""),t.push("rules:"),u.rules.length>0?(t.push(...u.rules),u.rules.some(d=>d.includes("MATCH,"))||t.push(" - MATCH,CFPilot")):t.push(...Jn("CFPilot")),t.push(""),t.join(`
|
|
5
5
|
`)}function Vs(e){let t=[],n=[],r=Mt(e.config.subVariants,e.config,cr),o=r.some(l=>l==="vless-ws"),s=r.includes("trojan"),i=e.config.ech,a=e.config.echHost.trim()||"cloudflare-ech.com",c=()=>i?{ech:{enabled:!0,query_server_name:a}}:{};for(let l of Ft(e)){let u=[];l.entries.forEach((d,m)=>{let g=`${l.name} ${Be(d,"vless",m,"")}`;for(let b of Ht(d,e)){let A=e.ports.length>1?`:${b}`:"",p=`${g}${A}`,w=`${p} Trojan`;o&&u.push(p),s&&u.push(w),o&&t.push({type:"vless",tag:p,server:d.ip,server_port:b,uuid:e.config.uuid,tls:{enabled:!0,server_name:e.domain,insecure:!1,utls:{enabled:!0,fingerprint:e.config.clientFingerprint},...c()},transport:{type:"ws",path:e.config.wsPath,headers:{Host:e.domain}}}),s&&t.push({type:"trojan",tag:w,server:d.ip,server_port:b,password:e.config.trojanPassword,tls:{enabled:!0,server_name:e.domain,insecure:!1,utls:{enabled:!0,fingerprint:e.config.clientFingerprint},...c()},transport:{type:"ws",path:e.config.trojanPath,headers:{Host:e.domain}}})}}),u.length>0&&n.push({tag:l.name,members:u})}t.push({type:"direct",tag:"direct"});for(let l of n)t.push({type:"selector",tag:l.tag,outbounds:l.members,default:l.members[0]});return t.push({type:"selector",tag:"CFPilot",outbounds:n.length>0?n.map(l=>l.tag):["direct"],default:n.length>0?n[0].tag:"direct"}),JSON.stringify({log:{level:"info",timestamp:!0},dns:{servers:[{tag:"dns-out",address:"https://1.1.1.1/dns-query"},{tag:"local",address:"local"}],rules:[{domain_suffix:lr,server:"local"}]},inbounds:[{type:"mixed",tag:"mixed-in",listen:"127.0.0.1",listen_port:2080}],outbounds:t,route:{rules:[{ip_is_private:!0,outbound:"direct"},{domain_suffix:lr,outbound:"direct"}],final:"CFPilot",auto_detect_interface:!0}},null,2)}function Ys(e){let t=[],n=Mt(e.config.subVariants,e.config);for(let r of Ft(e))r.entries.forEach((o,s)=>{let i=Be(o,"vless",s,r.name);for(let a of Ht(o,e)){let c=e.ports.length>1?`:${a}`:"",f=`${i}${c}`,l={...o,port:a};for(let u of n)u==="vless-ws"?t.push(ar(l,e,"ws",`${f} WS`)):u==="vless-xhttp"?t.push(ar(l,e,"xhttp",`${f} XHTTP`)):t.push(Gs(l,e,`${f} Trojan`))}});return Ln(t.join(`
|
|
6
|
-
`))}function gr(e,t){let n=Bt(t.config.subName);switch(e){case"clash":return{body:Xs(t),contentType:"text/yaml; charset=utf-8",fileName:n};case"singbox":return{body:Vs(t),contentType:"application/json; charset=utf-8",fileName:n};default:return{body:Ys(t),contentType:"text/plain; charset=utf-8",fileName:n}}}var pe,Ps,Es,$n,er,tr,Ss,Cs,Ts,Fs,Hs,Ks,de,Ws,ir,cr,js,lr,Kt=R(()=>{"use strict";ie();oe();Ut();_n();pe=443;Ps=["ip\u5730\u5740","ip \u5730\u5740","ip","\u5730\u5740","\u670D\u52A1\u5668","server","host"],Es=["\u7AEF\u53E3","port"],$n=["\u4E0B\u8F7D\u901F\u5EA6","\u901F\u5EA6","speed","download"],er=["\u5E73\u5747\u5EF6\u8FDF","\u5EF6\u8FDF","latency","delay","\u54CD\u5E94\u65F6\u95F4","rtt"],tr=["colo","\u673A\u623F","\u6570\u636E\u4E2D\u5FC3","\u5730\u533A","region"],Ss=["\u56FD\u5BB6","country","\u56FD\u522B"],Cs=["\u57CE\u5E02","city"],Ts=["tls","\u662F\u5426\u652F\u6301tls","\u652F\u6301tls"];Fs={official:"\u5B98\u65B9\u4F18\u9009IP",domain:"\u4F18\u9009\u57DF\u540D",manual:"\u624B\u52A8\u4F18\u9009IP",api:"\u8FDC\u7A0BAPI",csv:"\u6D4B\u901FCSV"};Hs=12e4,Ks=32,de=new Map,Ws="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36";ir=["vless-ws","vless-xhttp","trojan"];cr=["vless-ws","trojan"];js=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;lr=".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 ti(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 xr(e,t){let n=await crypto.subtle.importKey("raw",wr.encode(e),{name:"HMAC",hash:"SHA-256"},!1,["sign"]),r=await crypto.subtle.sign("HMAC",n,wr.encode(t));return ti(new Uint8Array(r))}async function at(e){let t=(await e.get(it))?.trim();if(t)return t;let n=Ar();return e instanceof se&&await e.put(it,n),n}async function Pr(e){let t=Ar();return e instanceof se?await e.put(it,t):await e.put(it,t),t}async function Er(e,t={}){let n=t.ttlDays??0,r=Math.floor((t.now??Date.now())/1e3),o=n>0?r+Math.round(n*86400):0,s=Math.floor(Math.random()*36**8).toString(36).padStart(8,"0"),i=`${zt}.${o.toString(36)}.${s}`,a=(await xr(e,i)).slice(0,Gt);return`${i}.${a}`}async function lt(e,t,n=Date.now()){if(!e||!t)return{ok:!1,reason:"format"};let r=t.split(".");if(r.length!==4||r[0]!==zt)return{ok:!1,reason:"format"};let o=r[1],s=r[2],i=r[3];if(!o||!s||i.length!==Gt)return{ok:!1,reason:"format"};let a=Number.parseInt(o,36);if(!Number.isFinite(a)||a<0)return{ok:!1,reason:"format"};let c=(await xr(e,`${zt}.${o}.${s}`)).slice(0,Gt);return Z(i,c)?a>0&&Math.floor(n/1e3)>=a?{ok:!1,reason:"expired",exp:a}:{ok:!0,exp:a}:{ok:!1,reason:"signature"}}var it,zt,Gt,wr,Ar,Xt=R(()=>{"use strict";Qe();oe();it="SUB_TOKEN_SECRET",zt="v1",Gt=22,wr=new TextEncoder;Ar=()=>q(32)});function oi(e){let t="";for(let n of e)t+=(n<16?"0":"")+n.toString(16);return t}function si(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 vr(e,t,n){let r=si(t);if(!r)return null;let o=await crypto.subtle.importKey("raw",new TextEncoder().encode(e),"PBKDF2",!1,["deriveBits"]),s=await crypto.subtle.deriveBits({name:"PBKDF2",salt:r,iterations:n,hash:"SHA-256"},o,256);return oi(new Uint8Array(s))}function Ir(e){if(e.startsWith(`${Yt}$`)){let[r,o,s,i]=e.split("$");if(r!==Yt||!s||!i)return null;let a=Number.parseInt(o??"",10);return!Number.isFinite(a)||a<1||a>1e6?null:{scheme:"pbkdf2",salt:s,iterations:a,expected:i}}let[t,n]=e.split(":");return!t||!n?null:{scheme:"sha256",salt:t,iterations:0,expected:n}}async function Ur(e,t){return e.scheme==="pbkdf2"?await vr(t,e.salt,e.iterations):await Tt(`${e.salt}:${t}`)}async function qt(e,t){let n=await vr(e,t,Rr);return n?`${Yt}$${Rr}$${t}$${n}`:`${t}:${await Tt(`${t}:${e}`)}`}async function ii(e,t){let n=Ir(e);if(!n)return!1;let r=await Ur(n,t);return r?Z(r,n.expected):!1}function Dr(e){return`/${e.trim().replace(/^\/+/,"")}`}async function Nr(e,t,n){let r=await e.get(_e)??"",o=n&&n.trim()?Dr(n):"";o?r!==o&&(r=o,await e.put(_e,r)):r||(r=Dr(`${Hn}-${On(6)}`),await e.put(_e,r));let s=await e.get(De)??"",i=null,a=t&&t.trim()?t.trim():"";if(a){if(!s||!await ii(s,a)){let f=q(8);s=await qt(a,f),await e.put(De,s)}await e.get(be)&&await e.delete(be)}else if(!s){let c=`cfp-${q(8)}`,f=q(8);s=await qt(c,f),await e.put(De,s),i=c,await e.put(be,c)}return{panelPath:r,passwordHash:s,generatedPassword:i}}async function Or(e,t){let n=Ir(e.passwordHash);if(!n)return{ok:!1,legacy:!1};let r=await Ur(n,t);if(!r)return{ok:!1,legacy:!1};let o=Z(r,n.expected);return{ok:o,legacy:o&&n.scheme==="sha256"}}async function Lr(e,t){let n=q(8);await e.put(De,await qt(t,n))}async function Mr(e){await e.get(be)&&await e.delete(be)}function Fr(e){let t=e.headers.get("Cookie")??"",n={};for(let r of t.split(";")){let o=r.indexOf("=");if(o<0)continue;let s=r.slice(0,o).trim(),i=r.slice(o+1).trim();s&&(n[s]=decodeURIComponent(i))}return n}async function Br(e){let t=q(24);return await e.put(`${Ze}${t}`,JSON.stringify({ua:"",t:Date.now()}),kr),t}async function Qt(e,t){let n=Fr(t)[ut];return n?!!await e.get(`${Ze}${n}`):!1}function Hr(e,t=kr){return`${ut}=${e}; Path=/; HttpOnly; Secure; SameSite=Strict; Max-Age=${t}`}function Kr(){return`${ut}=; Path=/; HttpOnly; Secure; SameSite=Strict; Max-Age=0`}async function Wr(e,t){let n=Fr(t)[ut];n&&await e.delete(`${Ze}${n}`)}async function jr(e){let t=q(20);return await e.put(`${Je}${t}`,"1",ri),t}async function zr(e,t){if(!t)return!1;let n=await e.get("SCANNER_TOKEN");return n&&Z(n,t)?!0:await e.get(`${Je}${t}`)?(await e.delete(`${Je}${t}`),!0):!1}var ut,kr,ri,Rr,Yt,Jt=R(()=>{"use strict";Ne();oe();ut="cfpilot_sess",kr=3600*24,ri=600,Rr=3e4,Yt="pbkdf2"});function Zt(e){return Mn(e)}async function ft(e,t){if(J.config&&Date.now()-J.configAt<ai)return J.config;let n=await jn(e,t);return J.config=n,J.configAt=Date.now(),n}function Gr(){J.config=null,J.configAt=0}async function _t(e,t){if(J.auth&&Date.now()-J.authAt<li)return J.auth;let n=await Nr(e,t.PANEL_PASSWORD,t.PANEL_PATH);return J.auth=n,J.authAt=Date.now(),n}function $t(e){switch((e??"").toLowerCase()){case"clash":case"mihomo":case"yaml":return"clash";case"singbox":case"sing-box":case"json":return"singbox";case"v2ray":return"v2ray";case"base64":return"base64";default:return"base64"}}function He(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 Xr(e){let t=(e??"").toLowerCase();return t?t.includes("clash")||t.includes("mihomo")||t.includes("flclash")||t.includes("clashx")||t.includes("stash")?"clash":t.includes("sing-box")||t.includes("singbox")?"singbox":t.includes("v2ray")||t.includes("v2rayng")||t.includes("shadowrocket")||t.includes("nekobox")||t.includes("surge")||t.includes("loon")||t.includes("quantumult")?"base64":null:null}var ai,li,J,dt=R(()=>{"use strict";Qe();Ne();Jt();ai=15e3,li=6e4,J={config:null,configAt:0,auth:null,authAt:0}});function en(e,t,n){if(!e){n.push({field:t,message:`${t} \u4E0D\u80FD\u4E3A\u7A7A`});return}if(!e.startsWith("/")){n.push({field:t,message:`${t} \u5FC5\u987B\u4EE5 / \u5F00\u5934`});return}if(e.length>128){n.push({field:t,message:`${t} \u8FC7\u957F\uFF08\u6700\u591A 128 \u5B57\u7B26\uFF09`});return}/[\s\u0000-\u001f]/.test(e)&&n.push({field:t,message:`${t} \u4E0D\u80FD\u5305\u542B\u7A7A\u683C\u6216\u63A7\u5236\u5B57\u7B26`})}function me(e,t,n,r,o){if(!Number.isFinite(e)){o.push({field:t,message:`${t} \u5FC5\u987B\u662F\u6570\u5B57`});return}(e<n||e>r)&&o.push({field:t,message:`${t} \u5FC5\u987B\u5728 ${n} ~ ${r} \u4E4B\u95F4\uFF08\u5F53\u524D ${e}\uFF09`})}function pt(e,t,n){let r=e.split(/\r?\n|,/).map(o=>o.trim()).filter(Boolean);if(r.length>20){n.push({field:t,message:`${t} \u6700\u591A 20 \u6761\uFF08\u5F53\u524D ${r.length}\uFF09`});return}for(let o of r)if(!ui.test(o)){n.push({field:t,message:`${t} \u91CC\u6709\u65E0\u6CD5\u8BC6\u522B\u7684\u6761\u76EE\uFF1A${o.slice(0,40)}`});return}}function Vr(e,t,n){let r=e.split(/\r?\n|,/).map(o=>o.trim()).filter(Boolean);if(r.length>10){n.push({field:t,message:`${t} \u6700\u591A 10 \u6761\uFF08\u5F53\u524D ${r.length}\uFF09`});return}for(let o of r)if(!/^https?:\/\/\S+$/i.test(o)){n.push({field:t,message:`${t} \u5FC5\u987B\u662F http(s) \u5730\u5740\uFF1A${o.slice(0,40)}`});return}}function tn(e){let t=[],n=o=>Object.prototype.hasOwnProperty.call(e,o);n("wsPath")&&en(String(e.wsPath??""),"wsPath",t),n("trojanPath")&&en(String(e.trojanPath??""),"trojanPath",t),n("xhttpPath")&&en(String(e.xhttpPath??""),"xhttpPath",t);let r=["wsPath","trojanPath","xhttpPath"].filter(o=>n(o)).map(o=>`${o}=${String(e[o]??"")}`);if(r.length>=2){let o=r.map(s=>s.slice(s.indexOf("=")+1));new Set(o).size!==o.length&&t.push({field:"paths",message:"wsPath / trojanPath / xhttpPath \u4E0D\u80FD\u91CD\u590D"})}if(n("subDomain")){let o=String(e.subDomain??"").trim();o&&(!ci.test(o)||o.includes("/"))&&t.push({field:"subDomain",message:"subDomain \u5FC5\u987B\u662F\u5408\u6CD5\u4E3B\u673A\u540D\uFF08\u4E0D\u542B\u534F\u8BAE\u4E0E\u8DEF\u5F84\uFF09"})}if(n("proxyIp")&&pt(String(e.proxyIp??""),"proxyIp",t),n("socks5")&&pt(String(e.socks5??""),"socks5",t),n("httpProxy")&&pt(String(e.httpProxy??""),"httpProxy",t),n("relayPool")&&pt(String(e.relayPool??""),"relayPool",t),n("officialCount")&&me(Number(e.officialCount),"officialCount",1,200,t),n("domainCount")&&me(Number(e.domainCount),"domainCount",1,200,t),n("maxNodes")&&me(Number(e.maxNodes),"maxNodes",0,500,t),n("dls")&&me(Number(e.dls),"dls",0,1e3,t),n("maxLatency")&&me(Number(e.maxLatency),"maxLatency",0,1e4,t),n("dataBudgetMB")&&me(Number(e.dataBudgetMB),"dataBudgetMB",0,102400,t),n("subTokenTtlDays")&&me(Number(e.subTokenTtlDays),"subTokenTtlDays",0,3650,t),n("subPorts")){let o=String(e.subPorts??"").trim();if(o){let s=o.split(/[\n,;\s]+/).filter(Boolean);s.length>6?t.push({field:"subPorts",message:"subPorts \u6700\u591A 6 \u4E2A\u7AEF\u53E3"}):s.every(i=>/^\d{1,5}$/.test(i)&&Number(i)>=1&&Number(i)<=65535)||t.push({field:"subPorts",message:"subPorts \u91CC\u6BCF\u4E2A\u7AEF\u53E3\u90FD\u5FC5\u987B\u662F 1~65535 \u7684\u6570\u5B57"})}}if(n("subName")){let o=String(e.subName??"");o.length>40&&t.push({field:"subName",message:"subName \u6700\u591A 40 \u5B57\u7B26"}),/[\u0000-\u001f]/.test(o)&&t.push({field:"subName",message:"subName \u4E0D\u80FD\u5305\u542B\u63A7\u5236\u5B57\u7B26"})}if(n("addApi")&&Vr(String(e.addApi??""),"addApi",t),n("addCsv")&&Vr(String(e.addCsv??""),"addCsv",t),n("uuid")){let o=String(e.uuid??"").trim();o&&!/^[0-9a-fA-F]{8}-?[0-9a-fA-F]{4}-?[0-9a-fA-F]{4}-?[0-9a-fA-F]{4}-?[0-9a-fA-F]{12}$/.test(o)&&t.push({field:"uuid",message:"uuid \u5FC5\u987B\u662F\u6807\u51C6 UUID\uFF0836 \u4F4D\uFF0C\u53EF\u5E26\u8FDE\u5B57\u7B26\uFF09"})}if(n("poolCountries")){let o=String(e.poolCountries??"").trim();if(o){let s=o.split(/[\n,;\s]+/).filter(Boolean);s.length>30?t.push({field:"poolCountries",message:"poolCountries \u6700\u591A 30 \u4E2A\u56FD\u5BB6/\u5730\u533A"}):s.every(i=>/^[A-Za-z]{2,3}$/.test(i))||t.push({field:"poolCountries",message:"poolCountries \u53EA\u80FD\u662F 2~3 \u4F4D\u5B57\u6BCD\u4EE3\u7801"})}}if(n("udpDnsEndpoint")){let o=String(e.udpDnsEndpoint??"").trim();o&&!/^https:\/\/\S+$/i.test(o)&&t.push({field:"udpDnsEndpoint",message:"udpDnsEndpoint \u5FC5\u987B\u662F https \u5730\u5740"})}return t}function nn(e){return e.length===0?"":e.length===1?e[0].message:`\u6709 ${e.length} \u9879\u914D\u7F6E\u4E0D\u5408\u6CD5\uFF1A${e.map(t=>t.message).join("\uFF1B")}`}var ci,ui,Yr=R(()=>{"use strict";ci=/^(?=.{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])?)*$/,ui=/^(?:(?:socks5|socks|socks5h|http|https):\/\/)?(?:[^\s@/]+@)?(?:\[[0-9a-fA-F:]+\]|[A-Za-z0-9._-]+)(?::\d{1,5})?$/});function Jr(e,t=Date.now()){let n={};for(let o of Qr){let s=e[o];s!==void 0&&(n[o]=s)}let r=fi.map(o=>({field:o.field,reason:o.reason}));for(let o of["socks5","httpProxy"]){let s=String(e[o]??"");if(!s){n[o]="";continue}if(s.includes("@")){r.push({field:o,reason:"\u542B\u7528\u6237\u540D/\u53E3\u4EE4\uFF0C\u9700\u624B\u5DE5\u91CD\u65B0\u586B\u5199"});continue}n[o]=s}return{schemaVersion:1,exportedAt:new Date(t).toISOString(),config:n,omitted:r}}function Zr(e){let t=new Set([...Qr.map(String),"socks5","httpProxy"]),n={};for(let[r,o]of Object.entries(e))t.has(r)&&(n[r]=o);return n}function qr(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 _r(e,t){let n=[];for(let[r,o]of Object.entries(t)){let s=e[r];String(s)!==String(o)&&n.push({field:r,from:qr(s),to:qr(o)})}return n}var Qr,fi,$r=R(()=>{"use strict";Qr=["poolOfficial","officialCount","poolDomain","domainCount","poolManual","poolCountries","add","dls","maxLatency","maxNodes","proxyIp","relayPool","useBuiltinRelay","proxyMode","nat64","concurrentDial","dataBudgetMB","resolvePreferred","enableTrojan","enableXhttp","subProtocol","subTransport","subVariants","subName","subPorts","clientFingerprint","ech","echHost","echDns","tlsFragment","tlsFragmentSize","tlsFragmentDelay","subToken","subTokenTtlDays","unlockProbe","udpDns","udpDnsEndpoint"],fi=[{field:"uuid",reason:"\u5165\u7AD9\u51ED\u636E"},{field:"trojanPassword",reason:"\u5165\u7AD9\u51ED\u636E"},{field:"wsPath",reason:"\u5B9E\u4F8B\u6807\u8BC6\uFF08\u8BA2\u9605\u94FE\u63A5\u91CC\u53EF\u89C1\uFF0C\u5BFC\u51FA\u5373\u66B4\u9732\u5165\u53E3\uFF09"},{field:"trojanPath",reason:"\u5B9E\u4F8B\u6807\u8BC6"},{field:"xhttpPath",reason:"\u5B9E\u4F8B\u6807\u8BC6"},{field:"subDomain",reason:"\u5B9E\u4F8B\u6807\u8BC6"},{field:"addApi",reason:"URL \u53EF\u80FD\u542B\u79C1\u6709 token"},{field:"addCsv",reason:"URL \u53EF\u80FD\u542B\u79C1\u6709 token"}]});function to(){return new Response(JSON.stringify({build:Ke,version:rn,ts:Date.now()}),{status:200,headers:{"Content-Type":"application/json","Cache-Control":"no-store","Access-Control-Allow-Origin":"*"}})}var Ke,rn,eo,on=R(()=>{"use strict";Ke="6cf3fc8-2d5c8203",rn="0.12.5",eo="/__cfp_version"});var oo={};Re(oo,{API_PREFIX:()=>sn,getScannerToken:()=>hi,handleApi:()=>yi});function pi(e){return e.headers.get("CF-Connecting-IP")??e.headers.get("x-forwarded-for")?.split(",")[0]?.trim()??"unknown"}function mi(e,t){let n=ne.get(e);return n?t>=n.resetAt?(ne.delete(e),!1):n.count>=di:!1}function gi(e,t){let n=ne.get(e);if(!n||t>=n.resetAt){if(ne.size>=no){for(let[r,o]of ne)t>=o.resetAt&&ne.delete(r);ne.size>=no&&ne.clear()}ne.set(e,{count:1,resetAt:t+ro});return}n.count+=1}function L(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 z(e,t){return L({ok:!1,error:e},t)}async function hi(e,t){let n=await e.get(kt);if(n)return n;if(typeof t.SCANNER_TOKEN=="string"&&t.SCANNER_TOKEN)return t.SCANNER_TOKEN;let r=q(24);return await e.put(kt,r),r}async function yi(e,t,n){if(!t.pathname.startsWith(sn))return null;let{store:r,env:o,config:s,auth:i}=n,a=t.pathname.slice(sn.length)||"/",c=e.method.toUpperCase();if(a==="/session"&&c==="GET"){let l=await Qt(r,e);return L({ok:!0,authenticated:l,panelPath:i.panelPath})}if(a==="/login"&&c==="POST"){let l="";try{let b=await e.json();l=String(b.password??"")}catch{return z("\u8BF7\u6C42\u4F53\u89E3\u6790\u5931\u8D25",400)}if(!l)return z("\u8BF7\u8F93\u5165\u5BC6\u7801",400);let u=pi(e),d=Date.now();if(mi(u,d))return new Response(JSON.stringify({ok:!1,error:"\u5C1D\u8BD5\u8FC7\u4E8E\u9891\u7E41\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5"}),{status:429,headers:{"Content-Type":"application/json; charset=utf-8","Cache-Control":"no-store","Retry-After":String(Math.ceil(ro/1e3))}});let m=await Or(i,l);if(!m.ok)return gi(u,d),z("\u5BC6\u7801\u9519\u8BEF",401);ne.delete(u),m.legacy&&await Lr(r,l).catch(()=>{}),await Mr(r).catch(()=>{});let g=await Br(r);return L({ok:!0},200,{"Set-Cookie":Hr(g)})}if(a==="/logout"&&c==="POST")return await Wr(r,e),L({ok:!0},200,{"Set-Cookie":Kr()});if(a==="/preferred-ips"&&c==="POST"){let l=e.headers.get("Authorization")??"",u=l.startsWith("Bearer ")?l.slice(7).trim():l.trim();if(!await zr(r,u))return z("Token \u6821\u9A8C\u5931\u8D25",401);let m;try{m=await e.json()}catch{return z("\u8BF7\u6C42\u4F53\u89E3\u6790\u5931\u8D25",400)}let g=Array.isArray(m.ips)?m.ips.map(S=>String(S)):[],b=g.map(S=>S.trim()).filter(S=>S.length>0).join(`
|
|
6
|
+
`))}function gr(e,t){let n=Bt(t.config.subName);switch(e){case"clash":return{body:Xs(t),contentType:"text/yaml; charset=utf-8",fileName:n};case"singbox":return{body:Vs(t),contentType:"application/json; charset=utf-8",fileName:n};default:return{body:Ys(t),contentType:"text/plain; charset=utf-8",fileName:n}}}var pe,Ps,Es,$n,er,tr,Ss,Cs,Ts,Fs,Hs,Ks,de,Ws,ir,cr,js,lr,Kt=R(()=>{"use strict";ie();oe();Ut();_n();pe=443;Ps=["ip\u5730\u5740","ip \u5730\u5740","ip","\u5730\u5740","\u670D\u52A1\u5668","server","host"],Es=["\u7AEF\u53E3","port"],$n=["\u4E0B\u8F7D\u901F\u5EA6","\u901F\u5EA6","speed","download"],er=["\u5E73\u5747\u5EF6\u8FDF","\u5EF6\u8FDF","latency","delay","\u54CD\u5E94\u65F6\u95F4","rtt"],tr=["colo","\u673A\u623F","\u6570\u636E\u4E2D\u5FC3","\u5730\u533A","region"],Ss=["\u56FD\u5BB6","country","\u56FD\u522B"],Cs=["\u57CE\u5E02","city"],Ts=["tls","\u662F\u5426\u652F\u6301tls","\u652F\u6301tls"];Fs={official:"\u5B98\u65B9\u4F18\u9009IP",domain:"\u4F18\u9009\u57DF\u540D",manual:"\u624B\u52A8\u4F18\u9009IP",api:"\u8FDC\u7A0BAPI",csv:"\u6D4B\u901FCSV"};Hs=12e4,Ks=32,de=new Map,Ws="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36";ir=["vless-ws","vless-xhttp","trojan"];cr=["vless-ws","trojan"];js=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;lr=".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 ti(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 xr(e,t){let n=await crypto.subtle.importKey("raw",wr.encode(e),{name:"HMAC",hash:"SHA-256"},!1,["sign"]),r=await crypto.subtle.sign("HMAC",n,wr.encode(t));return ti(new Uint8Array(r))}async function at(e){let t=(await e.get(it))?.trim();if(t)return t;let n=Ar();return e instanceof se&&await e.put(it,n),n}async function Pr(e){let t=Ar();return e instanceof se?await e.put(it,t):await e.put(it,t),t}async function Er(e,t={}){let n=t.ttlDays??0,r=Math.floor((t.now??Date.now())/1e3),o=n>0?r+Math.round(n*86400):0,s=Math.floor(Math.random()*36**8).toString(36).padStart(8,"0"),i=`${zt}.${o.toString(36)}.${s}`,a=(await xr(e,i)).slice(0,Gt);return`${i}.${a}`}async function lt(e,t,n=Date.now()){if(!e||!t)return{ok:!1,reason:"format"};let r=t.split(".");if(r.length!==4||r[0]!==zt)return{ok:!1,reason:"format"};let o=r[1],s=r[2],i=r[3];if(!o||!s||i.length!==Gt)return{ok:!1,reason:"format"};let a=Number.parseInt(o,36);if(!Number.isFinite(a)||a<0)return{ok:!1,reason:"format"};let c=(await xr(e,`${zt}.${o}.${s}`)).slice(0,Gt);return Z(i,c)?a>0&&Math.floor(n/1e3)>=a?{ok:!1,reason:"expired",exp:a}:{ok:!0,exp:a}:{ok:!1,reason:"signature"}}var it,zt,Gt,wr,Ar,Xt=R(()=>{"use strict";Qe();oe();it="SUB_TOKEN_SECRET",zt="v1",Gt=22,wr=new TextEncoder;Ar=()=>q(32)});function oi(e){let t="";for(let n of e)t+=(n<16?"0":"")+n.toString(16);return t}function si(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 vr(e,t,n){let r=si(t);if(!r)return null;let o=await crypto.subtle.importKey("raw",new TextEncoder().encode(e),"PBKDF2",!1,["deriveBits"]),s=await crypto.subtle.deriveBits({name:"PBKDF2",salt:r,iterations:n,hash:"SHA-256"},o,256);return oi(new Uint8Array(s))}function Ir(e){if(e.startsWith(`${Yt}$`)){let[r,o,s,i]=e.split("$");if(r!==Yt||!s||!i)return null;let a=Number.parseInt(o??"",10);return!Number.isFinite(a)||a<1||a>1e6?null:{scheme:"pbkdf2",salt:s,iterations:a,expected:i}}let[t,n]=e.split(":");return!t||!n?null:{scheme:"sha256",salt:t,iterations:0,expected:n}}async function Ur(e,t){return e.scheme==="pbkdf2"?await vr(t,e.salt,e.iterations):await Tt(`${e.salt}:${t}`)}async function qt(e,t){let n=await vr(e,t,Rr);return n?`${Yt}$${Rr}$${t}$${n}`:`${t}:${await Tt(`${t}:${e}`)}`}async function ii(e,t){let n=Ir(e);if(!n)return!1;let r=await Ur(n,t);return r?Z(r,n.expected):!1}function Dr(e){return`/${e.trim().replace(/^\/+/,"")}`}async function Nr(e,t,n){let r=await e.get(_e)??"",o=n&&n.trim()?Dr(n):"";o?r!==o&&(r=o,await e.put(_e,r)):r||(r=Dr(`${Hn}-${On(6)}`),await e.put(_e,r));let s=await e.get(De)??"",i=null,a=t&&t.trim()?t.trim():"";if(a){if(!s||!await ii(s,a)){let f=q(8);s=await qt(a,f),await e.put(De,s)}await e.get(be)&&await e.delete(be)}else if(!s){let c=`cfp-${q(8)}`,f=q(8);s=await qt(c,f),await e.put(De,s),i=c,await e.put(be,c)}return{panelPath:r,passwordHash:s,generatedPassword:i}}async function Or(e,t){let n=Ir(e.passwordHash);if(!n)return{ok:!1,legacy:!1};let r=await Ur(n,t);if(!r)return{ok:!1,legacy:!1};let o=Z(r,n.expected);return{ok:o,legacy:o&&n.scheme==="sha256"}}async function Lr(e,t){let n=q(8);await e.put(De,await qt(t,n))}async function Mr(e){await e.get(be)&&await e.delete(be)}function Fr(e){let t=e.headers.get("Cookie")??"",n={};for(let r of t.split(";")){let o=r.indexOf("=");if(o<0)continue;let s=r.slice(0,o).trim(),i=r.slice(o+1).trim();s&&(n[s]=decodeURIComponent(i))}return n}async function Br(e){let t=q(24);return await e.put(`${Ze}${t}`,JSON.stringify({ua:"",t:Date.now()}),kr),t}async function Qt(e,t){let n=Fr(t)[ut];return n?!!await e.get(`${Ze}${n}`):!1}function Hr(e,t=kr){return`${ut}=${e}; Path=/; HttpOnly; Secure; SameSite=Strict; Max-Age=${t}`}function Kr(){return`${ut}=; Path=/; HttpOnly; Secure; SameSite=Strict; Max-Age=0`}async function Wr(e,t){let n=Fr(t)[ut];n&&await e.delete(`${Ze}${n}`)}async function jr(e){let t=q(20);return await e.put(`${Je}${t}`,"1",ri),t}async function zr(e,t){if(!t)return!1;let n=await e.get("SCANNER_TOKEN");return n&&Z(n,t)?!0:await e.get(`${Je}${t}`)?(await e.delete(`${Je}${t}`),!0):!1}var ut,kr,ri,Rr,Yt,Jt=R(()=>{"use strict";Ne();oe();ut="cfpilot_sess",kr=3600*24,ri=600,Rr=3e4,Yt="pbkdf2"});function Zt(e){return Mn(e)}async function ft(e,t){if(J.config&&Date.now()-J.configAt<ai)return J.config;let n=await jn(e,t);return J.config=n,J.configAt=Date.now(),n}function Gr(){J.config=null,J.configAt=0}async function _t(e,t){if(J.auth&&Date.now()-J.authAt<li)return J.auth;let n=await Nr(e,t.PANEL_PASSWORD,t.PANEL_PATH);return J.auth=n,J.authAt=Date.now(),n}function $t(e){switch((e??"").toLowerCase()){case"clash":case"mihomo":case"yaml":return"clash";case"singbox":case"sing-box":case"json":return"singbox";case"v2ray":return"v2ray";case"base64":return"base64";default:return"base64"}}function He(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 Xr(e){let t=(e??"").toLowerCase();return t?t.includes("clash")||t.includes("mihomo")||t.includes("flclash")||t.includes("clashx")||t.includes("stash")?"clash":t.includes("sing-box")||t.includes("singbox")?"singbox":t.includes("v2ray")||t.includes("v2rayng")||t.includes("shadowrocket")||t.includes("nekobox")||t.includes("surge")||t.includes("loon")||t.includes("quantumult")?"base64":null:null}var ai,li,J,dt=R(()=>{"use strict";Qe();Ne();Jt();ai=15e3,li=6e4,J={config:null,configAt:0,auth:null,authAt:0}});function en(e,t,n){if(!e){n.push({field:t,message:`${t} \u4E0D\u80FD\u4E3A\u7A7A`});return}if(!e.startsWith("/")){n.push({field:t,message:`${t} \u5FC5\u987B\u4EE5 / \u5F00\u5934`});return}if(e.length>128){n.push({field:t,message:`${t} \u8FC7\u957F\uFF08\u6700\u591A 128 \u5B57\u7B26\uFF09`});return}/[\s\u0000-\u001f]/.test(e)&&n.push({field:t,message:`${t} \u4E0D\u80FD\u5305\u542B\u7A7A\u683C\u6216\u63A7\u5236\u5B57\u7B26`})}function me(e,t,n,r,o){if(!Number.isFinite(e)){o.push({field:t,message:`${t} \u5FC5\u987B\u662F\u6570\u5B57`});return}(e<n||e>r)&&o.push({field:t,message:`${t} \u5FC5\u987B\u5728 ${n} ~ ${r} \u4E4B\u95F4\uFF08\u5F53\u524D ${e}\uFF09`})}function pt(e,t,n){let r=e.split(/\r?\n|,/).map(o=>o.trim()).filter(Boolean);if(r.length>20){n.push({field:t,message:`${t} \u6700\u591A 20 \u6761\uFF08\u5F53\u524D ${r.length}\uFF09`});return}for(let o of r)if(!ui.test(o)){n.push({field:t,message:`${t} \u91CC\u6709\u65E0\u6CD5\u8BC6\u522B\u7684\u6761\u76EE\uFF1A${o.slice(0,40)}`});return}}function Vr(e,t,n){let r=e.split(/\r?\n|,/).map(o=>o.trim()).filter(Boolean);if(r.length>10){n.push({field:t,message:`${t} \u6700\u591A 10 \u6761\uFF08\u5F53\u524D ${r.length}\uFF09`});return}for(let o of r)if(!/^https?:\/\/\S+$/i.test(o)){n.push({field:t,message:`${t} \u5FC5\u987B\u662F http(s) \u5730\u5740\uFF1A${o.slice(0,40)}`});return}}function tn(e){let t=[],n=o=>Object.prototype.hasOwnProperty.call(e,o);n("wsPath")&&en(String(e.wsPath??""),"wsPath",t),n("trojanPath")&&en(String(e.trojanPath??""),"trojanPath",t),n("xhttpPath")&&en(String(e.xhttpPath??""),"xhttpPath",t);let r=["wsPath","trojanPath","xhttpPath"].filter(o=>n(o)).map(o=>`${o}=${String(e[o]??"")}`);if(r.length>=2){let o=r.map(s=>s.slice(s.indexOf("=")+1));new Set(o).size!==o.length&&t.push({field:"paths",message:"wsPath / trojanPath / xhttpPath \u4E0D\u80FD\u91CD\u590D"})}if(n("subDomain")){let o=String(e.subDomain??"").trim();o&&(!ci.test(o)||o.includes("/"))&&t.push({field:"subDomain",message:"subDomain \u5FC5\u987B\u662F\u5408\u6CD5\u4E3B\u673A\u540D\uFF08\u4E0D\u542B\u534F\u8BAE\u4E0E\u8DEF\u5F84\uFF09"})}if(n("proxyIp")&&pt(String(e.proxyIp??""),"proxyIp",t),n("socks5")&&pt(String(e.socks5??""),"socks5",t),n("httpProxy")&&pt(String(e.httpProxy??""),"httpProxy",t),n("relayPool")&&pt(String(e.relayPool??""),"relayPool",t),n("officialCount")&&me(Number(e.officialCount),"officialCount",1,200,t),n("domainCount")&&me(Number(e.domainCount),"domainCount",1,200,t),n("maxNodes")&&me(Number(e.maxNodes),"maxNodes",0,500,t),n("dls")&&me(Number(e.dls),"dls",0,1e3,t),n("maxLatency")&&me(Number(e.maxLatency),"maxLatency",0,1e4,t),n("dataBudgetMB")&&me(Number(e.dataBudgetMB),"dataBudgetMB",0,102400,t),n("subTokenTtlDays")&&me(Number(e.subTokenTtlDays),"subTokenTtlDays",0,3650,t),n("subPorts")){let o=String(e.subPorts??"").trim();if(o){let s=o.split(/[\n,;\s]+/).filter(Boolean);s.length>6?t.push({field:"subPorts",message:"subPorts \u6700\u591A 6 \u4E2A\u7AEF\u53E3"}):s.every(i=>/^\d{1,5}$/.test(i)&&Number(i)>=1&&Number(i)<=65535)||t.push({field:"subPorts",message:"subPorts \u91CC\u6BCF\u4E2A\u7AEF\u53E3\u90FD\u5FC5\u987B\u662F 1~65535 \u7684\u6570\u5B57"})}}if(n("subName")){let o=String(e.subName??"");o.length>40&&t.push({field:"subName",message:"subName \u6700\u591A 40 \u5B57\u7B26"}),/[\u0000-\u001f]/.test(o)&&t.push({field:"subName",message:"subName \u4E0D\u80FD\u5305\u542B\u63A7\u5236\u5B57\u7B26"})}if(n("addApi")&&Vr(String(e.addApi??""),"addApi",t),n("addCsv")&&Vr(String(e.addCsv??""),"addCsv",t),n("uuid")){let o=String(e.uuid??"").trim();o&&!/^[0-9a-fA-F]{8}-?[0-9a-fA-F]{4}-?[0-9a-fA-F]{4}-?[0-9a-fA-F]{4}-?[0-9a-fA-F]{12}$/.test(o)&&t.push({field:"uuid",message:"uuid \u5FC5\u987B\u662F\u6807\u51C6 UUID\uFF0836 \u4F4D\uFF0C\u53EF\u5E26\u8FDE\u5B57\u7B26\uFF09"})}if(n("poolCountries")){let o=String(e.poolCountries??"").trim();if(o){let s=o.split(/[\n,;\s]+/).filter(Boolean);s.length>30?t.push({field:"poolCountries",message:"poolCountries \u6700\u591A 30 \u4E2A\u56FD\u5BB6/\u5730\u533A"}):s.every(i=>/^[A-Za-z]{2,3}$/.test(i))||t.push({field:"poolCountries",message:"poolCountries \u53EA\u80FD\u662F 2~3 \u4F4D\u5B57\u6BCD\u4EE3\u7801"})}}if(n("udpDnsEndpoint")){let o=String(e.udpDnsEndpoint??"").trim();o&&!/^https:\/\/\S+$/i.test(o)&&t.push({field:"udpDnsEndpoint",message:"udpDnsEndpoint \u5FC5\u987B\u662F https \u5730\u5740"})}return t}function nn(e){return e.length===0?"":e.length===1?e[0].message:`\u6709 ${e.length} \u9879\u914D\u7F6E\u4E0D\u5408\u6CD5\uFF1A${e.map(t=>t.message).join("\uFF1B")}`}var ci,ui,Yr=R(()=>{"use strict";ci=/^(?=.{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])?)*$/,ui=/^(?:(?:socks5|socks|socks5h|http|https):\/\/)?(?:[^\s@/]+@)?(?:\[[0-9a-fA-F:]+\]|[A-Za-z0-9._-]+)(?::\d{1,5})?$/});function Jr(e,t=Date.now()){let n={};for(let o of Qr){let s=e[o];s!==void 0&&(n[o]=s)}let r=fi.map(o=>({field:o.field,reason:o.reason}));for(let o of["socks5","httpProxy"]){let s=String(e[o]??"");if(!s){n[o]="";continue}if(s.includes("@")){r.push({field:o,reason:"\u542B\u7528\u6237\u540D/\u53E3\u4EE4\uFF0C\u9700\u624B\u5DE5\u91CD\u65B0\u586B\u5199"});continue}n[o]=s}return{schemaVersion:1,exportedAt:new Date(t).toISOString(),config:n,omitted:r}}function Zr(e){let t=new Set([...Qr.map(String),"socks5","httpProxy"]),n={};for(let[r,o]of Object.entries(e))t.has(r)&&(n[r]=o);return n}function qr(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 _r(e,t){let n=[];for(let[r,o]of Object.entries(t)){let s=e[r];String(s)!==String(o)&&n.push({field:r,from:qr(s),to:qr(o)})}return n}var Qr,fi,$r=R(()=>{"use strict";Qr=["poolOfficial","officialCount","poolDomain","domainCount","poolManual","poolCountries","add","dls","maxLatency","maxNodes","proxyIp","relayPool","useBuiltinRelay","proxyMode","nat64","concurrentDial","dataBudgetMB","resolvePreferred","enableTrojan","enableXhttp","subProtocol","subTransport","subVariants","subName","subPorts","clientFingerprint","ech","echHost","echDns","tlsFragment","tlsFragmentSize","tlsFragmentDelay","subToken","subTokenTtlDays","unlockProbe","udpDns","udpDnsEndpoint"],fi=[{field:"uuid",reason:"\u5165\u7AD9\u51ED\u636E"},{field:"trojanPassword",reason:"\u5165\u7AD9\u51ED\u636E"},{field:"wsPath",reason:"\u5B9E\u4F8B\u6807\u8BC6\uFF08\u8BA2\u9605\u94FE\u63A5\u91CC\u53EF\u89C1\uFF0C\u5BFC\u51FA\u5373\u66B4\u9732\u5165\u53E3\uFF09"},{field:"trojanPath",reason:"\u5B9E\u4F8B\u6807\u8BC6"},{field:"xhttpPath",reason:"\u5B9E\u4F8B\u6807\u8BC6"},{field:"subDomain",reason:"\u5B9E\u4F8B\u6807\u8BC6"},{field:"addApi",reason:"URL \u53EF\u80FD\u542B\u79C1\u6709 token"},{field:"addCsv",reason:"URL \u53EF\u80FD\u542B\u79C1\u6709 token"}]});function to(){return new Response(JSON.stringify({build:Ke,version:rn,ts:Date.now()}),{status:200,headers:{"Content-Type":"application/json","Cache-Control":"no-store","Access-Control-Allow-Origin":"*"}})}var Ke,rn,eo,on=R(()=>{"use strict";Ke="b109ac3-2d5c8203",rn="0.12.6",eo="/__cfp_version"});var oo={};Re(oo,{API_PREFIX:()=>sn,getScannerToken:()=>hi,handleApi:()=>yi});function pi(e){return e.headers.get("CF-Connecting-IP")??e.headers.get("x-forwarded-for")?.split(",")[0]?.trim()??"unknown"}function mi(e,t){let n=ne.get(e);return n?t>=n.resetAt?(ne.delete(e),!1):n.count>=di:!1}function gi(e,t){let n=ne.get(e);if(!n||t>=n.resetAt){if(ne.size>=no){for(let[r,o]of ne)t>=o.resetAt&&ne.delete(r);ne.size>=no&&ne.clear()}ne.set(e,{count:1,resetAt:t+ro});return}n.count+=1}function L(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 z(e,t){return L({ok:!1,error:e},t)}async function hi(e,t){let n=await e.get(kt);if(n)return n;if(typeof t.SCANNER_TOKEN=="string"&&t.SCANNER_TOKEN)return t.SCANNER_TOKEN;let r=q(24);return await e.put(kt,r),r}async function yi(e,t,n){if(!t.pathname.startsWith(sn))return null;let{store:r,env:o,config:s,auth:i}=n,a=t.pathname.slice(sn.length)||"/",c=e.method.toUpperCase();if(a==="/session"&&c==="GET"){let l=await Qt(r,e);return L({ok:!0,authenticated:l,panelPath:i.panelPath})}if(a==="/login"&&c==="POST"){let l="";try{let b=await e.json();l=String(b.password??"")}catch{return z("\u8BF7\u6C42\u4F53\u89E3\u6790\u5931\u8D25",400)}if(!l)return z("\u8BF7\u8F93\u5165\u5BC6\u7801",400);let u=pi(e),d=Date.now();if(mi(u,d))return new Response(JSON.stringify({ok:!1,error:"\u5C1D\u8BD5\u8FC7\u4E8E\u9891\u7E41\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5"}),{status:429,headers:{"Content-Type":"application/json; charset=utf-8","Cache-Control":"no-store","Retry-After":String(Math.ceil(ro/1e3))}});let m=await Or(i,l);if(!m.ok)return gi(u,d),z("\u5BC6\u7801\u9519\u8BEF",401);ne.delete(u),m.legacy&&await Lr(r,l).catch(()=>{}),await Mr(r).catch(()=>{});let g=await Br(r);return L({ok:!0},200,{"Set-Cookie":Hr(g)})}if(a==="/logout"&&c==="POST")return await Wr(r,e),L({ok:!0},200,{"Set-Cookie":Kr()});if(a==="/preferred-ips"&&c==="POST"){let l=e.headers.get("Authorization")??"",u=l.startsWith("Bearer ")?l.slice(7).trim():l.trim();if(!await zr(r,u))return z("Token \u6821\u9A8C\u5931\u8D25",401);let m;try{m=await e.json()}catch{return z("\u8BF7\u6C42\u4F53\u89E3\u6790\u5931\u8D25",400)}let g=Array.isArray(m.ips)?m.ips.map(S=>String(S)):[],b=g.map(S=>S.trim()).filter(S=>S.length>0).join(`
|
|
7
7
|
`);await r.get(te)!==b&&await r.put(te,b);let w={};(s.add??"").trim()!==""&&(w.add=""),s.poolManual||(w.poolManual=!0);let P=!1;return Object.keys(w).length>0&&(await ve(r,ke(s,w)),n.onConfigChanged(),P=w.add!==void 0),L({ok:!0,count:g.length,clearedManual:P,enabledManual:w.poolManual===!0})}if(!await Qt(r,e))return z("\u672A\u767B\u5F55\u6216\u4F1A\u8BDD\u5DF2\u8FC7\u671F",401);if(a==="/status"&&c==="GET"){let l=await Ie(r),u=Fe(l),d=He(s.subDomain||o.DATA_HOST||t.hostname);return L({ok:!0,panelPath:i.panelPath,domain:t.hostname,nodeDomain:d,dataHost:o.DATA_HOST??"",colo:e.cf?.colo??"UNK",coloLabel:Me(e.cf?.colo??""),localIps:u.length,generatedPassword:i.generatedPassword,version:Ke,pkgVersion:rn,readAt:Date.now()})}if(a==="/config"&&c==="GET")return L({ok:!0,config:s});if(a==="/config"&&c==="PUT"){let l;try{l=await e.json()}catch{return z("\u8BF7\u6C42\u4F53\u89E3\u6790\u5931\u8D25",400)}if(!l.config||typeof l.config!="object")return z("\u7F3A\u5C11\u914D\u7F6E\u5BF9\u8C61",400);let u=tn(l.config);if(u.length>0)return z(nn(u),400);let d=ke(s,l.config);return await ve(r,d),n.onConfigChanged(),L({ok:!0,config:d})}if(a==="/config/export"&&c==="GET")return L({ok:!0,...Jr(s)});if(a==="/config/import"&&c==="POST"){let l;try{l=await e.json()}catch{return z("\u8BF7\u6C42\u4F53\u89E3\u6790\u5931\u8D25",400)}if(!l.config||typeof l.config!="object")return z("\u7F3A\u5C11\u914D\u7F6E\u5BF9\u8C61",400);let u=Zr(l.config);if(Object.keys(u).length===0)return z("\u6CA1\u6709\u53EF\u5BFC\u5165\u7684\u5B57\u6BB5\uFF08\u786E\u8BA4\u662F\u672C\u9879\u76EE\u5BFC\u51FA\u7684\u914D\u7F6E\u6587\u4EF6\uFF1F\uFF09",400);let d=tn(u);if(d.length>0)return z(nn(d),400);let m=_r(s,u);if(l.dryRun)return L({ok:!0,dryRun:!0,diff:m,count:m.length});if(m.length===0)return L({ok:!0,applied:0,diff:[],config:s});let g=ke(s,u);return await ve(r,g),n.onConfigChanged(),L({ok:!0,applied:m.length,diff:m,config:g})}if(a==="/ips"&&c==="GET"){let l=await Ie(r),u=Fe(l);return L({ok:!0,raw:l,count:u.length,entries:u})}if(a==="/ips"&&c==="DELETE")return await r.delete(te),L({ok:!0});if(a==="/ips"&&c==="PUT"){let l;try{l=await e.json()}catch{return z("\u8BF7\u6C42\u4F53\u89E3\u6790\u5931\u8D25",400)}if(typeof l.raw!="string")return z("\u7F3A\u5C11 raw \u5B57\u6BB5",400);let u=l.raw.split(/\r?\n/).map(d=>d.trim()).filter(d=>d.length>0).join(`
|
|
8
8
|
`);return u?await r.put(te,u):await r.get(te)!==null&&await r.delete(te),L({ok:!0,count:u?u.split(`
|
|
9
9
|
`).length:0})}if(a==="/nodes"&&c==="GET"){let l=await Ie(r),u=await Ue(r),d=new we(8),m=await ot(s,l,{budget:d,domainPool:u.length>0?u:void 0,bypassRemoteCache:!0});return L({ok:!0,count:m.nodes.length,nodes:m.nodes.slice(0,200).map(g=>({...g,coloLabel:g.colo?Me(g.colo):""})),groups:m.groups.map(g=>({key:g.key,name:g.name,count:g.entries.length})),stats:m.stats})}if(a==="/pool/meta"&&c==="GET"){let l=await Ue(r);return L({ok:!0,countries:Qn.map(u=>({code:u,name:Vn[u]??u})),limits:{officialCount:200,domainCount:100},builtin:{cidrs:$e.length,domains:Le.length},customDomains:l})}if(a==="/pool/library"&&c==="PUT"){let l;try{l=await e.json()}catch{return z("\u8BF7\u6C42\u4F53\u89E3\u6790\u5931\u8D25",400)}let u=Array.isArray(l.domains)?l.domains.map(d=>String(d)):[];return await zn(r,u),L({ok:!0,count:u.filter(d=>d.trim()).length})}if(a==="/scanner-token"&&c==="POST"){let l=await jr(r);return L({ok:!0,token:l,expiresIn:600})}if(a==="/sub-token"&&(c==="GET"||c==="POST")){let l=c==="POST",u=l?await Pr(r):await at(r),d=await Er(u,{ttlDays:s.subTokenTtlDays}),m=await lt(u,d);return L({ok:!0,rotated:l,mode:s.subToken,ttlDays:s.subTokenTtlDays,token:d,link:`${t.origin}/sub/${d}`,expiresAt:(m.exp??0)*1e3})}return a==="/events"&&c==="GET"?await bi(e,r):z("\u63A5\u53E3\u4E0D\u5B58\u5728",404)}async function bi(e,t){let n=new TextEncoder,r="",o,s=new ReadableStream({async start(i){let a=()=>{o&&clearTimeout(o);try{i.close()}catch{}};e.signal.addEventListener("abort",a);let c=async()=>{try{let f=await Ie(t);if(f!==r){r=f;let l=Fe(f).length;i.enqueue(n.encode(`event: ips
|
package/dist/cli.js
CHANGED