Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
efd9bbb77a | |||
b463aea274 | |||
c8cf590a5a | |||
42f679ef61 |
4
.gitignore
vendored
4
.gitignore
vendored
@ -15,8 +15,6 @@ node_modules/
|
||||
|
||||
# builds
|
||||
dist/
|
||||
dist_web/
|
||||
dist_serve/
|
||||
dist_ts_web/
|
||||
dist_*/
|
||||
|
||||
# custom
|
@ -19,22 +19,23 @@ mirror:
|
||||
stage: security
|
||||
script:
|
||||
- npmci git mirror
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
snyk:
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:snyk
|
||||
audit:
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
stage: security
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci command npm install --ignore-scripts
|
||||
- npmci command snyk test
|
||||
- npmci command npm config set registry https://registry.npmjs.org
|
||||
- npmci command npm audit --audit-level=high
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
# ====================
|
||||
# test stage
|
||||
@ -49,9 +50,7 @@ testStable:
|
||||
- npmci npm test
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- priv
|
||||
|
||||
testBuild:
|
||||
stage: test
|
||||
@ -62,9 +61,7 @@ testBuild:
|
||||
- npmci command npm run build
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
release:
|
||||
stage: release
|
||||
@ -84,6 +81,8 @@ release:
|
||||
codequality:
|
||||
stage: metadata
|
||||
allow_failure: true
|
||||
only:
|
||||
- tags
|
||||
script:
|
||||
- npmci command npm install -g tslint typescript
|
||||
- npmci npm prepare
|
||||
|
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
@ -15,7 +15,7 @@
|
||||
"properties": {
|
||||
"projectType": {
|
||||
"type": "string",
|
||||
"enum": ["website", "element", "service", "npm"]
|
||||
"enum": ["website", "element", "service", "npm", "wcc"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
10460
package-lock.json
generated
10460
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
28
package.json
28
package.json
@ -1,13 +1,13 @@
|
||||
{
|
||||
"name": "@pushrocks/smartdns",
|
||||
"version": "4.0.2",
|
||||
"version": "4.0.4",
|
||||
"private": false,
|
||||
"description": "smart dns methods written in TypeScript",
|
||||
"main": "dist/index.js",
|
||||
"typings": "dist/index.d.ts",
|
||||
"main": "dist_ts/index.js",
|
||||
"typings": "dist_ts/index.d.ts",
|
||||
"scripts": {
|
||||
"test": "(tstest test/)",
|
||||
"build": "(tsbuild)"
|
||||
"build": "(tsbuild --web)"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@ -25,28 +25,32 @@
|
||||
},
|
||||
"homepage": "https://gitlab.com/pushrocks/dnsly#README",
|
||||
"dependencies": {
|
||||
"@pushrocks/smartdelay": "^2.0.6",
|
||||
"@pushrocks/smartdelay": "^2.0.10",
|
||||
"@pushrocks/smartpromise": "^3.0.6",
|
||||
"@pushrocks/smartrequest": "^1.1.47",
|
||||
"@tsclass/tsclass": "^3.0.6"
|
||||
"@tsclass/tsclass": "^3.0.21"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@gitzone/tsbuild": "^2.1.17",
|
||||
"@gitzone/tstest": "^1.0.28",
|
||||
"@pushrocks/tapbundle": "^3.2.0",
|
||||
"@types/node": "^13.7.1",
|
||||
"tslint": "^6.0.0",
|
||||
"@gitzone/tsbuild": "^2.1.24",
|
||||
"@gitzone/tstest": "^1.0.43",
|
||||
"@pushrocks/tapbundle": "^3.2.9",
|
||||
"@types/node": "^14.0.27",
|
||||
"tslint": "^6.1.3",
|
||||
"tslint-config-prettier": "^1.18.0"
|
||||
},
|
||||
"files": [
|
||||
"ts/**/*",
|
||||
"ts_web/**/*",
|
||||
"dist/**/*",
|
||||
"dist_web/**/*",
|
||||
"dist_*/**/*",
|
||||
"dist_ts/**/*",
|
||||
"dist_ts_web/**/*",
|
||||
"assets/**/*",
|
||||
"cli.js",
|
||||
"npmextra.json",
|
||||
"readme.md"
|
||||
],
|
||||
"browserslist": [
|
||||
"last 1 chrome versions"
|
||||
]
|
||||
}
|
||||
|
21
readme.md
21
readme.md
@ -8,13 +8,20 @@ smart dns methods written in TypeScript
|
||||
* [docs (typedoc)](https://pushrocks.gitlab.io/smartdns/)
|
||||
|
||||
## Status for master
|
||||
[](https://gitlab.com/pushrocks/smartdns/commits/master)
|
||||
[](https://gitlab.com/pushrocks/smartdns/commits/master)
|
||||
[](https://www.npmjs.com/package/@pushrocks/smartdns)
|
||||
[](https://snyk.io/test/npm/@pushrocks/smartdns)
|
||||
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||
[](https://prettier.io/)
|
||||
|
||||
Status Category | Status Badge
|
||||
-- | --
|
||||
GitLab Pipelines | [](https://lossless.cloud)
|
||||
GitLab Pipline Test Coverage | [](https://lossless.cloud)
|
||||
npm | [](https://lossless.cloud)
|
||||
Snyk | [](https://lossless.cloud)
|
||||
TypeScript Support | [](https://lossless.cloud)
|
||||
node Support | [](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||
Code Style | [](https://lossless.cloud)
|
||||
PackagePhobia (total standalone install weight) | [](https://lossless.cloud)
|
||||
PackagePhobia (package size on registry) | [](https://lossless.cloud)
|
||||
BundlePhobia (total size when bundled) | [](https://lossless.cloud)
|
||||
Platform support | [](https://lossless.cloud) [](https://lossless.cloud)
|
||||
|
||||
## Usage
|
||||
|
||||
|
12
test/test.ts
12
test/test.ts
@ -15,8 +15,8 @@ tap.test('should get an A DNS Record', async () => {
|
||||
name: 'dnsly_a.bleu.de',
|
||||
value: '127.0.0.1',
|
||||
dnsSecEnabled: false,
|
||||
type: 'A'
|
||||
}
|
||||
type: 'A',
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
@ -26,8 +26,8 @@ tap.test('should get an AAAA Record', async () => {
|
||||
name: 'dnsly_aaaa.bleu.de',
|
||||
value: '::1',
|
||||
dnsSecEnabled: false,
|
||||
type: 'AAAA'
|
||||
}
|
||||
type: 'AAAA',
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
@ -37,8 +37,8 @@ tap.test('should get a txt record', async () => {
|
||||
name: 'dnsly_txt.bleu.de',
|
||||
value: 'sometext_txt',
|
||||
type: 'TXT',
|
||||
dnsSecEnabled: false
|
||||
}
|
||||
dnsSecEnabled: false,
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
|
31
ts/index.ts
31
ts/index.ts
@ -29,7 +29,7 @@ export class Smartdns {
|
||||
AAAA: 28,
|
||||
CNAME: 5,
|
||||
MX: 15,
|
||||
TXT: 16
|
||||
TXT: 16,
|
||||
};
|
||||
|
||||
/**
|
||||
@ -56,9 +56,12 @@ export class Smartdns {
|
||||
if (runCycles < cyclesArg) {
|
||||
runCycles++;
|
||||
try {
|
||||
const myRecordArray = await this.getRecord(recordNameArg, recordTypeArg);
|
||||
const myRecordArray = await this.getRecordWithNodeDNS(recordNameArg, recordTypeArg);
|
||||
const myRecord = myRecordArray[0].value;
|
||||
if (myRecord === expectedValue) {
|
||||
console.log(
|
||||
`smartdns: .checkUntilAvailable() verified that wanted >>>${recordTypeArg}<<< record exists for >>>${recordNameArg}<<< with value >>>${expectedValue}<<<`
|
||||
);
|
||||
return true;
|
||||
} else {
|
||||
await plugins.smartdelay.delayFor(intervalArg);
|
||||
@ -69,7 +72,9 @@ export class Smartdns {
|
||||
return await doCheck();
|
||||
}
|
||||
} else {
|
||||
console.log('failed permanently...');
|
||||
console.log(
|
||||
`smartdns: .checkUntilAvailable() failed permanently for ${recordNameArg} with value ${recordTypeArg} - ${expectedValue}...`
|
||||
);
|
||||
return false;
|
||||
}
|
||||
};
|
||||
@ -101,9 +106,12 @@ export class Smartdns {
|
||||
recordNameArg: string,
|
||||
recordTypeArg: plugins.tsclass.network.TDnsRecordType
|
||||
): Promise<plugins.tsclass.network.IDnsRecord[]> {
|
||||
const requestUrl = `https://dns.google/resolve?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'
|
||||
method: 'GET',
|
||||
headers: {
|
||||
accept: 'application/dns-json',
|
||||
},
|
||||
});
|
||||
const returnArray: plugins.tsclass.network.IDnsRecord[] = [];
|
||||
const responseBody: IGoogleDNSHTTPSResponse = response.body;
|
||||
@ -118,7 +126,7 @@ export class Smartdns {
|
||||
name: dnsEntry.name,
|
||||
type: this.convertDnsTypeNumberToTypeName(dnsEntry.type),
|
||||
dnsSecEnabled: responseBody.AD,
|
||||
value: dnsEntry.data
|
||||
value: dnsEntry.data,
|
||||
});
|
||||
}
|
||||
// console.log(responseBody);
|
||||
@ -132,6 +140,7 @@ export class Smartdns {
|
||||
recordNameArg: string,
|
||||
recordTypeArg: plugins.tsclass.network.TDnsRecordType
|
||||
): Promise<plugins.tsclass.network.IDnsRecord[]> {
|
||||
this.setNodeDnsProvider('cloudflare');
|
||||
const done = plugins.smartpromise.defer<plugins.tsclass.network.IDnsRecord[]>();
|
||||
plugins.dns.resolve(recordNameArg, recordTypeArg, (err, recordsArg) => {
|
||||
if (err) {
|
||||
@ -142,9 +151,9 @@ export class Smartdns {
|
||||
for (const recordKey in recordsArg) {
|
||||
returnArray.push({
|
||||
name: recordNameArg,
|
||||
value: recordsArg[recordKey],
|
||||
value: recordsArg[recordKey][0],
|
||||
type: recordTypeArg,
|
||||
dnsSecEnabled: false
|
||||
dnsSecEnabled: false,
|
||||
});
|
||||
}
|
||||
done.resolve(returnArray);
|
||||
@ -169,14 +178,16 @@ export class Smartdns {
|
||||
* set the DNS provider
|
||||
*/
|
||||
public setNodeDnsProvider(dnsProvider: TDnsProvider) {
|
||||
if (!this.dnsServerIp) {
|
||||
console.log(
|
||||
`Warning: Setting the nodejs dns authority to ${dnsProvider}. Only do this if you know what you are doing.`
|
||||
);
|
||||
if (dnsProvider === 'google') {
|
||||
}
|
||||
if (dnsProvider === 'google' && this.dnsServerIp !== '8.8.8.8') {
|
||||
this.dnsServerIp = '8.8.8.8';
|
||||
this.dnsServerPort = 53;
|
||||
plugins.dns.setServers(['8.8.8.8', '8.8.4.4']);
|
||||
} else if (dnsProvider === 'cloudflare') {
|
||||
} else if (dnsProvider === 'cloudflare' && this.dnsServerIp !== '1.1.1.1') {
|
||||
this.dnsServerIp = '1.1.1.1';
|
||||
this.dnsServerPort = 53;
|
||||
plugins.dns.setServers(['1.1.1.1', '1.0.0.1']);
|
||||
|
Reference in New Issue
Block a user