Compare commits

...

8 Commits

Author SHA1 Message Date
2a1fbeb183 5.0.4 2023-04-08 11:30:49 +02:00
a6a47d2e96 fix(core): update 2023-04-08 11:30:48 +02:00
84ad6bbcd6 5.0.3 2023-03-23 01:41:35 +01:00
4102c3a692 fix(core): update 2023-03-23 01:41:35 +01:00
6281ab0c80 5.0.2 2022-07-27 11:42:02 +02:00
622c65291e fix(core): update 2022-07-27 11:42:01 +02:00
dd8c97b99a 5.0.1 2022-07-27 09:15:28 +02:00
9c56dc51e3 fix(core): update 2022-07-27 09:15:28 +02:00
8 changed files with 4529 additions and 14987 deletions

View File

@ -13,8 +13,13 @@ stages:
- metadata - metadata
before_script: before_script:
- npm install -g @shipzone/npmci - pnpm install -g pnpm
- pnpm install -g @shipzone/npmci
- npmci npm prepare
# ====================
# security stage
# ====================
# ==================== # ====================
# security stage # security stage
# ==================== # ====================
@ -22,11 +27,10 @@ auditProductionDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security stage: security
script: script:
- npmci npm prepare - npmci command npm config set registry https://registry.npmjs.org
- npmci command npm install --production --ignore-scripts - npmci command pnpm audit --audit-level=high --prod
- npmci command npm config set registry https://registry.npmjs.org
- npmci command npm audit --audit-level=high --only=prod --production
tags: tags:
- lossless
- docker - docker
allow_failure: true allow_failure: true
@ -34,11 +38,10 @@ auditDevDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security stage: security
script: script:
- npmci npm prepare
- npmci command npm install --ignore-scripts
- npmci command npm config set registry https://registry.npmjs.org - npmci command npm config set registry https://registry.npmjs.org
- npmci command npm audit --audit-level=high --only=dev - npmci command pnpm audit --audit-level=high --dev
tags: tags:
- lossless
- docker - docker
allow_failure: true allow_failure: true
@ -49,7 +52,6 @@ auditDevDependencies:
testStable: testStable:
stage: test stage: test
script: script:
- npmci npm prepare
- npmci node install stable - npmci node install stable
- npmci npm install - npmci npm install
- npmci npm test - npmci npm test
@ -60,10 +62,9 @@ testStable:
testBuild: testBuild:
stage: test stage: test
script: script:
- npmci npm prepare
- npmci node install stable - npmci node install stable
- npmci npm install - npmci npm install
- npmci command npm run build - npmci npm build
coverage: /\d+.?\d+?\%\s*coverage/ coverage: /\d+.?\d+?\%\s*coverage/
tags: tags:
- docker - docker
@ -111,8 +112,7 @@ trigger:
pages: pages:
stage: metadata stage: metadata
script: script:
- npmci node install stable - npmci node install stable
- npmci npm prepare
- npmci npm install - npmci npm install
- npmci command npm run buildDocs - npmci command npm run buildDocs
tags: tags:

14936
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,13 +1,13 @@
{ {
"name": "@pushrocks/smartdns", "name": "@pushrocks/smartdns",
"version": "5.0.0", "version": "5.0.4",
"private": false, "private": false,
"description": "smart dns methods written in TypeScript", "description": "smart dns methods written in TypeScript",
"main": "dist_ts/index.js", "main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts", "typings": "dist_ts/index.d.ts",
"scripts": { "scripts": {
"test": "(tstest test/)", "test": "(tstest test/)",
"build": "(tsbuild --web)", "build": "(tsbuild --web --allowimplicitany)",
"buildDocs": "tsdoc" "buildDocs": "tsdoc"
}, },
"repository": { "repository": {
@ -29,17 +29,16 @@
"@pushrocks/smartdelay": "^2.0.13", "@pushrocks/smartdelay": "^2.0.13",
"@pushrocks/smartenv": "^5.0.2", "@pushrocks/smartenv": "^5.0.2",
"@pushrocks/smartpromise": "^3.1.7", "@pushrocks/smartpromise": "^3.1.7",
"@pushrocks/smartrequest": "^1.1.56", "@pushrocks/smartrequest": "^2.0.11",
"@tsclass/tsclass": "^4.0.17", "@tsclass/tsclass": "^4.0.17",
"dns2": "^2.0.5" "dns2": "^2.0.5"
}, },
"devDependencies": { "devDependencies": {
"@gitzone/tsbuild": "^2.1.63", "@gitzone/tsbuild": "^2.1.63",
"@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"
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0"
}, },
"files": [ "files": [
"ts/**/*", "ts/**/*",

4462
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -21,7 +21,6 @@ Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](htt
PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@pushrocks/smartdns)](https://lossless.cloud) PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@pushrocks/smartdns)](https://lossless.cloud)
PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@pushrocks/smartdns)](https://lossless.cloud) PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@pushrocks/smartdns)](https://lossless.cloud)
BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@pushrocks/smartdns)](https://lossless.cloud) BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@pushrocks/smartdns)](https://lossless.cloud)
Platform support | [![Supports Windows 10](https://badgen.net/badge/supports%20Windows%2010/yes/green?icon=windows)](https://lossless.cloud) [![Supports Mac OS X](https://badgen.net/badge/supports%20Mac%20OS%20X/yes/green?icon=apple)](https://lossless.cloud)
## Usage ## Usage
@ -47,7 +46,6 @@ We are always happy for code contributions. If you are not the code contributing
For further information read the linked docs at the top of this readme. For further information read the linked docs at the top of this readme.
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh) ## Legal
> MIT licensed | **©** [Task Venture Capital GmbH](https://task.vc)
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy) | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
[![repo-footer](https://lossless.gitlab.io/publicrelations/repofooter.svg)](https://maintainedby.lossless.com)

View File

@ -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,29 +43,35 @@ 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);
}); });
tap.test('should check until DNS is available', async () => { tap.test('should check until DNS is available', async () => {
return expect(await testDnsly.checkUntilAvailable('dnsly_txt.bleu.de', 'TXT', 'sometext_txt')).toBeTrue(); return expect(
await testDnsly.checkUntilAvailable('dnsly_txt.bleu.de', 'TXT', 'sometext_txt')
).toBeTrue();
}); });
tap.test('should check until DNS is available an return false if it fails', async () => { tap.test('should check until DNS is available an return false if it fails', async () => {
return expect(await testDnsly.checkUntilAvailable('dnsly_txt.bleu.de', 'TXT', 'sometext_txt2')).toBeFalse() return expect(
await testDnsly.checkUntilAvailable('dnsly_txt.bleu.de', 'TXT', 'sometext_txt2')
).toBeFalse();
}); });
tap.test('should check until DNS is available an return false if it fails', async () => { tap.test('should check until DNS is available an return false if it fails', async () => {
return expect(await testDnsly.checkUntilAvailable('dnsly_txtNotThere.bleu.de', 'TXT', 'sometext_txt2')).toBeFalse() return expect(
await testDnsly.checkUntilAvailable('dnsly_txtNotThere.bleu.de', 'TXT', 'sometext_txt2')
).toBeFalse();
}); });
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();
}); });

View File

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

View File

@ -2,7 +2,7 @@ import * as plugins from './dnsly.plugins.js';
export type TDnsProvider = 'google' | 'cloudflare'; export type TDnsProvider = 'google' | 'cloudflare';
export const makeNodeProcessUseDnsProvider = async (providerArg: TDnsProvider) => { export const makeNodeProcessUseDnsProvider = (providerArg: TDnsProvider) => {
switch (providerArg) { switch (providerArg) {
case 'cloudflare': case 'cloudflare':
plugins.dns.setServers([ plugins.dns.setServers([
@ -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); myRecordArray = await this.getRecords(recordNameArg, recordTypeArg, 0);
} else { } else {
myRecordArray = await this.getRecordWithNodeDNS(recordNameArg, recordTypeArg); myRecordArray = await this.getRecordWithNodeDNS(recordNameArg, recordTypeArg);
} }
@ -110,37 +110,50 @@ 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
): Promise<plugins.tsclass.network.IDnsRecord[]> { ): Promise<plugins.tsclass.network.IDnsRecord[]> {
const requestUrl = `https://cloudflare-dns.com/dns-query?name=${recordNameArg}&type=${recordTypeArg}&do=1`; const requestUrl = `https://cloudflare-dns.com/dns-query?name=${recordNameArg}&type=${recordTypeArg}&do=1`;
const response = await plugins.smartrequest.request(requestUrl, {
method: 'GET',
headers: {
accept: 'application/dns-json',
},
});
const returnArray: plugins.tsclass.network.IDnsRecord[] = []; const returnArray: plugins.tsclass.network.IDnsRecord[] = [];
const responseBody: IGoogleDNSHTTPSResponse = response.body; const getResponseBody = async (counterArg = 0): Promise<IGoogleDNSHTTPSResponse> => {
const response = await plugins.smartrequest.request(requestUrl, {
method: 'GET',
headers: {
accept: 'application/dns-json',
},
});
const responseBody: IGoogleDNSHTTPSResponse = response.body;
if (responseBody?.Status !== 0 && counterArg < retriesCounterArg) {
await plugins.smartdelay.delayFor(500);
return getResponseBody(counterArg++);
} else {
return responseBody;
}
};
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');
@ -186,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) {