Skip to content

Commit 5181d2d

Browse files
Added WorkerLess config.
1 parent abfcf2d commit 5181d2d

File tree

1 file changed

+69
-24
lines changed

1 file changed

+69
-24
lines changed

_worker.js

+69-24
Original file line numberDiff line numberDiff line change
@@ -916,6 +916,49 @@ const buildProxyOutbound = async (proxyParams) => {
916916
return proxyOutbound;
917917
}
918918

919+
const buildWorkerLessConfig = async (env, client) => {
920+
let proxySettings = await env.bpb.get("proxySettings", {type: 'json'});
921+
const { remoteDNS, lengthMin, lengthMax, intervalMin, intervalMax, blockAds } = proxySettings;
922+
923+
let fakeOutbound = structuredClone(xrayOutboundTemp);
924+
delete fakeOutbound.mux;
925+
fakeOutbound.settings.vnext[0].address = 'google.com';
926+
fakeOutbound.settings.vnext[0].users[0].id = userID;
927+
delete fakeOutbound.streamSettings.sockopt;
928+
fakeOutbound.streamSettings.tlsSettings.serverName = 'google.com';
929+
fakeOutbound.streamSettings.wsSettings.headers.Host = 'google.com';
930+
fakeOutbound.streamSettings.wsSettings.path = '/?ed=2560';
931+
delete fakeOutbound.streamSettings.grpcSettings;
932+
delete fakeOutbound.streamSettings.tcpSettings;
933+
delete fakeOutbound.streamSettings.realitySettings;
934+
fakeOutbound.tag = 'fake-outbound';
935+
936+
let fragConfig = structuredClone(xrayConfigTemp);
937+
fragConfig.remarks = '💦 BPB Frag - WorkerLess ⭐'
938+
fragConfig.dns.servers[0] = remoteDNS;
939+
fragConfig.dns.servers.pop();
940+
fragConfig.outbounds[0].settings.domainStrategy = 'UseIP';
941+
fragConfig.outbounds[0].settings.fragment.length = `${lengthMin}-${lengthMax}`;
942+
fragConfig.outbounds[0].settings.fragment.interval = `${intervalMin}-${intervalMax}`;
943+
fragConfig.outbounds = [...fragConfig.outbounds, {...fakeOutbound}];
944+
fragConfig.routing.rules.pop();
945+
if (!blockAds) {
946+
delete fragConfig.dns.hosts;
947+
fragConfig.routing.rules.pop();
948+
}
949+
fragConfig.routing.rules[1].domain = ["domain:.ir"];
950+
fragConfig.routing.rules.shift();
951+
delete fragConfig.routing.balancers;
952+
delete fragConfig.observatory;
953+
954+
if (client === 'nekoray') {
955+
fragConfig.inbounds[0].port = 2080;
956+
fragConfig.inbounds[1].port = 2081;
957+
}
958+
959+
return fragConfig;
960+
}
961+
919962
const getFragmentConfigs = async (env, hostName, client) => {
920963
let Configs = [];
921964
let outbounds = [];
@@ -977,8 +1020,8 @@ const getFragmentConfigs = async (env, hostName, client) => {
9771020
fragConfig.remarks = remark.length <= 30 ? remark : `${remark.slice(0,29)}...`;;
9781021
fragConfig.dns.servers[0] = remoteDNS;
9791022
fragConfig.dns.servers[1].address = localDNS;
980-
fragConfig.outbounds[2].settings.fragment.length = `${lengthMin}-${lengthMax}`;
981-
fragConfig.outbounds[2].settings.fragment.interval = `${intervalMin}-${intervalMax}`;
1023+
fragConfig.outbounds[0].settings.fragment.length = `${lengthMin}-${lengthMax}`;
1024+
fragConfig.outbounds[0].settings.fragment.interval = `${intervalMin}-${intervalMax}`;
9821025
fragConfig.routing.rules[0].ip = [localDNS];
9831026

9841027
if (proxyOutbound) {
@@ -1034,8 +1077,8 @@ const getFragmentConfigs = async (env, hostName, client) => {
10341077
bestPing.remarks = '💦 BPB Frag - Best Ping 💥';
10351078
bestPing.dns.servers[0] = remoteDNS;
10361079
bestPing.dns.servers[1].address = localDNS;
1037-
bestPing.outbounds[2].settings.fragment.length = `${lengthMin}-${lengthMax}`;
1038-
bestPing.outbounds[2].settings.fragment.interval = `${intervalMin}-${intervalMax}`;
1080+
bestPing.outbounds[0].settings.fragment.length = `${lengthMin}-${lengthMax}`;
1081+
bestPing.outbounds[0].settings.fragment.interval = `${intervalMin}-${intervalMax}`;
10391082
bestPing.routing.rules[0].ip = [localDNS];
10401083
bestPing.outbounds = [...outbounds, ...bestPing.outbounds];
10411084

@@ -1065,10 +1108,12 @@ const getFragmentConfigs = async (env, hostName, client) => {
10651108
bestPing.inbounds[1].port = 2081;
10661109
}
10671110

1068-
Configs.push({
1069-
address: "Best-Ping",
1070-
config: bestPing,
1071-
});
1111+
const workerLessConfig = await buildWorkerLessConfig(env, client);
1112+
1113+
Configs.push(
1114+
{ address: 'Best-Ping', config: bestPing},
1115+
{ address: 'WorkerLess', config: workerLessConfig}
1116+
);
10721117

10731118
return Configs;
10741119
}
@@ -2092,22 +2137,6 @@ const xrayConfigTemp = {
20922137
loglevel: "warning",
20932138
},
20942139
outbounds: [
2095-
{
2096-
protocol: "freedom",
2097-
settings: {
2098-
domainStrategy: "UseIP",
2099-
},
2100-
tag: "direct",
2101-
},
2102-
{
2103-
protocol: "blackhole",
2104-
settings: {
2105-
response: {
2106-
type: "http",
2107-
},
2108-
},
2109-
tag: "block",
2110-
},
21112140
{
21122141
tag: "fragment",
21132142
protocol: "freedom",
@@ -2124,6 +2153,22 @@ const xrayConfigTemp = {
21242153
tcpNoDelay: true
21252154
},
21262155
},
2156+
},
2157+
{
2158+
protocol: "freedom",
2159+
settings: {
2160+
domainStrategy: "UseIP",
2161+
},
2162+
tag: "direct",
2163+
},
2164+
{
2165+
protocol: "blackhole",
2166+
settings: {
2167+
response: {
2168+
type: "http",
2169+
},
2170+
},
2171+
tag: "block",
21272172
}
21282173
],
21292174
policy: {

0 commit comments

Comments
 (0)