@@ -17,7 +17,7 @@ let proxyIP = proxyIPs[Math.floor(Math.random() * proxyIPs.length)];
17
17
18
18
let dohURL = 'https://cloudflare-dns.com/dns-query' ;
19
19
20
- let panelVersion = '2.3.2 ' ;
20
+ let panelVersion = '2.3.3 ' ;
21
21
22
22
if ( ! isValidUUID ( userID ) ) {
23
23
throw new Error ( 'uuid is not valid' ) ;
@@ -74,7 +74,7 @@ export default {
74
74
case '/panel' :
75
75
76
76
if ( ! env . bpb ) {
77
- const errorPage = getErrorPage ( 'KV Dataset is not properly set!' ) ;
77
+ const errorPage = renderErrorPage ( 'KV Dataset is not properly set!' ) ;
78
78
return new Response ( errorPage , { status : 200 , headers : { 'Content-Type' : 'text/html' } } ) ;
79
79
}
80
80
@@ -118,7 +118,7 @@ export default {
118
118
case '/login' :
119
119
120
120
if ( ! env . bpb ) {
121
- const errorPage = getErrorPage ( 'KV Dataset is not properly set!' ) ;
121
+ const errorPage = renderErrorPage ( 'KV Dataset is not properly set!' ) ;
122
122
return new Response ( errorPage , { status : 200 , headers : { 'Content-Type' : 'text/html' } } ) ;
123
123
}
124
124
@@ -221,7 +221,7 @@ export default {
221
221
}
222
222
} catch ( err ) {
223
223
/** @type {Error } */ let e = err ;
224
- const errorPage = getErrorPage ( 'Something went wrong!' , e . toString ( ) ) ;
224
+ const errorPage = renderErrorPage ( 'Something went wrong!' , e . toString ( ) ) ;
225
225
return new Response ( errorPage , { status : 200 , headers : { 'Content-Type' : 'text/html' } } ) ;
226
226
}
227
227
} ,
@@ -991,10 +991,15 @@ const getFragmentConfigs = async (env, hostName, client) => {
991
991
delete fragConfig . routing . balancers ;
992
992
fragConfig . routing . rules . pop ( ) ;
993
993
994
+ if ( localDNS === 'localhost' && bypassIran ) {
995
+ fragConfig . dns . servers . pop ( ) ;
996
+ fragConfig . routing . rules . splice ( 0 , 1 ) ;
997
+ }
998
+
994
999
if ( ! bypassIran ) {
995
1000
fragConfig . dns . servers . pop ( ) ;
996
- fragConfig . routing . rules . splice ( 1 , 1 ) ;
997
- fragConfig . routing . rules [ 1 ] . ip = [ "geoip:private" ] ;
1001
+ fragConfig . routing . rules . splice ( 0 , 2 ) ;
1002
+ fragConfig . routing . rules [ 0 ] . ip = [ "geoip:private" ] ;
998
1003
}
999
1004
1000
1005
if ( ! blockAds ) {
@@ -1038,11 +1043,16 @@ const getFragmentConfigs = async (env, hostName, client) => {
1038
1043
delete bestPing . dns . hosts ;
1039
1044
bestPing . routing . rules . splice ( 3 , 1 ) ;
1040
1045
}
1046
+
1047
+ if ( localDNS === 'localhost' && bypassIran ) {
1048
+ bestPing . dns . servers . pop ( ) ;
1049
+ bestPing . routing . rules . splice ( 0 , 1 ) ;
1050
+ }
1041
1051
1042
1052
if ( ! bypassIran ) {
1043
1053
bestPing . dns . servers . pop ( ) ;
1044
- bestPing . routing . rules . splice ( 1 , 1 ) ;
1045
- bestPing . routing . rules [ 1 ] . ip = [ "geoip:private" ] ;
1054
+ bestPing . routing . rules . splice ( 0 , 2 ) ;
1055
+ bestPing . routing . rules [ 0 ] . ip = [ "geoip:private" ] ;
1046
1056
}
1047
1057
1048
1058
if ( proxyOutbound ) {
@@ -1477,7 +1487,7 @@ const renderHomePage = async (env, hostName, fragConfigs) => {
1477
1487
<div class="form-control">
1478
1488
<label for="localDNS">🏚️ Local DNS</label>
1479
1489
<input type="text" id="localDNS" name="localDNS" value="${ localDNS } "
1480
- pattern="^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$"
1490
+ pattern="^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)|localhost $"
1481
1491
title="Please enter a valid DNS IP Address!" required>
1482
1492
</div>
1483
1493
<div class="form-control">
@@ -2013,6 +2023,43 @@ const renderLoginPage = async () => {
2013
2023
return html ;
2014
2024
}
2015
2025
2026
+ const renderErrorPage = ( message , error ) => {
2027
+ return `
2028
+ <!DOCTYPE html>
2029
+ <html lang="en">
2030
+
2031
+ <head>
2032
+ <meta charset="UTF-8">
2033
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
2034
+ <title>Error Page</title>
2035
+ <style>
2036
+ body,
2037
+ html {
2038
+ height: 100%;
2039
+ margin: 0;
2040
+ display: flex;
2041
+ justify-content: center;
2042
+ align-items: center;
2043
+ font-family: system-ui;
2044
+ }
2045
+ h1 { text-align: center; color: #2980b9; font-size: 2.5rem; }
2046
+ #error-container { text-align: center; }
2047
+ </style>
2048
+ </head>
2049
+
2050
+ <body>
2051
+ <div id="error-container">
2052
+ <h1>BPB Panel <span style="font-size: smaller;">${ panelVersion } </span> 💦</h1>
2053
+ <div id="error-message">
2054
+ <h2>${ message } Please try again or refer to <a href="https://github.com/bia-pain-bache/BPB-Worker-Panel/blob/main/README.md">documents</a></h2>
2055
+ <p><b>${ error ? `⚠️ ${ error } ` : '' } </b></p>
2056
+ </div>
2057
+ </div>
2058
+ </body>
2059
+
2060
+ </html>` ;
2061
+ }
2062
+
2016
2063
const xrayConfigTemp = {
2017
2064
remarks : "" ,
2018
2065
dns : {
@@ -2025,6 +2072,7 @@ const xrayConfigTemp = {
2025
2072
{
2026
2073
address : "" ,
2027
2074
domains : [ "geosite:category-ir" , "domain:.ir" ] ,
2075
+ expectIPs : [ "geoip:ir" ] ,
2028
2076
port : 53
2029
2077
} ,
2030
2078
] ,
@@ -2478,41 +2526,4 @@ const singboxOutboundTemp = {
2478
2526
type : "ws"
2479
2527
} ,
2480
2528
tag : ""
2481
- } ;
2482
-
2483
- const getErrorPage = ( message , error ) => {
2484
- return `
2485
- <!DOCTYPE html>
2486
- <html lang="en">
2487
-
2488
- <head>
2489
- <meta charset="UTF-8">
2490
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
2491
- <title>Error Page</title>
2492
- <style>
2493
- body,
2494
- html {
2495
- height: 100%;
2496
- margin: 0;
2497
- display: flex;
2498
- justify-content: center;
2499
- align-items: center;
2500
- font-family: system-ui;
2501
- }
2502
- h1 { text-align: center; color: #2980b9; font-size: 2.5rem; }
2503
- #error-container { text-align: center; }
2504
- </style>
2505
- </head>
2506
-
2507
- <body>
2508
- <div id="error-container">
2509
- <h1>BPB Panel <span style="font-size: smaller;">${ panelVersion } </span> 💦</h1>
2510
- <div id="error-message">
2511
- <h2>${ message } Please try again or refer to <a href="https://github.com/bia-pain-bache/BPB-Worker-Panel/blob/main/README.md">documents</a></h2>
2512
- <p><b>${ error ? `⚠️ ${ error } ` : '' } </b></p>
2513
- </div>
2514
- </div>
2515
- </body>
2516
-
2517
- </html>` ;
2518
- }
2529
+ } ;
0 commit comments