@@ -9,7 +9,7 @@ let id = base64Decode('ZWM4NzJkOGYtNzJiMC00YTA0LWI2MTItMDMyN2Q4NWUxOGVk');
99let uuid ;
1010let host ;
1111
12- let paddr ;
12+ // let paddr;
1313
1414let s5 = '' ;
1515let socks5Enable = false ;
@@ -140,9 +140,9 @@ async function mainHandler({ req, url, headers, res, env }) {
140140 proxyIPsAll . push ( ...fromKv ) ;
141141 }
142142 proxyIPsAll = [ ...new Set ( proxyIPsAll ) ] ;
143- if ( proxyIPsAll . length > 0 ) {
144- paddr = proxyIPsAll [ Math . floor ( Math . random ( ) * proxyIPsAll . length ) ] ;
145- }
143+ // if (proxyIPsAll.length > 0) {
144+ // paddr = proxyIPsAll[Math.floor(Math.random() * proxyIPsAll.length)];
145+ // }
146146
147147 nat64 = url . searchParams . get ( 'NAT64' ) || getEnvVar ( 'NAT64' , env ) || NAT64 || nat64 ;
148148 const nat64PrefixUrl = url . searchParams . get ( 'NAT64_PREFIX' ) || getEnvVar ( 'NAT64_PREFIX' , env ) ;
@@ -200,10 +200,18 @@ async function mainHandler({ req, url, headers, res, env }) {
200200 return sendResponse ( html , userAgent , res ) ;
201201 }
202202 if ( url . pathname === `/${ id } ` ) {
203+ let paddr ;
204+ if ( proxyIPsAll . length > 0 ) {
205+ paddr = proxyIPsAll [ Math . floor ( Math . random ( ) * proxyIPsAll . length ) ] ;
206+ }
203207 const html = await getConfig ( rawHost , uuid , host , paddr , parsedSocks5 , userAgent , url , protType , nat64 , hostRemark ) ;
204208 return sendResponse ( html , userAgent , res ) ;
205209 }
206210 if ( url . pathname === `/${ fakeUserId } ` ) {
211+ let paddr ;
212+ if ( proxyIPsAll . length > 0 ) {
213+ paddr = proxyIPsAll [ Math . floor ( Math . random ( ) * proxyIPsAll . length ) ] ;
214+ }
207215 const html = await getConfig ( rawHost , uuid , host , paddr , parsedSocks5 , 'CF-FAKE-UA' , url , protType , nat64 , hostRemark ) ;
208216 return sendResponse ( html , 'CF-FAKE-UA' , res ) ;
209217 }
@@ -676,7 +684,7 @@ async function getConfig(rawHost, userId, host, proxyIP, parsedSocks5, userAgent
676684 const ipUrlTxtAndCsv = await getIpUrlTxtAndCsv ( noTLS , ipUrlTxt , ipUrlCsv , num ) ;
677685
678686 log ( `txt: ${ ipUrlTxtAndCsv . txt } \n csv: ${ ipUrlTxtAndCsv . csv } ` ) ;
679- let content = await getConfigContent ( rawHost , userAgent , _url , host , fakeHostName , fakeUserId , noTLS , ipUrlTxtAndCsv . txt , ipUrlTxtAndCsv . csv , protType , nat64 , hostRemark ) ;
687+ let content = await getConfigContent ( rawHost , userAgent , _url , host , fakeHostName , fakeUserId , noTLS , ipUrlTxtAndCsv . txt , ipUrlTxtAndCsv . csv , protType , nat64 , hostRemark , proxyIP ) ;
680688
681689 return _url . pathname === `/${ fakeUserId } ` ? content : revertFakeInfo ( content , userId , host ) ;
682690}
@@ -752,21 +760,21 @@ function getCLinkConfig(protType, host, address, port, uuid, path, tls, fp) {
752760 return `- {type: ${ xDe ( t , k ) } , name: ${ host } , server: ${ xDe ( a , k ) } , port: ${ xDe ( p , k ) } , password: ${ xDe ( u , k ) } , network: ${ network } , tls: ${ tls [ 1 ] } , udp: false, sni: ${ host } , client-fingerprint: ${ fp } , skip-cert-verify: true, ws-opts: {path: ${ path } , headers: {Host: ${ host } }}}` ;
753761}
754762
755- async function getConfigContent ( rawHost , userAgent , _url , host , fakeHostName , fakeUserId , noTLS , ipUrlTxt , ipUrlCsv , protType , nat64 , hostRemark ) {
763+ async function getConfigContent ( rawHost , userAgent , _url , host , fakeHostName , fakeUserId , noTLS , ipUrlTxt , ipUrlCsv , protType , nat64 , hostRemark , proxyIP ) {
756764 log ( `------------getConfigContent------------------` ) ;
757765 const uniqueIpTxt = [ ...new Set ( [ ...ipUrlTxt , ...ipUrlCsv ] ) ] ;
758766 let responseBody ;
759767 log ( `[getConfigContent]---> protType: ${ protType } ` ) ;
760768 if ( ! protType ) {
761769 protType = doubleBase64Decode ( protTypeBase64 ) ;
762- const responseBody1 = splitNodeData ( uniqueIpTxt , noTLS , fakeHostName , fakeUserId , userAgent , protType , nat64 , hostRemark ) ;
763- const responseBodyTop = splitNodeData ( ipLocal , noTLS , fakeHostName , fakeUserId , userAgent , protType , nat64 , hostRemark ) ;
770+ const responseBody1 = splitNodeData ( uniqueIpTxt , noTLS , fakeHostName , fakeUserId , userAgent , protType , nat64 , hostRemark , proxyIP ) ;
771+ const responseBodyTop = splitNodeData ( ipLocal , noTLS , fakeHostName , fakeUserId , userAgent , protType , nat64 , hostRemark , proxyIP ) ;
764772 protType = doubleBase64Decode ( protTypeBase64Tro ) ;
765- const responseBody2 = splitNodeData ( uniqueIpTxt , noTLS , fakeHostName , fakeUserId , userAgent , protType , nat64 , hostRemark ) ;
773+ const responseBody2 = splitNodeData ( uniqueIpTxt , noTLS , fakeHostName , fakeUserId , userAgent , protType , nat64 , hostRemark , proxyIP ) ;
766774 responseBody = [ responseBodyTop , responseBody1 , responseBody2 ] . join ( '\n' ) ;
767775 } else {
768- const responseBodyTop = splitNodeData ( ipLocal , noTLS , fakeHostName , fakeUserId , userAgent , protType , nat64 , hostRemark ) ;
769- responseBody = splitNodeData ( uniqueIpTxt , noTLS , fakeHostName , fakeUserId , userAgent , protType , nat64 , hostRemark ) ;
776+ const responseBodyTop = splitNodeData ( ipLocal , noTLS , fakeHostName , fakeUserId , userAgent , protType , nat64 , hostRemark , proxyIP ) ;
777+ responseBody = splitNodeData ( uniqueIpTxt , noTLS , fakeHostName , fakeUserId , userAgent , protType , nat64 , hostRemark , proxyIP ) ;
770778 responseBody = [ responseBodyTop , responseBody ] . join ( '\n' ) ;
771779 }
772780 responseBody = base64Encode ( responseBody ) ;
@@ -814,7 +822,7 @@ function isSingboxCondition(userAgent, _url) {
814822 return userAgent . includes ( 'sing-box' ) || userAgent . includes ( 'singbox' ) || ( ( _url . searchParams . has ( 'singbox' ) || _url . searchParams . has ( 'sb' ) ) && ! userAgent . includes ( 'subConverter' ) ) ;
815823}
816824
817- function splitNodeData ( uniqueIpTxt , noTLS , host , uuid , userAgent , protType , nat64 , hostRemark ) {
825+ function splitNodeData ( uniqueIpTxt , noTLS , host , uuid , userAgent , protType , nat64 , hostRemark , proxyIP ) {
818826 log ( `splitNodeData----> \n host: ${ host } \n uuid: ${ uuid } \n protType: ${ protType } \n hostRemark: ${ hostRemark } ` ) ;
819827
820828 const regionMap = {
@@ -878,7 +886,7 @@ function splitNodeData(uniqueIpTxt, noTLS, host, uuid, userAgent, protType, nat6
878886 remarks = regionMap [ rmKey ] ;
879887 }
880888
881- proxyip = proxyip || paddr ;
889+ proxyip = proxyip || proxyIP ;
882890 log ( `splitNodeData--final--> \n address: ${ address } \n port: ${ port } \n remarks: ${ remarks } \n proxyip: ${ proxyip } ` ) ;
883891
884892 if ( noTLS !== 'true' && portSet_http . has ( parseInt ( port ) ) ) {
@@ -2873,4 +2881,4 @@ function pageLogic() {
28732881 window.addEventListener("DOMContentLoaded", detectProxyOrVPN);
28742882
28752883 ` ;
2876- }
2884+ }
0 commit comments