fix(core): update

This commit is contained in:
Philipp Kunz 2020-02-19 21:38:42 +00:00
parent 0cb882bb7d
commit 42f679ef61

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']);