Skip to content

Commit

Permalink
Refactore, UI changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
bia-pain-bache committed Nov 30, 2024
1 parent c62c713 commit 19c3a24
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
2 changes: 0 additions & 2 deletions src/authentication/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ export async function resetPassword(request, env) {
}

export async function login(request, env) {
// await initializeParams(request, env);
if (typeof env.bpb !== 'object') throw new Error('KV Dataset is not properly set!', { cause: "init"});
const auth = await Authenticate(request, env);
if (auth) return Response.redirect(`${globalThis.urlOrigin}/panel`, 302);
if (request.method === 'POST') return await generateJWTToken(request, env);
Expand Down
1 change: 0 additions & 1 deletion src/cores-configs/xray.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { resolveDNS, isDomain } from '../helpers/helpers';
import { getConfigAddresses, extractWireguardParams, base64ToDecimal, generateRemark, randomUpperCase, getRandomPath } from './helpers';
// import { initializeParams, globalThis.userID, globalThis.trojanPassword, globalThis.hostName, globalThis.defaultHttpsPorts } from "../helpers/init";
import { getDataset } from '../kv/handlers';

async function buildXrayDNS (proxySettings, outboundAddrs, domainToStaticIPs, isWorkerLess, isWarp) {
Expand Down
4 changes: 3 additions & 1 deletion src/helpers/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ export function initializeParams(request, env) {
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 (!userID || !trojanPassword) throw new Error(`Please set UUID and Trojan password first. Please go to 🟢 https://${hostName}/secrets 🟢`, { 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"});
}

}
3 changes: 0 additions & 3 deletions src/kv/handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ import { Authenticate } from '../authentication/auth';

export async function getDataset(request, env) {
let proxySettings, warpConfigs;
if (typeof env.bpb !== 'object') {
throw new Error('KV Dataset is not properly set!', { cause: "init"});
}

try {
proxySettings = await env.bpb.get("proxySettings", {type: 'json'});
Expand Down
14 changes: 10 additions & 4 deletions src/pages/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ export async function renderHomePage (proxySettings, isPassSet) {
</div>
<div class="form-control">
<label for="scanner">🔎 Clean IP Scanner</label>
<a href="https://github.com/bia-pain-bache/Cloudflare-Clean-IP-Scanner/releases/tag/v2.2.5" name="scanner" target="_blank" style="width: 100%;">
<a href="${atob("aHR0cHM6Ly9naXRodWIuY29tL2JpYS1wYWluLWJhY2hl")}/Cloudflare-Clean-IP-Scanner/releases/tag/v2.2.5" name="scanner" target="_blank" style="width: 100%;">
<button type="button" id="scanner" class="button">
Download Scanner
<span class="material-symbols-outlined">open_in_new</span>
Expand Down Expand Up @@ -531,7 +531,7 @@ export async function renderHomePage (proxySettings, isPassSet) {
</div>
<div class="form-control">
<label for="endpointScanner" style="line-height: 1.5;">🔎 Scan Endpoint</label>
<button type="button" id="endpointScanner" class="button" style="padding: 10px 0;" onclick="copyToClipboard('bash <(curl -fsSL https://raw.githubusercontent.com/bia-pain-bache/warp-script/refs/heads/main/endip/install.sh)', false)">
<button type="button" id="endpointScanner" class="button" style="padding: 10px 0;" onclick="copyToClipboard('bash <(curl -fsSL ${atob("aHR0cHM6Ly9yYXcuZ2l0aHVidXNlcmNvbnRlbnQuY29tL2JpYS1wYWluLWJhY2hl")}/warp-script/refs/heads/main/endip/install.sh)', false)">
Copy Script<span class="material-symbols-outlined">terminal</span>
</button>
</div>
Expand Down Expand Up @@ -851,7 +851,7 @@ export async function renderHomePage (proxySettings, isPassSet) {
<hr>
<div class="header-container">
<h2 style="margin: 0 5px;">💡 MY IP</h2>
<button type="button" id="resetSettings" onclick="fetchIPInfo()" style="background: none; margin: 0; border: none; cursor: pointer;">
<button type="button" id="refresh-geo-location" onclick="fetchIPInfo()" style="background: none; margin: 0; border: none; cursor: pointer;">
<i class="fa fa-refresh fa-2x" style="color: var(--button-color);" aria-hidden="true"></i>
</button>
</div>
Expand Down Expand Up @@ -883,7 +883,7 @@ export async function renderHomePage (proxySettings, isPassSet) {
<hr>
<div class="footer">
<i class="fa fa-github" style="font-size:36px; margin-right: 10px;"></i>
<a class="link" href="https://github.com/bia-pain-bache/BPB-Worker-Panel" style="color: var(--color); text-decoration: underline;" target="_blank">Github</a>
<a class="link" href="${atob('aHR0cHM6Ly9naXRodWIuY29tL2JpYS1wYWluLWJhY2hlL0JQQi1Xb3JrZXItUGFuZWw=')}" style="color: var(--color); text-decoration: underline;" target="_blank">Github</a>
<button id="openModalBtn" class="button">Change Password</button>
<button type="button" id="logout" style="background: none; color: var(--color); margin: 0; border: none; cursor: pointer;">
<i class="fa fa-power-off fa-2x" aria-hidden="true"></i>
Expand Down Expand Up @@ -1025,6 +1025,10 @@ export async function renderHomePage (proxySettings, isPassSet) {
document.getElementById(cfIP ? 'cf-isp' : 'isp').textContent = isp;
};
const refreshIcon = document.getElementById("refresh-geo-location").querySelector('i');
refreshIcon.classList.add('fa-spin');
document.body.style.cursor = 'wait';
try {
const ipResponse = await fetch('https://ipwho.is/' + '?nocache=' + Date.now(), { cache: "no-store" });
const ipResponseObj = await ipResponse.json();
Expand All @@ -1042,6 +1046,8 @@ export async function renderHomePage (proxySettings, isPassSet) {
});
const cfIPGeoLocation = await cfGeoResponse.json();
updateUI(cfIP, cfIPGeoLocation.country, cfIPGeoLocation.countryCode, cfIPGeoLocation.city, cfIPGeoLocation.isp, true);
refreshIcon.classList.remove('fa-spin');
document.body.style.cursor = 'default';
} catch (error) {
console.error('Error fetching IP address:', error);
}
Expand Down
2 changes: 0 additions & 2 deletions src/worker.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// https://github.com/bia-pain-bache/BPB-Worker-Panel

import { initializeParams } from './helpers/init';
import { vlessOverWSHandler } from './protocols/vless';
import { trojanOverWSHandler } from './protocols/trojan';
Expand Down

0 comments on commit 19c3a24

Please sign in to comment.