@@ -8,13 +8,18 @@ const { task } = require('./lib/trace-runner');
8
8
9
9
const getBogusNxDomainIPs = async ( ) => {
10
10
/** @type {string[] } */
11
- const res = [ ] ;
11
+ const result = [ ] ;
12
12
for await ( const line of await fetchRemoteTextAndCreateReadlineInterface ( 'https://raw.githubusercontent.com/felixonmars/dnsmasq-china-list/master/bogus-nxdomain.china.conf' ) ) {
13
13
if ( line . startsWith ( 'bogus-nxdomain=' ) ) {
14
- res . push ( line . replace ( 'bogus-nxdomain=' , '' ) ) ;
14
+ const ip = line . slice ( 15 ) . trim ( ) ;
15
+ if ( isIPv4 ( ip ) ) {
16
+ result . push ( `IP-CIDR,${ ip } /32,no-resolve` ) ;
17
+ } else if ( isIPv6 ( ip ) ) {
18
+ result . push ( `IP-CIDR6,${ ip } /128,no-resolve` ) ;
19
+ }
15
20
}
16
21
}
17
- return res ;
22
+ return result ;
18
23
} ;
19
24
20
25
const buildAntiBogusDomain = task ( __filename , async ( ) => {
@@ -26,14 +31,7 @@ const buildAntiBogusDomain = task(__filename, async () => {
26
31
const result = [ ] ;
27
32
for await ( const line of readFileByLine ( filePath ) ) {
28
33
if ( line === '# --- [Anti Bogus Domain Replace Me] ---' ) {
29
- ( await bogusIpPromise ) . forEach ( ip => {
30
- if ( isIPv4 ( ip ) ) {
31
- result . push ( `IP-CIDR,${ ip } /32,no-resolve` ) ;
32
- } else if ( isIPv6 ( ip ) ) {
33
- result . push ( `IP-CIDR6,${ ip } /128,no-resolve` ) ;
34
- }
35
- } ) ;
36
-
34
+ ( await bogusIpPromise ) . forEach ( rule => result . push ( rule ) ) ;
37
35
continue ;
38
36
} else {
39
37
const l = processLine ( line ) ;
0 commit comments