@@ -9,6 +9,13 @@ import { fdir as Fdir } from 'fdir';
9
9
10
10
const queue = newQueue ( 32 ) ;
11
11
12
+ const deadDomains : string [ ] = [ ] ;
13
+ function onDomain ( args : [ string , boolean ] ) {
14
+ if ( ! args [ 1 ] ) {
15
+ deadDomains . push ( args [ 0 ] ) ;
16
+ }
17
+ }
18
+
12
19
( async ( ) => {
13
20
const domainSets = await new Fdir ( )
14
21
. withFullPaths ( )
@@ -24,7 +31,9 @@ const queue = newQueue(32);
24
31
...domainRules . map ( runAgainstRuleset )
25
32
] ) ;
26
33
27
- console . log ( 'done' ) ;
34
+ console . log ( ) ;
35
+ console . log ( ) ;
36
+ console . log ( JSON . stringify ( deadDomains ) ) ;
28
37
} ) ( ) ;
29
38
30
39
export async function runAgainstRuleset ( filepath : string ) {
@@ -34,7 +43,7 @@ export async function runAgainstRuleset(filepath: string) {
34
43
return ;
35
44
}
36
45
37
- const promises : Array < Promise < [ string , boolean ] > > = [ ] ;
46
+ const promises : Array < Promise < void > > = [ ] ;
38
47
39
48
for await ( const l of readFileByLine ( filepath ) ) {
40
49
const line = processLine ( l ) ;
@@ -43,7 +52,10 @@ export async function runAgainstRuleset(filepath: string) {
43
52
switch ( type ) {
44
53
case 'DOMAIN-SUFFIX' :
45
54
case 'DOMAIN' : {
46
- promises . push ( queue . add ( ( ) => keyedAsyncMutexWithQueue ( domain , ( ) => isDomainAlive ( domain , type === 'DOMAIN-SUFFIX' ) ) ) ) ;
55
+ promises . push (
56
+ queue . add ( ( ) => keyedAsyncMutexWithQueue ( domain , ( ) => isDomainAlive ( domain , type === 'DOMAIN-SUFFIX' ) ) )
57
+ . then ( onDomain )
58
+ ) ;
47
59
break ;
48
60
}
49
61
// no default
@@ -61,12 +73,15 @@ export async function runAgainstDomainset(filepath: string) {
61
73
return ;
62
74
}
63
75
64
- const promises : Array < Promise < [ string , boolean ] > > = [ ] ;
76
+ const promises : Array < Promise < void > > = [ ] ;
65
77
66
78
for await ( const l of readFileByLine ( filepath ) ) {
67
79
const line = processLine ( l ) ;
68
80
if ( ! line ) continue ;
69
- promises . push ( queue . add ( ( ) => keyedAsyncMutexWithQueue ( line , ( ) => isDomainAlive ( line , line [ 0 ] === '.' ) ) ) ) ;
81
+ promises . push (
82
+ queue . add ( ( ) => keyedAsyncMutexWithQueue ( line , ( ) => isDomainAlive ( line , line [ 0 ] === '.' ) ) )
83
+ . then ( onDomain )
84
+ ) ;
70
85
}
71
86
72
87
await Promise . all ( promises ) ;
0 commit comments