@@ -107,7 +107,7 @@ const resolve = createResolve(dohServers);
107
107
const domesticResolve = createResolve ( domesticDohServers ) ;
108
108
109
109
async function getWhois ( domain : string ) {
110
- return asyncRetry ( ( ) => whoiser . domain ( domain ) , { retries : 5 } ) ;
110
+ return asyncRetry ( ( ) => whoiser . domain ( domain , { raw : true } ) , { retries : 5 } ) ;
111
111
}
112
112
113
113
const domainAliveMap = new Map < string , boolean > ( ) ;
@@ -206,7 +206,7 @@ async function isApexDomainAlive(apexDomain: string): Promise<[string, boolean]>
206
206
try {
207
207
whois = await getWhois ( apexDomain ) ;
208
208
} catch ( e ) {
209
- console . log ( picocolors . red ( '[domain dead]' ) , ' whois error' , { domain : apexDomain } , e ) ;
209
+ console . log ( picocolors . red ( '[whois error]' ) , { domain : apexDomain } , e ) ;
210
210
return onDomainAlive ( apexDomain ) ;
211
211
}
212
212
@@ -241,7 +241,8 @@ const whoisNotFoundKeywordTest = createKeywordFilter([
241
241
'status: available' ,
242
242
' is free' ,
243
243
'no object found' ,
244
- 'nothing found'
244
+ 'nothing found' ,
245
+ 'status: free'
245
246
] ) ;
246
247
247
248
// whois server can redirect, so whoiser might/will get info from multiple whois servers
@@ -254,51 +255,69 @@ export function noWhois(whois: whoiser.WhoisSearchResult): null | string {
254
255
if ( Object . hasOwn ( whois , key ) ) {
255
256
empty = false ;
256
257
257
- if ( key === 'error' ) {
258
- // if (
259
- // (typeof whois.error === 'string' && whois.error)
260
- // || (Array.isArray(whois.error) && whois.error.length > 0)
261
- // ) {
262
- // console.error(whois);
263
- // return true;
264
- // }
265
- continue ;
266
- }
267
-
268
- if ( key === 'text' ) {
269
- if ( Array . isArray ( whois . text ) ) {
270
- for ( const value of whois . text ) {
271
- if ( whoisNotFoundKeywordTest ( value . toLowerCase ( ) ) ) {
272
- return value ;
273
- }
274
- }
258
+ // if (key === 'error') {
259
+ // // if (
260
+ // // (typeof whois.error === 'string' && whois.error)
261
+ // // || (Array.isArray(whois.error) && whois.error.length > 0)
262
+ // // ) {
263
+ // // console.error(whois);
264
+ // // return true;
265
+ // // }
266
+ // continue;
267
+ // }
268
+
269
+ // if (key === 'text') {
270
+ // if (Array.isArray(whois.text)) {
271
+ // for (const value of whois.text) {
272
+ // if (whoisNotFoundKeywordTest(value.toLowerCase())) {
273
+ // return value;
274
+ // }
275
+ // }
276
+ // }
277
+ // continue;
278
+ // }
279
+ // if (key === 'Name Server') {
280
+ // // if (Array.isArray(whois[key]) && whois[key].length === 0) {
281
+ // // return false;
282
+ // // }
283
+ // continue;
284
+ // }
285
+
286
+ // if (key === 'Domain Status') {
287
+ // if (Array.isArray(whois[key])) {
288
+ // for (const status of whois[key]) {
289
+ // if (status === 'free' || status === 'AVAILABLE') {
290
+ // return key + ': ' + status;
291
+ // }
292
+ // if (whoisNotFoundKeywordTest(status.toLowerCase())) {
293
+ // return key + ': ' + status;
294
+ // }
295
+ // }
296
+ // }
297
+
298
+ // continue;
299
+ // }
300
+
301
+ // if (typeof whois[key] === 'string' && whois[key]) {
302
+ // if (whoisNotFoundKeywordTest(whois[key].toLowerCase())) {
303
+ // return key + ': ' + whois[key];
304
+ // }
305
+
306
+ // continue;
307
+ // }
308
+
309
+ if ( key === '__raw' && typeof whois . __raw === 'string' ) {
310
+ const lines = whois . __raw . trim ( ) . toLowerCase ( ) . replaceAll ( / [ \t ] + / g, ' ' ) . split ( / \r ? \n / ) ;
311
+
312
+ if ( process . env . DEBUG ) {
313
+ console . log ( { lines } ) ;
275
314
}
276
- continue ;
277
- }
278
- if ( key === 'Name Server' ) {
279
- // if (Array.isArray(whois[key]) && whois[key].length === 0) {
280
- // return false;
281
- // }
282
- continue ;
283
- }
284
315
285
- if ( key === 'Domain Status' ) {
286
- if ( Array . isArray ( whois [ key ] ) ) {
287
- for ( const status of whois [ key ] ) {
288
- if ( whoisNotFoundKeywordTest ( status . toLowerCase ( ) ) ) {
289
- return key + ': ' + status ;
290
- }
316
+ for ( const line of lines ) {
317
+ if ( whoisNotFoundKeywordTest ( line ) ) {
318
+ return line ;
291
319
}
292
320
}
293
-
294
- continue ;
295
- }
296
-
297
- if ( typeof whois [ key ] === 'string' && whois [ key ] ) {
298
- if ( whoisNotFoundKeywordTest ( whois [ key ] . toLowerCase ( ) ) ) {
299
- return key + ': ' + whois [ key ] ;
300
- }
301
-
302
321
continue ;
303
322
}
304
323
0 commit comments