diff --git a/src/cores-configs/clash.js b/src/cores-configs/clash.js index 959d8deef..22b041a45 100644 --- a/src/cores-configs/clash.js +++ b/src/cores-configs/clash.js @@ -1,4 +1,4 @@ -import { getConfigAddresses, extractWireguardParams, generateRemark, randomUpperCase, getRandomPath, isIPv6 } from './helpers'; +import { getConfigAddresses, extractWireguardParams, generateRemark, randomUpperCase, getRandomPath, isIPv6, isIPv4 } from './helpers'; import { initializeParams, userID, trojanPassword, hostName, defaultHttpsPorts } from "../helpers/init"; import { getDataset } from '../kv/handlers'; import { renderErrorPage } from '../pages/error'; @@ -15,7 +15,9 @@ async function buildClashDNS (proxySettings, isChain, isWarp) { warpEnableIPv6, bypassIran, bypassChina, - bypassRussia + bypassRussia, + customBypassRules, + customBlockRules } = proxySettings; const warpRemoteDNS = warpEnableIPv6 @@ -23,6 +25,7 @@ async function buildClashDNS (proxySettings, isChain, isWarp) { : ["1.1.1.1", "1.0.0.1"]; const isFakeDNS = (vlessTrojanFakeDNS && !isWarp) || (warpFakeDNS && isWarp); const isIPv6 = (enableIPv6 && !isWarp) || (warpEnableIPv6 && isWarp); + const customBypassRulesDomains = customBypassRules.split(',').filter(address => isDomain(address)); const isBypass = bypassIran || bypassChina || bypassRussia; const bypassRules = [ { rule: bypassIran, geosite: "ir" }, @@ -62,6 +65,13 @@ async function buildClashDNS (proxySettings, isChain, isWarp) { }; } + customBypassRulesDomains.forEach( domain => { + dns["nameserver-policy"] = { + ...dns["nameserver-policy"], + [`+.${domain}`]: [`${localDNS}#DIRECT`] + }; + }); + if (isFakeDNS) Object.assign(dns, { "enhanced-mode": "fake-ip", "fake-ip-range": "198.18.0.1/16", @@ -79,17 +89,22 @@ function buildClashRoutingRules (proxySettings) { bypassRussia, blockAds, blockPorn, - blockUDP443 + blockUDP443, + customBypassRules, + customBlockRules } = proxySettings; + const customBypassRulesTotal = customBypassRules ? customBypassRules.split(',') : []; + const customBlockRulesTotal = customBlockRules ? customBlockRules.split(',') : []; const geoRules = [ { rule: bypassLAN, type: 'direct', + noResolve: true, ruleProvider: { format: "yaml", geosite: "private", - geoip: "private-cidr", + geoip: "private-cidr", geositeURL: "https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/meta/geo/geosite/private.yaml", geoipURL: "https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/meta/geo/geoip/private.yaml" } @@ -100,7 +115,7 @@ function buildClashRoutingRules (proxySettings) { ruleProvider: { format: "text", geosite: "ir", - geoip: "ir-cidr", + geoip: "ir-cidr", geositeURL: "https://raw.githubusercontent.com/Chocolate4U/Iran-clash-rules/release/ir.txt", geoipURL: "https://raw.githubusercontent.com/Chocolate4U/Iran-clash-rules/release/ircidr.txt" } @@ -188,24 +203,48 @@ function buildClashRoutingRules (proxySettings) { } } - const rules = [], ruleProviders = {}; - geoRules.forEach( ({ rule, type, ruleProvider }) => { + const directDomainRules = [], directIPRules = [], blockDomainRules = [], blockIPRules = [], ruleProviders = {}; + geoRules.forEach( ({ rule, type, ruleProvider, noResolve }) => { const { geosite, geoip, geositeURL, geoipURL, format } = ruleProvider; if (rule) { if (geosite) { - rules.push(`RULE-SET,${geosite},${type === 'direct' ? 'DIRECT' : 'REJECT'}`); + const targetRules = type === 'direct' ? directDomainRules : blockDomainRules; + targetRules.push(`RULE-SET,${geosite},${type === 'direct' ? 'DIRECT' : 'REJECT'}`); const ruleProvider = buildRuleProvider(geosite, format, 'domain', geositeURL); Object.assign(ruleProviders, ruleProvider); } if (geoip) { - rules.push(`RULE-SET,${geoip},${type === 'direct' ? 'DIRECT' : 'REJECT'}`); + const targetRules = type === 'direct' ? directIPRules : blockIPRules; + targetRules.push(`RULE-SET,${geoip},${type === 'direct' ? 'DIRECT' : 'REJECT'}${noResolve ? ',no-resolve' : ''}`); const ruleProvider = buildRuleProvider(geoip, format, 'ipcidr', geoipURL); Object.assign(ruleProviders, ruleProvider); } } }); + const generateRule = (address, action) => { + if (isDomain(address)) { + return `DOMAIN-SUFFIX,${address},${action}`; + } else { + const type = isIPv4(address) ? 'IP-CIDR' : 'IP-CIDR6'; + const ip = isIPv6(address) ? address.replace(/\[|\]/g, '') : address; + const cidr = address.includes('/') ? '' : isIPv4(address) ? '/32' : '/128'; + return `${type},${ip}${cidr},${action},no-resolve`; + } + }; + + [...customBypassRulesTotal, ...customBlockRulesTotal].forEach((address, index) => { + const isDirectRule = index < customBypassRulesTotal.length; + const action = isDirectRule ? 'DIRECT' : 'REJECT'; + const targetRules = isDirectRule + ? isDomain(address) ? directDomainRules : directIPRules + : isDomain(address) ? blockDomainRules : blockIPRules; + + targetRules.push(generateRule(address, action)); + }); + + const rules = [...directDomainRules, ...directIPRules, ...blockDomainRules, ...blockIPRules]; blockUDP443 && rules.push("AND,((NETWORK,udp),(DST-PORT,443)),REJECT"); rules.push("MATCH,✅ Selector"); return { rules, ruleProviders }; diff --git a/src/cores-configs/helpers.js b/src/cores-configs/helpers.js index 3cf21dbfb..bca12150b 100644 --- a/src/cores-configs/helpers.js +++ b/src/cores-configs/helpers.js @@ -60,11 +60,11 @@ export function base64ToDecimal (base64) { } export function isIPv4(address) { - const ipv4Pattern = /^(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/; + const ipv4Pattern = /^(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(?:\/([0-9]|[1-2][0-9]|3[0-2]))?$/; return ipv4Pattern.test(address); } export function isIPv6(address) { - const ipv6Pattern = /^\[(?:(?:[a-fA-F0-9]{1,4}:){7}[a-fA-F0-9]{1,4}|(?:[a-fA-F0-9]{1,4}:){1,7}:|::(?:[a-fA-F0-9]{1,4}:){0,7}|(?:[a-fA-F0-9]{1,4}:){1,6}:[a-fA-F0-9]{1,4}|(?:[a-fA-F0-9]{1,4}:){1,5}(?::[a-fA-F0-9]{1,4}){1,2}|(?:[a-fA-F0-9]{1,4}:){1,4}(?::[a-fA-F0-9]{1,4}){1,3}|(?:[a-fA-F0-9]{1,4}:){1,3}(?::[a-fA-F0-9]{1,4}){1,4}|(?:[a-fA-F0-9]{1,4}:){1,2}(?::[a-fA-F0-9]{1,4}){1,5}|[a-fA-F0-9]{1,4}:(?::[a-fA-F0-9]{1,4}){1,6})\]$/; + const ipv6Pattern = /^\[(?:(?:[a-fA-F0-9]{1,4}:){7}[a-fA-F0-9]{1,4}|(?:[a-fA-F0-9]{1,4}:){1,7}:|::(?:[a-fA-F0-9]{1,4}:){0,7}|(?:[a-fA-F0-9]{1,4}:){1,6}:[a-fA-F0-9]{1,4}|(?:[a-fA-F0-9]{1,4}:){1,5}(?::[a-fA-F0-9]{1,4}){1,2}|(?:[a-fA-F0-9]{1,4}:){1,4}(?::[a-fA-F0-9]{1,4}){1,3}|(?:[a-fA-F0-9]{1,4}:){1,3}(?::[a-fA-F0-9]{1,4}){1,4}|(?:[a-fA-F0-9]{1,4}:){1,2}(?::[a-fA-F0-9]{1,4}){1,5}|[a-fA-F0-9]{1,4}:(?::[a-fA-F0-9]{1,4}){1,6})\](?:\/(1[0-1][0-9]|12[0-8]|[0-9]?[0-9]))?$/; return ipv6Pattern.test(address); } \ No newline at end of file diff --git a/src/cores-configs/sing-box.js b/src/cores-configs/sing-box.js index abd3314a1..b237b3a91 100644 --- a/src/cores-configs/sing-box.js +++ b/src/cores-configs/sing-box.js @@ -1,4 +1,4 @@ -import { getConfigAddresses, extractWireguardParams, generateRemark, randomUpperCase, getRandomPath } from './helpers'; +import { getConfigAddresses, extractWireguardParams, generateRemark, randomUpperCase, getRandomPath, isIPv6 } from './helpers'; import { initializeParams, userID, trojanPassword, hostName, defaultHttpsPorts } from "../helpers/init"; import { renderErrorPage } from '../pages/error'; import { getDataset } from '../kv/handlers'; @@ -16,12 +16,16 @@ function buildSingBoxDNS (proxySettings, outboundAddrs, isWarp, remoteDNSDetour) bypassChina, bypassRussia, blockAds, - blockPorn + blockPorn, + customBypassRules, + customBlockRules } = proxySettings; let fakeip; const isFakeDNS = (vlessTrojanFakeDNS && !isWarp) || (warpFakeDNS && isWarp); const isIPv6 = (enableIPv6 && !isWarp) || (warpEnableIPv6 && isWarp); + const customBypassRulesDomains = customBypassRules.split(',').filter(address => isDomain(address)); + const customBlockRulesDomains = customBlockRules.split(',').filter(address => isDomain(address)); const geoRules = [ { rule: bypassIran, type: 'direct', geosite: "geosite-ir", geoip: "geoip-ir" }, { rule: bypassChina, type: 'direct', geosite: "geosite-cn", geoip: "geoip-cn" }, @@ -100,6 +104,30 @@ function buildSingBoxDNS (proxySettings, outboundAddrs, isWarp, remoteDNSDetour) }); rules.push(blockRule); + const createRule = (server) => ({ + domain_suffix: [], + server + }); + + let domainDirectRule, domainBlockRule; + if (customBypassRulesDomains.length) { + domainDirectRule = createRule("dns-direct"); + customBypassRulesDomains.forEach( domain => { + domainDirectRule.domain_suffix.push(domain); + }); + + rules.push(domainDirectRule); + } + + if (customBlockRulesDomains.length) { + domainBlockRule = createRule("dns-block"); + customBlockRulesDomains.forEach( domain => { + domainBlockRule.domain_suffix.push(domain); + }); + + rules.push(domainBlockRule); + } + if (isFakeDNS) { servers.push({ address: "fakeip", @@ -135,11 +163,14 @@ function buildSingBoxRoutingRules (proxySettings) { bypassRussia, blockAds, blockPorn, - blockUDP443 + blockUDP443, + customBypassRules, + customBlockRules } = proxySettings; - const isBypass = bypassIran || bypassChina || bypassRussia; - const rules = [ + const customBypassRulesTotal = customBypassRules ? customBypassRules.split(',') : []; + const customBlockRulesTotal = customBlockRules ? customBlockRules.split(',') : []; + const defaultRules = [ { type: "logical", mode: "or", @@ -241,13 +272,14 @@ function buildSingBoxRoutingRules (proxySettings) { }, ]; - bypassLAN && rules.push({ + const directDomainRules = [], directIPRules = [], blockDomainRules = [], blockIPRules = [], ruleSets = []; + bypassLAN && directIPRules.push({ ip_is_private: true, outbound: "direct" }); - const createRule = (outbound) => ({ - rule_set: [], + const createRule = (rule, outbound) => ({ + [rule]: [], outbound }); @@ -259,28 +291,56 @@ function buildSingBoxRoutingRules (proxySettings) { download_detour: "direct" }; - const directRule = createRule('direct');; - const blockRule = createRule('block'); - const ruleSets = []; + const directDomainRule = createRule('rule_set', 'direct');; + const directIPRule = createRule('rule_set', 'direct');; + const blockDomainRule = createRule('rule_set', 'block'); + const blockIPRule = createRule('rule_set', 'block'); geoRules.forEach(({ rule, type, ruleSet }) => { + if (!rule) return; const { geosite, geoip, geositeURL, geoipURL } = ruleSet; - if (rule) { - if (type === 'direct') { - directRule.rule_set.unshift(geosite); - directRule.rule_set.push(geoip); - } else { - blockRule.rule_set.unshift(geosite); - geoip && blockRule.rule_set.push(geoip); - } - ruleSets.push({...routingRuleSet, tag: geosite, url: geositeURL}); - geoip && ruleSets.push({...routingRuleSet, tag: geoip, url: geoipURL}); - } + const isDirect = type === 'direct'; + const domainRule = isDirect ? directDomainRule : blockDomainRule; + const ipRule = isDirect ? directIPRule : blockIPRule; + + domainRule.rule_set.push(geosite); + ruleSets.push({ ...routingRuleSet, tag: geosite, url: geositeURL }); + if (geoip) { + ipRule.rule_set.push(geoip); + ruleSets.push({ ...routingRuleSet, tag: geoip, url: geoipURL }); + } }); - isBypass && rules.push(directRule); - rules.push(blockRule); + const pushRuleIfNotEmpty = (rule, targetArray) => { + if (rule.rule_set?.length || rule.domain_suffix?.length || rule.ip_cidr?.length) { + targetArray.push(rule); + } + }; + + pushRuleIfNotEmpty(directDomainRule, directDomainRules); + pushRuleIfNotEmpty(directIPRule, directIPRules); + pushRuleIfNotEmpty(blockDomainRule, blockDomainRules); + pushRuleIfNotEmpty(blockIPRule, blockIPRules); + + const processRules = (addresses, action) => { + const domainRule = createRule('domain_suffix', action); + const ipRule = createRule('ip_cidr', action); + addresses.forEach(address => { + if (isDomain(address)) { + domainRule.domain_suffix.push(address); + } else { + const ip = isIPv6(address) ? address.replace(/\[|\]/g, '') : address; + ipRule.ip_cidr.push(ip); + } + }); + pushRuleIfNotEmpty(domainRule, action === 'direct' ? directDomainRules : blockDomainRules); + pushRuleIfNotEmpty(ipRule, action === 'direct' ? directIPRules : blockIPRules); + }; + + customBypassRulesTotal.length && processRules(customBypassRulesTotal, 'direct'); + customBlockRulesTotal.length && processRules(customBlockRulesTotal, 'block'); + const rules = [...defaultRules, ...directDomainRules, ...directIPRules, ...blockDomainRules, ...blockIPRules]; blockUDP443 && rules.push({ network: "udp", port: 443, @@ -288,7 +348,7 @@ function buildSingBoxRoutingRules (proxySettings) { outbound: "block" }); - return {rules: rules, rule_set: ruleSets}; + return {rules, rule_set: ruleSets}; } function buildSingBoxVLESSOutbound (proxySettings, remark, address, port, host, sni, allowInsecure, isFragment) { diff --git a/src/cores-configs/xray.js b/src/cores-configs/xray.js index 7ffc2c533..a360848b5 100644 --- a/src/cores-configs/xray.js +++ b/src/cores-configs/xray.js @@ -4,7 +4,7 @@ import { initializeParams, userID, trojanPassword, hostName, defaultHttpsPorts } import { getDataset } from '../kv/handlers'; import { renderErrorPage } from '../pages/error'; -async function buildXrayDNS (proxySettings, outboundAddrs, domainToStaticIPs, isWorkerLess, isWarp) { +async function buildXrayDNS (proxySettings, outboundAddrs, domainToStaticIPs, isWorkerLess, isWarp) { const { remoteDNS, resolvedRemoteDNS, @@ -17,11 +17,11 @@ async function buildXrayDNS (proxySettings, outboundAddrs, domainToStaticIPs, is bypassIran, bypassChina, blockPorn, - bypassRussia + bypassRussia, + customBypassRules, + customBlockRules } = proxySettings; - const isBypass = bypassIran || bypassChina || bypassRussia; - const isBlock = blockAds || blockPorn; const bypassRules = [ { rule: bypassIran, domain: "geosite:category-ir", ip: "geoip:ir" }, { rule: bypassChina, domain: "geosite:cn", ip: "geoip:cn" }, @@ -37,9 +37,12 @@ async function buildXrayDNS (proxySettings, outboundAddrs, domainToStaticIPs, is const isFakeDNS = (vlessTrojanFakeDNS && !isWarp) || (warpFakeDNS && isWarp); const isIPv6 = (enableIPv6 && !isWarp) || (warpEnableIPv6 && isWarp); const outboundDomains = outboundAddrs.filter(address => isDomain(address)); - const uniqueDomains = [...new Set(outboundDomains)]; - const isOutboundRule = uniqueDomains.length > 0; - const outboundRules = uniqueDomains.map(domain => `full:${domain}`); + const customBypassRulesDomains = customBypassRules.split(',').filter(address => isDomain(address)); + const customBlockRulesDomains = customBlockRules.split(',').filter(address => isDomain(address)); + const uniqueOutboundDomains = [...new Set(outboundDomains)]; + const isDomainRule = [...uniqueOutboundDomains, ...customBypassRulesDomains].length > 0; + const isBypass = bypassIran || bypassChina || bypassRussia; + const isBlock = blockAds || blockPorn || customBlockRulesDomains.length > 0; const finalRemoteDNS = isWorkerLess ? ["https://cloudflare-dns.com/dns-query"] : isWarp @@ -49,9 +52,14 @@ async function buildXrayDNS (proxySettings, outboundAddrs, domainToStaticIPs, is : [remoteDNS]; const dnsHost = {}; - isBlock && blockRules.forEach( ({ rule, host }) => { - if (rule) dnsHost[host] = ["127.0.0.1"]; - }); + if (isBlock) { + blockRules.forEach( ({ rule, host }) => { + if (rule) dnsHost[host] = ["127.0.0.1"]; + }); + customBlockRulesDomains.forEach( domain => { + dnsHost[`domain:${domain}`] = ["127.0.0.1"]; + }); + } const staticIPs = domainToStaticIPs ? await resolveDNS(domainToStaticIPs) : undefined; if (staticIPs) dnsHost[domainToStaticIPs] = enableIPv6 ? [...staticIPs.ipv4, ...staticIPs.ipv6] : staticIPs.ipv4; @@ -75,11 +83,15 @@ async function buildXrayDNS (proxySettings, outboundAddrs, domainToStaticIPs, is tag: "dns", }; - isOutboundRule && dnsObject.servers.push({ - address: localDNS, - domains: outboundRules, - skipFallback: true - }); + if (isDomainRule) { + const outboundDomainRules = uniqueOutboundDomains.map(domain => `full:${domain}`); + const bypassDomainRules = customBypassRulesDomains.map(domain => `domain:${domain}`); + dnsObject.servers.push({ + address: localDNS, + domains: [...outboundDomainRules, ...bypassDomainRules], + skipFallback: true + }); + } const localDNSServer = { address: localDNS, @@ -119,12 +131,12 @@ function buildXrayRoutingRules (proxySettings, outboundAddrs, isChain, isBalance bypassRussia, blockAds, blockPorn, - blockUDP443 + blockUDP443, + customBypassRules, + customBlockRules } = proxySettings; - const isBlock = blockAds || blockPorn; - const isBypass = bypassIran || bypassChina || bypassRussia; - const geoRules = [ + const geoRules = [ { rule: bypassLAN, type: 'direct', domain: "geosite:private", ip: "geoip:private" }, { rule: bypassIran, type: 'direct', domain: "geosite:category-ir", ip: "geoip:ir" }, { rule: bypassChina, type: 'direct', domain: "geosite:cn", ip: "geoip:cn" }, @@ -133,7 +145,12 @@ function buildXrayRoutingRules (proxySettings, outboundAddrs, isChain, isBalance { rule: blockPorn, type: 'block', domain: "geosite:category-porn" } ]; const outboundDomains = outboundAddrs.filter(address => isDomain(address)); - const isOutboundRule = outboundDomains.length > 0; + const customBypassRulesTotal = customBypassRules ? customBypassRules.split(',') : []; + const customBlockRulesTotal = customBlockRules ? customBlockRules.split(',') : []; + const customBypassRulesDomains = customBypassRulesTotal.filter(address => isDomain(address)); + const isDomainRule = [...outboundDomains, ...customBypassRulesDomains].length > 0; + const isBlock = blockAds || blockPorn || customBlockRulesTotal.length > 0; + const isBypass = bypassIran || bypassChina || bypassRussia || customBypassRulesTotal.length > 0; const rules = [ { inboundTag: [ @@ -153,7 +170,7 @@ function buildXrayRoutingRules (proxySettings, outboundAddrs, isChain, isBalance } ]; - if (!isWorkerLess && (isOutboundRule || isBypass)) rules.push({ + if (!isWorkerLess && (isDomainRule || isBypass)) rules.push({ ip: [localDNS], port: "53", network: "udp", @@ -168,26 +185,48 @@ function buildXrayRoutingRules (proxySettings, outboundAddrs, isChain, isBalance type: "field" }); - let geositeDirectRule, geoipDirectRule; + let domainDirectRule, ipDirectRule; if (!isWorkerLess) { - geositeDirectRule = createRule("domain", "direct"); - geoipDirectRule = createRule("ip", "direct"); + domainDirectRule = createRule("domain", "direct"); + ipDirectRule = createRule("ip", "direct"); } - let geositeBlockRule = createRule("domain", "block"); + let domainBlockRule = createRule("domain", "block"); + let ipBlockRule = createRule("ip", "block"); geoRules.forEach(({ rule, type, domain, ip }) => { if (rule) { if (type === 'direct') { - geositeDirectRule?.domain.push(domain); - geoipDirectRule?.ip?.push(ip); + domainDirectRule?.domain.push(domain); + ipDirectRule?.ip?.push(ip); } else { - geositeBlockRule.domain.push(domain); + domainBlockRule.domain.push(domain); } } }); + + customBypassRulesTotal.forEach( address => { + if (isDomain(address)) { + domainDirectRule?.domain.push(`domain:${address}`); + } else { + ipDirectRule?.ip.push(address); + } + }); + + customBlockRulesTotal.forEach( address => { + if (isDomain(address)) { + domainBlockRule.domain.push(`domain:${address}`); + } else { + ipBlockRule.ip.push(address); + } + }); - !isWorkerLess && isBypass && rules.push(geositeDirectRule, geoipDirectRule); - isBlock && rules.push(geositeBlockRule); + if (!isWorkerLess) { + domainDirectRule.domain.length && rules.push(domainDirectRule); + ipDirectRule.ip.length && rules.push(ipDirectRule); + } + + domainBlockRule.domain.length && rules.push(domainBlockRule); + ipBlockRule.ip.length && rules.push(ipBlockRule); } blockUDP443 && rules.push({ diff --git a/src/helpers/init.js b/src/helpers/init.js index ec1a213d4..0b8b8d0fa 100644 --- a/src/helpers/init.js +++ b/src/helpers/init.js @@ -11,7 +11,7 @@ function initParams(request, env) { trojanPassword = env.TROJAN_PASS || 'bpb-trojan'; defaultHttpPorts = ['80', '8080', '2052', '2082', '2086', '2095', '8880']; defaultHttpsPorts = ['443', '8443', '2053', '2083', '2087', '2096']; - panelVersion = '2.7.2'; + panelVersion = '2.7.3'; hostName = request.headers.get('Host'); const url = new URL(request.url); const searchParams = new URLSearchParams(url.search); diff --git a/src/kv/handlers.js b/src/kv/handlers.js index 3a48adacf..7eb801e99 100644 --- a/src/kv/handlers.js +++ b/src/kv/handlers.js @@ -103,6 +103,8 @@ export async function updateDataset (request, env) { blockAds: validateField('block-ads') ?? currentSettings?.blockAds ?? false, blockPorn: validateField('block-porn') ?? currentSettings?.blockPorn ?? false, blockUDP443: validateField('block-udp-443') ?? currentSettings?.blockUDP443 ?? false, + customBypassRules: validateField('customBypassRules')?.replaceAll(' ', '') ?? currentSettings?.customBypassRules ?? '', + customBlockRules: validateField('customBlockRules')?.replaceAll(' ', '') ?? currentSettings?.customBlockRules ?? '', warpEndpoints: validateField('warpEndpoints')?.replaceAll(' ', '') ?? currentSettings?.warpEndpoints ?? 'engage.cloudflareclient.com:2408', warpFakeDNS: validateField('warpFakeDNS') ?? currentSettings?.warpFakeDNS ?? false, warpEnableIPv6: validateField('warpEnableIPv6') ?? currentSettings?.warpEnableIPv6 ?? true, diff --git a/src/pages/home.js b/src/pages/home.js index 1fe5cb132..2538e891b 100644 --- a/src/pages/home.js +++ b/src/pages/home.js @@ -41,7 +41,9 @@ export async function renderHomePage (request, env, proxySettings, isPassSet) { bypassRussia, blockAds, blockPorn, - blockUDP443 + blockUDP443, + customBypassRules, + customBlockRules } = proxySettings; const isWarpPlus = warpPlusLicense ? true : false; @@ -147,7 +149,7 @@ export async function renderHomePage (request, env, proxySettings, isPassSet) { summary::marker { font-size: 1.5rem; color: var(--secondary-color); } summary h2 { display: inline-flex; } h1 { font-size: 2.5em; text-align: center; color: var(--header-color); text-shadow: var(--header-shadow); } - h2 { margin: 30px 0; text-align: center; color: var(--hr-text-color); } + h2,h3 { margin: 30px 0; text-align: center; color: var(--hr-text-color); } hr { border: 1px solid var(--border-color); margin: 20px 0; } .footer { display: flex; @@ -412,7 +414,7 @@ export async function renderHomePage (request, env, proxySettings, isPassSet) {