@@ -3,13 +3,13 @@ const path = require('path');
3
3
const { createRuleset } = require ( './lib/create-file' ) ;
4
4
const { fetchRemoteTextAndCreateReadlineInterface, readFileByLine } = require ( './lib/fetch-remote-text-by-line' ) ;
5
5
const Trie = require ( './lib/trie' ) ;
6
- const { runner } = require ( './lib/trace-runner' ) ;
6
+ const { runner, task } = require ( './lib/trace-runner' ) ;
7
7
const fs = require ( 'fs' ) ;
8
8
const { processLine } = require ( './lib/process-line' ) ;
9
9
10
- const publicSuffixPath = path . resolve ( __dirname , '../node_modules/.cache/public_suffix-list_dat .txt' ) ;
10
+ const publicSuffixPath = path . resolve ( __dirname , '../node_modules/.cache/public_suffix_list_dat .txt' ) ;
11
11
12
- const buildCdnConf = async ( ) => {
12
+ const buildCdnConf = task ( __filename , async ( ) => {
13
13
const trie = new Trie ( ) ;
14
14
15
15
if ( fs . existsSync ( publicSuffixPath ) ) {
@@ -30,23 +30,33 @@ const buildCdnConf = async () => {
30
30
const S3OSSDomains = new Set ( ) ;
31
31
32
32
trie . find ( '.amazonaws.com' ) . forEach ( line => {
33
- if ( ( line . startsWith ( 's3-' ) || line . startsWith ( 's3.' ) ) && ! line . includes ( 'cn-' ) ) {
33
+ if (
34
+ ( line . startsWith ( 's3-' ) || line . startsWith ( 's3.' ) )
35
+ && ! line . includes ( 'cn-' )
36
+ ) {
34
37
S3OSSDomains . add ( line ) ;
35
38
}
36
39
} ) ;
37
40
trie . find ( '.scw.cloud' ) . forEach ( line => {
38
- if ( ( line . startsWith ( 's3-' ) || line . startsWith ( 's3.' ) ) && ! line . includes ( 'cn-' ) ) {
41
+ if (
42
+ ( line . startsWith ( 's3-' ) || line . startsWith ( 's3.' ) )
43
+ && ! line . includes ( 'cn-' )
44
+ ) {
39
45
S3OSSDomains . add ( line ) ;
40
46
}
41
47
} ) ;
42
48
43
49
/** @type {string[] } */
44
50
const cdnDomainsList = [ ] ;
45
51
for await ( const l of readFileByLine ( path . resolve ( __dirname , '../Source/non_ip/cdn.conf' ) ) ) {
52
+ if ( l === '# --- [AWS S3 Replace Me] ---' ) {
53
+ console . log ( S3OSSDomains ) ;
54
+ S3OSSDomains . forEach ( domain => {
55
+ cdnDomainsList . push ( `DOMAIN-SUFFIX,${ domain } ` ) ;
56
+ } ) ;
57
+ }
46
58
const line = processLine ( l ) ;
47
- if ( line === '# --- [AWS S3 Replace Me] ---' ) {
48
- S3OSSDomains . forEach ( domain => cdnDomainsList . push ( `DOMAIN-SUFFIX,${ domain } ` ) ) ;
49
- } else if ( line ) {
59
+ if ( line ) {
50
60
cdnDomainsList . push ( line ) ;
51
61
}
52
62
}
@@ -68,7 +78,7 @@ const buildCdnConf = async () => {
68
78
path . resolve ( __dirname , '../List/non_ip/cdn.conf' ) ,
69
79
path . resolve ( __dirname , '../Clash/non_ip/cdn.txt' )
70
80
) ) ;
71
- } ;
81
+ } ) ;
72
82
73
83
module . exports . buildCdnConf = buildCdnConf ;
74
84
0 commit comments