diff --git a/src/authentication/auth.js b/src/authentication/auth.js
index a814afb41..ee6e4f9b5 100644
--- a/src/authentication/auth.js
+++ b/src/authentication/auth.js
@@ -1,6 +1,10 @@
import { SignJWT, jwtVerify } from 'jose';
+import nacl from 'tweetnacl';
+import { configs } from '../helpers/config.js';
+let userID = configs.userID;
-export async function generateJWTToken (secretKey) {
+export async function generateJWTToken (env, secretKey) {
+ userID = env.UUID || userID;
const secret = new TextEncoder().encode(secretKey);
return await new SignJWT({ userID })
.setProtectedHeader({ alg: 'HS256' })
diff --git a/src/cores/clash.js b/src/cores-configs/clash.js
similarity index 98%
rename from src/cores/clash.js
rename to src/cores-configs/clash.js
index ba7cd93aa..98e363547 100644
--- a/src/cores/clash.js
+++ b/src/cores-configs/clash.js
@@ -1,6 +1,5 @@
import { getConfigAddresses, extractWireguardParams, generateRemark, randomUpperCase, getRandomPath, isIPv6 } from './helpers.js';
import { configs } from '../helpers/config.js';
-import { isValidUUID } from '../helpers/helpers.js';
let userID = configs.userID;
let trojanPassword = configs.userID;
const defaultHttpsPorts = configs.defaultHttpsPorts;
@@ -315,12 +314,10 @@ export async function getClashWarpConfig(proxySettings, warpConfigs) {
return config;
}
-export async function getClashNormalConfig (env, proxySettings) {
+export async function getClashNormalConfig (env, hostName, proxySettings) {
let chainProxy;
userID = env.UUID || userID;
- if (!isValidUUID(userID)) throw new Error(`Invalid UUID: ${userID}`);
trojanPassword = env.TROJAN_PASS || trojanPassword;
- const hostName = globalThis.hostName;
const {
cleanIPs,
proxyIP,
diff --git a/src/cores/helpers.js b/src/cores-configs/helpers.js
similarity index 100%
rename from src/cores/helpers.js
rename to src/cores-configs/helpers.js
diff --git a/src/cores/normalConfigs.js b/src/cores-configs/normalConfigs.js
similarity index 93%
rename from src/cores/normalConfigs.js
rename to src/cores-configs/normalConfigs.js
index cfa1c0785..88f41fb1d 100644
--- a/src/cores/normalConfigs.js
+++ b/src/cores-configs/normalConfigs.js
@@ -1,15 +1,12 @@
import { getConfigAddresses, generateRemark, randomUpperCase, getRandomPath } from './helpers.js';
import { configs } from '../helpers/config.js';
-import { isValidUUID } from '../helpers/helpers.js';
let userID = configs.userID;
let trojanPassword = configs.userID;
const defaultHttpsPorts = configs.defaultHttpsPorts;
-export async function getNormalConfigs(env, proxySettings, client) {
+export async function getNormalConfigs(env, hostName, proxySettings, client) {
userID = env.UUID || userID;
- if (!isValidUUID(userID)) throw new Error(`Invalid UUID: ${userID}`);
trojanPassword = env.TROJAN_PASS || trojanPassword;
- const hostName = globalThis.hostName;
const {
cleanIPs,
proxyIP,
diff --git a/src/cores/sing-box.js b/src/cores-configs/sing-box.js
similarity index 98%
rename from src/cores/sing-box.js
rename to src/cores-configs/sing-box.js
index f6818fba7..c4b959406 100644
--- a/src/cores/sing-box.js
+++ b/src/cores-configs/sing-box.js
@@ -1,6 +1,5 @@
import { getConfigAddresses, extractWireguardParams, generateRemark, randomUpperCase, getRandomPath } from './helpers.js';
import { configs } from '../helpers/config.js';
-import { isValidUUID } from '../helpers/helpers.js';
let userID = configs.userID;
let trojanPassword = configs.userID;
const defaultHttpsPorts = configs.defaultHttpsPorts;
@@ -550,12 +549,10 @@ export async function getSingBoxWarpConfig (proxySettings, warpConfigs, client)
return config;
}
-export async function getSingBoxCustomConfig(env, proxySettings, isFragment) {
+export async function getSingBoxCustomConfig(env, hostName, proxySettings, isFragment) {
let chainProxyOutbound;
userID = env.UUID || userID;
- if (!isValidUUID(userID)) throw new Error(`Invalid UUID: ${userID}`);
trojanPassword = env.TROJAN_PASS || trojanPassword;
- const hostName = globalThis.hostName;
const {
cleanIPs,
ports,
diff --git a/src/cores/xray.js b/src/cores-configs/xray.js
similarity index 98%
rename from src/cores/xray.js
rename to src/cores-configs/xray.js
index f7085905f..ac1147914 100644
--- a/src/cores/xray.js
+++ b/src/cores-configs/xray.js
@@ -1,4 +1,4 @@
-import { resolveDNS, isDomain, isValidUUID } from '../helpers/helpers.js';
+import { resolveDNS, isDomain } from '../helpers/helpers.js';
import { getConfigAddresses, extractWireguardParams, base64ToDecimal, generateRemark, randomUpperCase, getRandomPath } from './helpers.js';
import { configs } from '../helpers/config.js';
let userID = configs.userID;
@@ -634,11 +634,9 @@ async function buildXrayWorkerLessConfig(proxySettings) {
return config;
}
-export async function getXrayCustomConfigs(env, proxySettings, isFragment) {
+export async function getXrayCustomConfigs(env, hostName, proxySettings, isFragment) {
userID = env.UUID || userID;
- if (!isValidUUID(userID)) throw new Error(`Invalid UUID: ${userID}`);
trojanPassword = env.TROJAN_PASS || trojanPassword;
- const hostName = globalThis.hostName;
let configs = [];
let outbounds = [];
let protocols = [];
@@ -737,7 +735,7 @@ export async function getXrayWarpConfigs (proxySettings, warpConfigs, client) {
const endpointHost = endpoint.split(':')[0];
let warpConfig = buildXrayConfig(proxySettings, `💦 ${index + 1} - Warp${proIndicator}🇮🇷`, false, false, false, undefined, true);
let WoWConfig = buildXrayConfig(proxySettings, `💦 ${index + 1} - WoW${proIndicator}🌍`, false, false, true, undefined, true);
- warpConfig.dns = WoWConfig.dns = await buildXrayDNS(proxySettings, [endpointHost], undefined, false, true);
+ warpConfig.dns = WoWConfig.dns = await buildXrayDNS(proxySettings, [endpointHost], undefined, false, false, true);
warpConfig.routing.rules = buildXrayRoutingRules(proxySettings, [endpointHost], false, false, false);
WoWConfig.routing.rules = buildXrayRoutingRules(proxySettings, [endpointHost], true, false, false);
const warpOutbound = buildXrayWarpOutbound(proxySettings, warpConfigs, endpoint, false, client);
diff --git a/src/helpers/config.js b/src/helpers/config.js
index bc97bd1f5..aa5e9e322 100644
--- a/src/helpers/config.js
+++ b/src/helpers/config.js
@@ -1,7 +1,7 @@
+const proxyIPs = ['bpb.yousef.isegaro.com'];
export const configs = {
userID: '89b3cbba-e6ac-485a-9481-976a0415eab9',
dohURL: 'https://cloudflare-dns.com/dns-query',
- proxyIPs: ['bpb.yousef.isegaro.com'],
proxyIP: proxyIPs[Math.floor(Math.random() * proxyIPs.length)],
trojanPassword: 'bpb-trojan',
defaultHttpPorts: ['80', '8080', '2052', '2082', '2086', '2095', '8880'],
diff --git a/src/kv/handlers.js b/src/kv/handlers.js
index 6d0cfa497..10c29cc9c 100644
--- a/src/kv/handlers.js
+++ b/src/kv/handlers.js
@@ -1,5 +1,7 @@
import { fetchWgConfig } from '../protocols/warp.js';
import { isDomain, resolveDNS } from '../helpers/helpers.js';
+import { configs } from '../helpers/config.js';
+const { panelVersion } = configs;
export async function getDataset(env) {
let proxySettings, warpConfigs;
diff --git a/src/pages/homePage.js b/src/pages/homePage.js
index 30749ded3..1eb9352b3 100644
--- a/src/pages/homePage.js
+++ b/src/pages/homePage.js
@@ -1,12 +1,9 @@
import { configs } from '../helpers/config.js';
-import { isValidUUID } from '../helpers/helpers.js';
const { defaultHttpPorts, defaultHttpsPorts, panelVersion } = configs;
let userID = configs.userID;
-export function renderHomePage (request, env, proxySettings, isPassSet) {
- const hostName = globalThis.hostName;
+export function renderHomePage (request, env, hostName, proxySettings, isPassSet) {
userID = env.UUID || userID;
- if (!isValidUUID(userID)) throw new Error(`Invalid UUID: ${userID}`);
const {
remoteDNS,
localDNS,
@@ -54,7 +51,9 @@ export function renderHomePage (request, env, proxySettings, isPassSet) {
let httpPortsBlock = '', httpsPortsBlock = '';
const allPorts = [...(hostName.includes('workers.dev') ? defaultHttpPorts : []), ...defaultHttpsPorts];
let regionNames = new Intl.DisplayNames(['en'], {type: 'region'});
- const cfCountry = regionNames.of(request.cf.country);
+ const countryCode = request.cf.country;
+ const flag = String.fromCodePoint(...[...countryCode].map(c => 0x1F1E6 + c.charCodeAt(0) - 65));
+ const cfCountry = `${regionNames.of(countryCode)} ${flag}`;
allPorts.forEach(port => {
const id = `port-${port}`;
@@ -93,7 +92,7 @@ export function renderHomePage (request, env, proxySettings, isPassSet) {
--input-background-color: white;
--header-shadow: 2px 2px 4px rgba(0, 0, 0, 0.25);
}
- body { font-family: system-ui; background-color: var(--background-color); color: var(--color) }
+ body { font-family: Twemoji Country Flags, system-ui; background-color: var(--background-color); color: var(--color) }
body.dark-mode {
--color: white;
--primary-color: #09639F;
@@ -1073,7 +1072,11 @@ export function renderHomePage (request, env, proxySettings, isPassSet) {
+
+