feat(smartdns): Add DNS Server and DNSSEC tools with comprehensive unit tests

This commit is contained in:
2024-09-18 19:28:28 +02:00
parent 2cfecab96f
commit 5c06ae1edb
10 changed files with 1038 additions and 389 deletions

View File

@ -24,7 +24,7 @@ export const makeNodeProcessUseDnsProvider = (providerArg: TDnsProvider) => {
export interface ISmartDnsConstructorOptions {}
export interface IGoogleDNSHTTPSResponse {
export interface IDnsJsonResponse {
Status: number;
TC: boolean;
RD: boolean;
@ -135,14 +135,14 @@ export class Smartdns {
): Promise<plugins.tsclass.network.IDnsRecord[]> {
const requestUrl = `https://cloudflare-dns.com/dns-query?name=${recordNameArg}&type=${recordTypeArg}&do=1`;
const returnArray: plugins.tsclass.network.IDnsRecord[] = [];
const getResponseBody = async (counterArg = 0): Promise<IGoogleDNSHTTPSResponse> => {
const getResponseBody = async (counterArg = 0): Promise<IDnsJsonResponse> => {
const response = await plugins.smartrequest.request(requestUrl, {
method: 'GET',
headers: {
accept: 'application/dns-json',
},
});
const responseBody: IGoogleDNSHTTPSResponse = response.body;
const responseBody: IDnsJsonResponse = response.body;
if (responseBody?.Status !== 0 && counterArg < retriesCounterArg) {
await plugins.smartdelay.delayFor(500);
return getResponseBody(counterArg++);

View File

@ -16,7 +16,3 @@ export { smartdelay, smartenv, smartpromise, smartrequest };
import * as tsclass from '@tsclass/tsclass';
export { tsclass };
// third party scope
const dns2 = smartenvInstance.getSafeNodeModule('dns2');
export { dns2 };