fix(core): update
This commit is contained in:
parent
228bc88d60
commit
e04485231d
5
package-lock.json
generated
5
package-lock.json
generated
@ -4495,6 +4495,11 @@
|
|||||||
"dns-packet": "^5.1.2"
|
"dns-packet": "^5.1.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"dns2": {
|
||||||
|
"version": "1.4.2",
|
||||||
|
"resolved": "https://verdaccio.lossless.one/dns2/-/dns2-1.4.2.tgz",
|
||||||
|
"integrity": "sha512-cRapXqyLsCW5HMBQg2pTkDnSe3KXjysWnU756epw554HJZRrqo4cD3xghCOFmZIgVzxhotiGsLGEH8QCq5cKnw=="
|
||||||
|
},
|
||||||
"dom-serializer": {
|
"dom-serializer": {
|
||||||
"version": "0.2.2",
|
"version": "0.2.2",
|
||||||
"resolved": "https://verdaccio.lossless.one/dom-serializer/-/dom-serializer-0.2.2.tgz",
|
"resolved": "https://verdaccio.lossless.one/dom-serializer/-/dom-serializer-0.2.2.tgz",
|
||||||
|
@ -26,9 +26,11 @@
|
|||||||
"homepage": "https://gitlab.com/pushrocks/dnsly#README",
|
"homepage": "https://gitlab.com/pushrocks/dnsly#README",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pushrocks/smartdelay": "^2.0.10",
|
"@pushrocks/smartdelay": "^2.0.10",
|
||||||
|
"@pushrocks/smartenv": "^4.0.16",
|
||||||
"@pushrocks/smartpromise": "^3.0.6",
|
"@pushrocks/smartpromise": "^3.0.6",
|
||||||
"@pushrocks/smartrequest": "^1.1.47",
|
"@pushrocks/smartrequest": "^1.1.47",
|
||||||
"@tsclass/tsclass": "^3.0.21"
|
"@tsclass/tsclass": "^3.0.21",
|
||||||
|
"dns2": "^1.4.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.24",
|
"@gitzone/tsbuild": "^2.1.24",
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
|
import * as smartenv from '@pushrocks/smartenv';
|
||||||
|
const smartenvInstance = new smartenv.Smartenv();
|
||||||
// node native scope
|
// node native scope
|
||||||
import * as dns from 'dns';
|
import type dnsType from 'dns';
|
||||||
|
const dns: typeof dnsType = smartenvInstance.getSafeNodeModule('dns');
|
||||||
|
|
||||||
export { dns };
|
export { dns };
|
||||||
|
|
||||||
@ -8,8 +11,16 @@ import * as smartdelay from '@pushrocks/smartdelay';
|
|||||||
import * as smartpromise from '@pushrocks/smartpromise';
|
import * as smartpromise from '@pushrocks/smartpromise';
|
||||||
import * as smartrequest from '@pushrocks/smartrequest';
|
import * as smartrequest from '@pushrocks/smartrequest';
|
||||||
|
|
||||||
export { smartdelay, smartpromise, smartrequest };
|
export { smartdelay, smartenv, smartpromise, smartrequest };
|
||||||
|
|
||||||
import * as tsclass from '@tsclass/tsclass';
|
import * as tsclass from '@tsclass/tsclass';
|
||||||
|
|
||||||
export { tsclass };
|
export { tsclass };
|
||||||
|
|
||||||
|
// third party scope
|
||||||
|
|
||||||
|
const dns2 = smartenvInstance.getSafeNodeModule('dns2');
|
||||||
|
|
||||||
|
export {
|
||||||
|
dns2
|
||||||
|
}
|
||||||
|
31
ts/index.ts
31
ts/index.ts
@ -56,7 +56,12 @@ export class Smartdns {
|
|||||||
if (runCycles < cyclesArg) {
|
if (runCycles < cyclesArg) {
|
||||||
runCycles++;
|
runCycles++;
|
||||||
try {
|
try {
|
||||||
const myRecordArray = await this.getRecordWithNodeDNS(recordNameArg, recordTypeArg);
|
let myRecordArray: plugins.tsclass.network.IDnsRecord[];
|
||||||
|
if (runCycles % 2 === 0 || !plugins.dns) {
|
||||||
|
myRecordArray = await this.getRecord(recordNameArg, recordTypeArg);
|
||||||
|
} else {
|
||||||
|
myRecordArray = await this.getRecordWithNodeDNS(recordNameArg, recordTypeArg);
|
||||||
|
}
|
||||||
const myRecord = myRecordArray[0].value;
|
const myRecord = myRecordArray[0].value;
|
||||||
if (myRecord === expectedValue) {
|
if (myRecord === expectedValue) {
|
||||||
console.log(
|
console.log(
|
||||||
@ -68,6 +73,7 @@ export class Smartdns {
|
|||||||
return await doCheck();
|
return await doCheck();
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
// console.log(err);
|
||||||
await plugins.smartdelay.delayFor(intervalArg);
|
await plugins.smartdelay.delayFor(intervalArg);
|
||||||
return await doCheck();
|
return await doCheck();
|
||||||
}
|
}
|
||||||
@ -140,7 +146,6 @@ export class Smartdns {
|
|||||||
recordNameArg: string,
|
recordNameArg: string,
|
||||||
recordTypeArg: plugins.tsclass.network.TDnsRecordType
|
recordTypeArg: plugins.tsclass.network.TDnsRecordType
|
||||||
): Promise<plugins.tsclass.network.IDnsRecord[]> {
|
): Promise<plugins.tsclass.network.IDnsRecord[]> {
|
||||||
this.setNodeDnsProvider('cloudflare');
|
|
||||||
const done = plugins.smartpromise.defer<plugins.tsclass.network.IDnsRecord[]>();
|
const done = plugins.smartpromise.defer<plugins.tsclass.network.IDnsRecord[]>();
|
||||||
plugins.dns.resolve(recordNameArg, recordTypeArg, (err, recordsArg) => {
|
plugins.dns.resolve(recordNameArg, recordTypeArg, (err, recordsArg) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
@ -174,28 +179,6 @@ export class Smartdns {
|
|||||||
return await done.promise;
|
return await done.promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 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' && 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' && 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']);
|
|
||||||
} else {
|
|
||||||
throw new Error('unknown dns provider');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public convertDnsTypeNameToTypeNumber(dnsTypeNameArg: string): number {
|
public convertDnsTypeNameToTypeNumber(dnsTypeNameArg: string): number {
|
||||||
return this.dnsTypeMap[dnsTypeNameArg];
|
return this.dnsTypeMap[dnsTypeNameArg];
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user