fix(core): update
This commit is contained in:
parent
84ad6bbcd6
commit
a6a47d2e96
@ -38,7 +38,7 @@
|
|||||||
"@gitzone/tsrun": "^1.2.39",
|
"@gitzone/tsrun": "^1.2.39",
|
||||||
"@gitzone/tstest": "^1.0.72",
|
"@gitzone/tstest": "^1.0.72",
|
||||||
"@pushrocks/tapbundle": "^5.0.4",
|
"@pushrocks/tapbundle": "^5.0.4",
|
||||||
"@types/node": "^18.6.1"
|
"@types/node": "^18.15.11"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"ts/**/*",
|
"ts/**/*",
|
||||||
|
1381
pnpm-lock.yaml
generated
1381
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
12
test/test.ts
12
test/test.ts
@ -10,7 +10,7 @@ tap.test('should create an instance of Dnsly', async () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
tap.test('should get an A DNS Record', 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',
|
name: 'dnsly_a.bleu.de',
|
||||||
value: '127.0.0.1',
|
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 () => {
|
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',
|
name: 'dnsly_aaaa.bleu.de',
|
||||||
value: '::1',
|
value: '::1',
|
||||||
@ -32,7 +32,7 @@ tap.test('should get an AAAA Record', async () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
tap.test('should get a txt 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',
|
name: 'dnsly_txt.bleu.de',
|
||||||
value: 'sometext_txt',
|
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 () => {
|
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);
|
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 () => {
|
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);
|
console.log(result);
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('should detect dns sec', async () => {
|
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]);
|
console.log(result[0]);
|
||||||
expect(result[0].dnsSecEnabled).toBeTrue();
|
expect(result[0].dnsSecEnabled).toBeTrue();
|
||||||
});
|
});
|
||||||
|
@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@pushrocks/smartdns',
|
name: '@pushrocks/smartdns',
|
||||||
version: '5.0.3',
|
version: '5.0.4',
|
||||||
description: 'smart dns methods written in TypeScript'
|
description: 'smart dns methods written in TypeScript'
|
||||||
}
|
}
|
||||||
|
21
ts/index.ts
21
ts/index.ts
@ -78,7 +78,7 @@ export class Smartdns {
|
|||||||
try {
|
try {
|
||||||
let myRecordArray: plugins.tsclass.network.IDnsRecord[];
|
let myRecordArray: plugins.tsclass.network.IDnsRecord[];
|
||||||
if (runCycles % 2 === 0 || !plugins.dns) {
|
if (runCycles % 2 === 0 || !plugins.dns) {
|
||||||
myRecordArray = await this.getRecord(recordNameArg, recordTypeArg, 0);
|
myRecordArray = await this.getRecords(recordNameArg, recordTypeArg, 0);
|
||||||
} else {
|
} else {
|
||||||
myRecordArray = await this.getRecordWithNodeDNS(recordNameArg, recordTypeArg);
|
myRecordArray = await this.getRecordWithNodeDNS(recordNameArg, recordTypeArg);
|
||||||
}
|
}
|
||||||
@ -110,25 +110,25 @@ export class Smartdns {
|
|||||||
/**
|
/**
|
||||||
* get A Dns Record
|
* get A Dns Record
|
||||||
*/
|
*/
|
||||||
public async getRecordA(recordNameArg: string): Promise<plugins.tsclass.network.IDnsRecord[]> {
|
public async getRecordsA(recordNameArg: string): Promise<plugins.tsclass.network.IDnsRecord[]> {
|
||||||
return await this.getRecord(recordNameArg, 'A');
|
return await this.getRecords(recordNameArg, 'A');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get AAAA Record
|
* get AAAA Record
|
||||||
*/
|
*/
|
||||||
public async getRecordAAAA(recordNameArg: string) {
|
public async getRecordsAAAA(recordNameArg: string) {
|
||||||
return await this.getRecord(recordNameArg, 'AAAA');
|
return await this.getRecords(recordNameArg, 'AAAA');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gets a txt record
|
* gets a txt record
|
||||||
*/
|
*/
|
||||||
public async getRecordTxt(recordNameArg: string): Promise<plugins.tsclass.network.IDnsRecord[]> {
|
public async getRecordsTxt(recordNameArg: string): Promise<plugins.tsclass.network.IDnsRecord[]> {
|
||||||
return await this.getRecord(recordNameArg, 'TXT');
|
return await this.getRecords(recordNameArg, 'TXT');
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getRecord(
|
public async getRecords(
|
||||||
recordNameArg: string,
|
recordNameArg: string,
|
||||||
recordTypeArg: plugins.tsclass.network.TDnsRecordType,
|
recordTypeArg: plugins.tsclass.network.TDnsRecordType,
|
||||||
retriesCounterArg = 20
|
retriesCounterArg = 20
|
||||||
@ -151,6 +151,9 @@ export class Smartdns {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
const responseBody = await getResponseBody();
|
const responseBody = await getResponseBody();
|
||||||
|
if (!responseBody.Answer || !typeof responseBody.Answer[Symbol.iterator]) {
|
||||||
|
return returnArray;
|
||||||
|
}
|
||||||
for (const dnsEntry of responseBody.Answer) {
|
for (const dnsEntry of responseBody.Answer) {
|
||||||
if (dnsEntry.data.startsWith('"') && dnsEntry.data.endsWith('"')) {
|
if (dnsEntry.data.startsWith('"') && dnsEntry.data.endsWith('"')) {
|
||||||
dnsEntry.data = dnsEntry.data.replace(/^"(.*)"$/, '$1');
|
dnsEntry.data = dnsEntry.data.replace(/^"(.*)"$/, '$1');
|
||||||
@ -196,7 +199,7 @@ export class Smartdns {
|
|||||||
return done.promise;
|
return done.promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getNameServer(domainNameArg: string): Promise<string[]> {
|
public async getNameServers(domainNameArg: string): Promise<string[]> {
|
||||||
const done = plugins.smartpromise.defer<string[]>();
|
const done = plugins.smartpromise.defer<string[]>();
|
||||||
plugins.dns.resolveNs(domainNameArg, (err, result) => {
|
plugins.dns.resolveNs(domainNameArg, (err, result) => {
|
||||||
if (!err) {
|
if (!err) {
|
||||||
|
Loading…
Reference in New Issue
Block a user