Compare commits

...

4 Commits

Author SHA1 Message Date
c8cf590a5a 4.0.3 2020-02-19 21:38:43 +00:00
42f679ef61 fix(core): update 2020-02-19 21:38:42 +00:00
0cb882bb7d 4.0.2 2020-02-15 16:46:46 +00:00
66f817cdf8 fix(core): update 2020-02-15 16:46:46 +00:00
4 changed files with 17 additions and 11 deletions

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "@pushrocks/smartdns",
"version": "4.0.1",
"version": "4.0.3",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@ -1,6 +1,6 @@
{
"name": "@pushrocks/smartdns",
"version": "4.0.1",
"version": "4.0.3",
"private": false,
"description": "smart dns methods written in TypeScript",
"main": "dist/index.js",

View File

@ -22,7 +22,7 @@ Use TypeScript for best in class instellisense.
```typescript
const mySmartDns = new smartdns.SmartDns(); // uses Google DNS Https API
const demoRecord = mySmartDns.getRecord('example.com', 'AAAA'); // returns promise
const demoRecord = await mySmartDns.getRecord('example.com', 'AAAA'); // returns promise
/*
demoRecord looks like this:
{

View File

@ -56,9 +56,10 @@ 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 +70,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;
}
};
@ -132,6 +135,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,7 +146,7 @@ export class Smartdns {
for (const recordKey in recordsArg) {
returnArray.push({
name: recordNameArg,
value: recordsArg[recordKey],
value: recordsArg[recordKey][0],
type: recordTypeArg,
dnsSecEnabled: false
});
@ -169,14 +173,16 @@ export class Smartdns {
* set the DNS provider
*/
public setNodeDnsProvider(dnsProvider: TDnsProvider) {
console.log(
`Warning: Setting the nodejs dns authority to ${dnsProvider}. Only do this if you know what you are doing.`
);
if (dnsProvider === 'google') {
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') {
} 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']);