@@ -916,6 +916,49 @@ const buildProxyOutbound = async (proxyParams) => {
916
916
return proxyOutbound ;
917
917
}
918
918
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
+
919
962
const getFragmentConfigs = async ( env , hostName , client ) => {
920
963
let Configs = [ ] ;
921
964
let outbounds = [ ] ;
@@ -977,8 +1020,8 @@ const getFragmentConfigs = async (env, hostName, client) => {
977
1020
fragConfig . remarks = remark . length <= 30 ? remark : `${ remark . slice ( 0 , 29 ) } ...` ; ;
978
1021
fragConfig . dns . servers [ 0 ] = remoteDNS ;
979
1022
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 } ` ;
982
1025
fragConfig . routing . rules [ 0 ] . ip = [ localDNS ] ;
983
1026
984
1027
if ( proxyOutbound ) {
@@ -1034,8 +1077,8 @@ const getFragmentConfigs = async (env, hostName, client) => {
1034
1077
bestPing . remarks = '💦 BPB Frag - Best Ping 💥' ;
1035
1078
bestPing . dns . servers [ 0 ] = remoteDNS ;
1036
1079
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 } ` ;
1039
1082
bestPing . routing . rules [ 0 ] . ip = [ localDNS ] ;
1040
1083
bestPing . outbounds = [ ...outbounds , ...bestPing . outbounds ] ;
1041
1084
@@ -1065,10 +1108,12 @@ const getFragmentConfigs = async (env, hostName, client) => {
1065
1108
bestPing . inbounds [ 1 ] . port = 2081 ;
1066
1109
}
1067
1110
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
+ ) ;
1072
1117
1073
1118
return Configs ;
1074
1119
}
@@ -2092,22 +2137,6 @@ const xrayConfigTemp = {
2092
2137
loglevel : "warning" ,
2093
2138
} ,
2094
2139
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
- } ,
2111
2140
{
2112
2141
tag : "fragment" ,
2113
2142
protocol : "freedom" ,
@@ -2124,6 +2153,22 @@ const xrayConfigTemp = {
2124
2153
tcpNoDelay : true
2125
2154
} ,
2126
2155
} ,
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" ,
2127
2172
}
2128
2173
] ,
2129
2174
policy : {
0 commit comments