Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
bia-pain-bache committed Dec 1, 2024
2 parents de86c83 + c5f5a38 commit 80b7180
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion _worker.js

Large diffs are not rendered by default.

8 changes: 3 additions & 5 deletions src/helpers/init.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
import { isValidUUID } from "./helpers";

export function initializeParams(request, env) {
const defaultProxyIP = 'bpb.yousef.isegaro.com';
const proxyIPs = env.PROXYIP?.split(',').map(proxyIP => proxyIP.trim());
const url = new URL(request.url);
const searchParams = new URLSearchParams(url.search);
globalThis.panelVersion = '2.7.7';
globalThis.panelVersion = '2.7.8';
globalThis.defaultHttpPorts = ['80', '8080', '2052', '2082', '2086', '2095', '8880'];
globalThis.defaultHttpsPorts = ['443', '8443', '2053', '2083', '2087', '2096'];
globalThis.userID = env.UUID;
globalThis.trojanPassword = env.TROJAN_PASS;
globalThis.proxyIP = proxyIPs ? proxyIPs[Math.floor(Math.random() * proxyIPs.length)] : defaultProxyIP;
globalThis.proxyIP = proxyIPs ? proxyIPs[Math.floor(Math.random() * proxyIPs.length)] : 'bpb.yousef.isegaro.com';
globalThis.hostName = request.headers.get('Host');
globalThis.pathName = url.pathname;
globalThis.client = searchParams.get('app');
globalThis.urlOrigin = url.origin;
globalThis.dohURL = env.DOH_URL || 'https://cloudflare-dns.com/dns-query';
if (typeof env.bpb !== 'object') throw new Error('KV Dataset is not properly set! Please refer to tutorials.', { cause: "init"});
if (pathName !== '/secrets') {
if (typeof env.bpb !== 'object') throw new Error('KV Dataset is not properly set! Please refer to tutorials.', { cause: "init"});
if (!userID || !trojanPassword) throw new Error(`Please set UUID and Trojan password first. Please go to 🟢 https://${hostName}/secrets 🟢 to generate them.`, { cause: "init"});
if (userID && !isValidUUID(userID)) throw new Error(`Invalid UUID: ${userID}`, { cause: "init"});
}

}

0 comments on commit 80b7180

Please sign in to comment.