fix(core): update

This commit is contained in:
Philipp Kunz 2023-04-08 11:30:48 +02:00
parent 84ad6bbcd6
commit a6a47d2e96
5 changed files with 715 additions and 703 deletions

View File

@ -38,7 +38,7 @@
"@gitzone/tsrun": "^1.2.39",
"@gitzone/tstest": "^1.0.72",
"@pushrocks/tapbundle": "^5.0.4",
"@types/node": "^18.6.1"
"@types/node": "^18.15.11"
},
"files": [
"ts/**/*",

File diff suppressed because it is too large Load Diff

View File

@ -10,7 +10,7 @@ tap.test('should create an instance of Dnsly', async () => {
});
tap.test('should get an A DNS Record', async () => {
return expect(await testDnsly.getRecordA('dnsly_a.bleu.de')).toEqual([
return expect(await testDnsly.getRecordsA('dnsly_a.bleu.de')).toEqual([
{
name: 'dnsly_a.bleu.de',
value: '127.0.0.1',
@ -21,7 +21,7 @@ tap.test('should get an A DNS Record', async () => {
});
tap.test('should get an AAAA Record', async () => {
return expect(await testDnsly.getRecordAAAA('dnsly_aaaa.bleu.de')).toEqual([
return expect(await testDnsly.getRecordsAAAA('dnsly_aaaa.bleu.de')).toEqual([
{
name: 'dnsly_aaaa.bleu.de',
value: '::1',
@ -32,7 +32,7 @@ tap.test('should get an AAAA Record', async () => {
});
tap.test('should get a txt record', async () => {
return expect(await testDnsly.getRecordTxt('dnsly_txt.bleu.de')).toEqual([
return expect(await testDnsly.getRecordsTxt('dnsly_txt.bleu.de')).toEqual([
{
name: 'dnsly_txt.bleu.de',
value: 'sometext_txt',
@ -43,7 +43,7 @@ tap.test('should get a txt record', async () => {
});
tap.test('should, get a mx record for a domain', async () => {
const res = await testDnsly.getRecord('bleu.de', 'MX');
const res = await testDnsly.getRecords('bleu.de', 'MX');
console.log(res);
});
@ -66,12 +66,12 @@ tap.test('should check until DNS is available an return false if it fails', asyn
});
tap.test('should get name server for hostname', async () => {
let result = await testDnsly.getNameServer('bleu.de');
let result = await testDnsly.getNameServers('bleu.de');
console.log(result);
});
tap.test('should detect dns sec', async () => {
const result = await testDnsly.getRecordA('lossless.com');
const result = await testDnsly.getRecordsA('lossless.com');
console.log(result[0]);
expect(result[0].dnsSecEnabled).toBeTrue();
});

View File

@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@pushrocks/smartdns',
version: '5.0.3',
version: '5.0.4',
description: 'smart dns methods written in TypeScript'
}

View File

@ -78,7 +78,7 @@ export class Smartdns {
try {
let myRecordArray: plugins.tsclass.network.IDnsRecord[];
if (runCycles % 2 === 0 || !plugins.dns) {
myRecordArray = await this.getRecord(recordNameArg, recordTypeArg, 0);
myRecordArray = await this.getRecords(recordNameArg, recordTypeArg, 0);
} else {
myRecordArray = await this.getRecordWithNodeDNS(recordNameArg, recordTypeArg);
}
@ -110,25 +110,25 @@ export class Smartdns {
/**
* get A Dns Record
*/
public async getRecordA(recordNameArg: string): Promise<plugins.tsclass.network.IDnsRecord[]> {
return await this.getRecord(recordNameArg, 'A');
public async getRecordsA(recordNameArg: string): Promise<plugins.tsclass.network.IDnsRecord[]> {
return await this.getRecords(recordNameArg, 'A');
}
/**
* get AAAA Record
*/
public async getRecordAAAA(recordNameArg: string) {
return await this.getRecord(recordNameArg, 'AAAA');
public async getRecordsAAAA(recordNameArg: string) {
return await this.getRecords(recordNameArg, 'AAAA');
}
/**
* gets a txt record
*/
public async getRecordTxt(recordNameArg: string): Promise<plugins.tsclass.network.IDnsRecord[]> {
return await this.getRecord(recordNameArg, 'TXT');
public async getRecordsTxt(recordNameArg: string): Promise<plugins.tsclass.network.IDnsRecord[]> {
return await this.getRecords(recordNameArg, 'TXT');
}
public async getRecord(
public async getRecords(
recordNameArg: string,
recordTypeArg: plugins.tsclass.network.TDnsRecordType,
retriesCounterArg = 20
@ -151,6 +151,9 @@ export class Smartdns {
}
};
const responseBody = await getResponseBody();
if (!responseBody.Answer || !typeof responseBody.Answer[Symbol.iterator]) {
return returnArray;
}
for (const dnsEntry of responseBody.Answer) {
if (dnsEntry.data.startsWith('"') && dnsEntry.data.endsWith('"')) {
dnsEntry.data = dnsEntry.data.replace(/^"(.*)"$/, '$1');
@ -196,7 +199,7 @@ export class Smartdns {
return done.promise;
}
public async getNameServer(domainNameArg: string): Promise<string[]> {
public async getNameServers(domainNameArg: string): Promise<string[]> {
const done = plugins.smartpromise.defer<string[]>();
plugins.dns.resolveNs(domainNameArg, (err, result) => {
if (!err) {