UNPKG

@stacksjs/whois

Version:
77 lines (76 loc) 3.92 kB
import { SERVERS } from './constants'; import { SocksClient } from './socks'; import type { ProxyData, WhoIsOptions, WhoIsResponse } from './types'; import type { SocksClientOptions } from './socks'; export type { SocksClientOptions } from './socks'; /** * Find the WhoIs server for the TLD from IANA WhoIs service. The TLD is be searched and the HTML response is parsed to extract the WhoIs server * * @param tld TLD of the domain * @returns WhoIs server which hosts the information for the domains of the TLD */ export declare function findWhoIsServer(tld: string): Promise<string>; /** * Get whois server of the tld from servers list * * @param tld TLD of the domain * @returns WhoIs server which hosts the information for the domains of the TLD */ export declare function getWhoIsServer(tld: keyof typeof SERVERS): string | undefined; /** * Extract TLD from domain name. * If the TLD is in whois-servers.json file, then the TLD is returned. * If TLD is not found within the file, then determined by taking the last element after splitting the domain name from '.' * * @param domain Domain name * @returns TLD */ export declare function getTLD(domain: string): keyof typeof SERVERS; // get whois query parameters if exist on parameters.json for whois server export declare function getParameters(server: string): string | undefined; /** * Connects to the provided {@link server}:{@link port} through TCP (through a proxy if a proxy is given), run the WhoIs query and returns the response * * @param domain Domain name * @param queryOptions Query options which can be used with the specific WhoIs server to get the complete response * @param server WhoIs server * @param port WhoIs server port * @param encoding Encoding used by the WhoIs server * @param proxy {@link ProxyData} * @returns The {string} WhoIs response for the query. Empty string is returned for errors */ export declare function tcpWhois(domain: string, queryOptions: string, server: string, port: number, encoding: string, proxy: ProxyData | null): Promise<string>; /** * Collect WhoIs data for the mentioned {@link domain}. Parse the received response if {@link parse} is true, accordingly. * * @param domain Domain name * @param parse Whether the raw text needs to be parsed/formatted or not * @param options {@link WhoIsOptions} * @returns {@link WhoIsResponse} Returns a {@link WhoIsResponse} object which contains the raw text and parsed data (if parse is true) */ export declare function whois(domain: string, parse?: boolean, options?: WhoIsOptions | null): Promise<WhoIsResponse>; export declare function lookup(domain: string, options?: WhoIsOptions | null): Promise<WhoIsResponse>; /** * Collects (and parse/format if set to be true) for the provided {@link domains}. If {@link parallel} is set to be true, multiple threads will be used to batch process the domains according to {@link threads} mentioned. * If <i>options.parsedData</i> is mentioned, then it will be used to parse <b>all</b> the responses. * If a proxy is mentioned in {@link options}, then the proxy will be used to collect <b>all</b> the WhoIs data. * * @param domains Domains Names * @param parallel Whether data should be collected parallally or not * @param threads Batch size (for parallel processing) * @param parse Whether the raw text needs to be parsed/formatted or not * @param options {@link WhoIsOptions} * @returns Array of {@link WhoIsResponse} for all the domains. Order is not guaranteed */ export declare function batchWhois(domains: string[], parallel?: boolean, threads?: number, parse?: boolean, options?: WhoIsOptions | null): Promise<WhoIsResponse[]>; /** * Parse collected raw WhoIs data * * @class */ export declare class WhoIsParser { static parseData(rawData: string, outputData: any | null): any; } export * from './constants'; export * from './types'; export { SocksClient } from './socks';