@@ -291,6 +291,9 @@ async function downloadSubscription(req, res) {
291291 if ( noCache ) {
292292 $ . info ( `指定不使用缓存: ${ noCache } ` ) ;
293293 }
294+ if ( req . query . noFlow ) {
295+ $ . info ( `指定不查询订阅流量信息: ${ req . query . noFlow } ` ) ;
296+ }
294297
295298 const allSubs = $ . read ( SUBS_KEY ) ;
296299 const fakeSub = _fakeNode ? {
@@ -306,6 +309,7 @@ async function downloadSubscription(req, res) {
306309 const sub = ( _fakeNode || _fakeSub ) ? fakeSub : findByName ( allSubs , name ) ;
307310 if ( sub ) {
308311 try {
312+ const noFlow = req . query . noFlow || sub . noFlow ;
309313 const passThroughUA = sub . passThroughUA ;
310314 if ( passThroughUA ) {
311315 $ . info (
@@ -335,6 +339,7 @@ async function downloadSubscription(req, res) {
335339 $options,
336340 proxy,
337341 noCache,
342+ noFlow,
338343 } ;
339344 if ( _fakeNode || _fakeSub ) {
340345 if ( _fakeNode ) {
@@ -377,7 +382,11 @@ async function downloadSubscription(req, res) {
377382 }
378383 }
379384 }
380- if ( ! $arguments . noFlow && / ^ h t t p s ? / . test ( url ) ) {
385+ if (
386+ ! noFlow &&
387+ ! $arguments . noFlow &&
388+ / ^ h t t p s ? / . test ( url )
389+ ) {
381390 // forward flow headers
382391 flowInfo = await getFlowHeaders (
383392 $arguments ?. insecure ? `${ url } #insecure` : url ,
@@ -414,7 +423,7 @@ async function downloadSubscription(req, res) {
414423 ) ;
415424 }
416425 }
417- if ( sub . subUserinfo ) {
426+ if ( ! noFlow && sub . subUserinfo ) {
418427 let subUserInfo ;
419428 if ( / ^ h t t p s ? : \/ \/ / . test ( sub . subUserinfo ) ) {
420429 try {
@@ -499,6 +508,7 @@ async function downloadSubscription(req, res) {
499508 targetPlatform : platform ,
500509 source : { [ sub . name ] : sub } ,
501510 $options,
511+ executionContext : { noFlow } ,
502512 } ) ;
503513 res . send (
504514 await applyAgeOutputEncryption ( {
@@ -644,9 +654,13 @@ async function downloadCollection(req, res) {
644654 if ( noCache ) {
645655 $ . info ( `指定不使用缓存: ${ noCache } ` ) ;
646656 }
657+ if ( req . query . noFlow ) {
658+ $ . info ( `指定不查询订阅流量信息: ${ req . query . noFlow } ` ) ;
659+ }
647660
648661 if ( collection ) {
649662 try {
663+ const noFlow = req . query . noFlow || collection . noFlow ;
650664 let output = await produceArtifact ( {
651665 type : 'collection' ,
652666 name,
@@ -665,11 +679,12 @@ async function downloadCollection(req, res) {
665679 $options,
666680 proxy,
667681 noCache,
682+ noFlow,
668683 ua : reqUA ,
669684 } ) ;
670685 let subUserInfoOfSub ;
671686 // 默认透传第一个子订阅的流量信息,除非 firstSubFlow 显式设置为 false
672- if ( collection . firstSubFlow !== false ) {
687+ if ( ! noFlow && collection . firstSubFlow !== false ) {
673688 // forward flow header from the first subscription in this collection
674689 const allSubs = $ . read ( SUBS_KEY ) ;
675690 const subnames = collection . subscriptions ;
@@ -707,7 +722,11 @@ async function downloadCollection(req, res) {
707722 }
708723 }
709724 }
710- if ( ! $arguments . noFlow && / ^ h t t p s ? : / . test ( url ) ) {
725+ if (
726+ ! sub . noFlow &&
727+ ! $arguments . noFlow &&
728+ / ^ h t t p s ? : / . test ( url )
729+ ) {
711730 subUserInfoOfSub = await getFlowHeaders (
712731 $arguments ?. insecure
713732 ? `${ url } #insecure`
@@ -729,7 +748,7 @@ async function downloadCollection(req, res) {
729748 ) ;
730749 }
731750 }
732- if ( sub . subUserinfo ) {
751+ if ( ! sub . noFlow && sub . subUserinfo ) {
733752 let subUserInfo ;
734753 if ( / ^ h t t p s ? : \/ \/ / . test ( sub . subUserinfo ) ) {
735754 try {
@@ -764,24 +783,26 @@ async function downloadCollection(req, res) {
764783 }
765784
766785 let subUserInfoOfCol ;
767- if ( / ^ h t t p s ? : \/ \/ / . test ( collection . subUserinfo ) ) {
768- try {
769- subUserInfoOfCol = await getFlowHeaders (
770- undefined ,
771- undefined ,
772- undefined ,
773- proxy || collection . proxy ,
774- collection . subUserinfo ,
775- ) ;
776- } catch ( e ) {
777- $ . error (
778- `组合订阅 ${ name } 使用自定义流量链接 ${
779- collection . subUserinfo
780- } 获取流量信息时发生错误: ${ JSON . stringify ( e ) } `,
781- ) ;
786+ if ( ! noFlow ) {
787+ if ( / ^ h t t p s ? : \/ \/ / . test ( collection . subUserinfo ) ) {
788+ try {
789+ subUserInfoOfCol = await getFlowHeaders (
790+ undefined ,
791+ undefined ,
792+ undefined ,
793+ proxy || collection . proxy ,
794+ collection . subUserinfo ,
795+ ) ;
796+ } catch ( e ) {
797+ $ . error (
798+ `组合订阅 ${ name } 使用自定义流量链接 ${
799+ collection . subUserinfo
800+ } 获取流量信息时发生错误: ${ JSON . stringify ( e ) } `,
801+ ) ;
802+ }
803+ } else {
804+ subUserInfoOfCol = collection . subUserinfo ;
782805 }
783- } else {
784- subUserInfoOfCol = collection . subUserinfo ;
785806 }
786807 const subUserInfo = [ subUserInfoOfCol , subUserInfoOfSub ]
787808 . filter ( ( i ) => i )
@@ -846,6 +867,7 @@ async function downloadCollection(req, res) {
846867 targetPlatform : platform ,
847868 source : { _collection : collection } ,
848869 $options,
870+ executionContext : { noFlow } ,
849871 } ) ;
850872 res . send (
851873 await applyAgeOutputEncryption ( {
0 commit comments