1
1
import type { SocksClientOptions } from 'socks'
2
2
import type { ProxyData , WhoIsOptions , WhoIsResponse } from './types'
3
3
import Net from 'node:net'
4
+ import { log } from '@stacksjs/logging'
4
5
import fetch from 'node-fetch'
5
6
import { SocksClient } from 'socks'
6
7
import { IANA_CHK_URL , PARAMETERS , SERVERS } from './constants'
@@ -268,16 +269,16 @@ export async function whois(
268
269
if ( server === '' ) {
269
270
let serverData = getWhoIsServer ( tld as keyof typeof SERVERS )
270
271
if ( ! serverData ) {
271
- console . debug ( `No WhoIs server found for TLD: ${ tld } ! Attempting IANA WhoIs database for server!` )
272
+ log . debug ( `No WhoIs server found for TLD: ${ tld } ! Attempting IANA WhoIs database for server!` )
272
273
serverData = await findWhoIsServer ( tld )
273
274
if ( ! serverData ) {
274
- console . debug ( 'WhoIs server could not be found!' )
275
+ log . debug ( 'WhoIs server could not be found!' )
275
276
return {
276
277
_raw : '' ,
277
278
parsedData : null ,
278
279
}
279
280
}
280
- console . debug ( `WhoIs sever found for ${ tld } : ${ server } ` )
281
+ log . debug ( `WhoIs sever found for ${ tld } : ${ server } ` )
281
282
}
282
283
283
284
server = serverData
@@ -287,9 +288,9 @@ export async function whois(
287
288
const queryOptions = qOptions || ''
288
289
289
290
try {
290
- console . log ( `Attempting WHOIS lookup for ${ domain } on server ${ server } ` )
291
+ log . debug ( `Attempting WHOIS lookup for ${ domain } on server ${ server } ` )
291
292
const rawData = await tcpWhois ( domain , queryOptions , server , port , encoding , proxy )
292
- console . log ( `Raw WHOIS data received:` , rawData )
293
+ log . debug ( `Raw WHOIS data received:` , rawData )
293
294
if ( ! parse ) {
294
295
const parsedData = WhoIsParser . parseData ( rawData , null )
295
296
return {
@@ -317,7 +318,8 @@ export async function whois(
317
318
}
318
319
}
319
320
}
320
- catch ( err ) {
321
+ catch ( err : any ) {
322
+ log . debug ( `Error in WHOIS lookup for ${ domain } on server ${ server } ` , err )
321
323
return {
322
324
_raw : '' ,
323
325
parsedData : null ,
@@ -326,7 +328,7 @@ export async function whois(
326
328
}
327
329
328
330
export function lookup ( domain : string , options : WhoIsOptions | null = null ) : Promise < WhoIsResponse > {
329
- console . log ( `Lookup called for ${ domain } ` )
331
+ log . debug ( `Lookup called for ${ domain } ` )
330
332
return whois ( domain , true , options )
331
333
}
332
334
0 commit comments