fix(core): update
This commit is contained in:
parent
0cb882bb7d
commit
42f679ef61
16
ts/index.ts
16
ts/index.ts
@ -56,9 +56,10 @@ export class Smartdns {
|
|||||||
if (runCycles < cyclesArg) {
|
if (runCycles < cyclesArg) {
|
||||||
runCycles++;
|
runCycles++;
|
||||||
try {
|
try {
|
||||||
const myRecordArray = await this.getRecord(recordNameArg, recordTypeArg);
|
const myRecordArray = await this.getRecordWithNodeDNS(recordNameArg, recordTypeArg);
|
||||||
const myRecord = myRecordArray[0].value;
|
const myRecord = myRecordArray[0].value;
|
||||||
if (myRecord === expectedValue) {
|
if (myRecord === expectedValue) {
|
||||||
|
console.log(`smartdns: .checkUntilAvailable() verified that wanted >>>${recordTypeArg}<<< record exists for >>>${recordNameArg}<<< with value >>>${expectedValue}<<<`);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
await plugins.smartdelay.delayFor(intervalArg);
|
await plugins.smartdelay.delayFor(intervalArg);
|
||||||
@ -69,7 +70,9 @@ export class Smartdns {
|
|||||||
return await doCheck();
|
return await doCheck();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.log('failed permanently...');
|
console.log(
|
||||||
|
`smartdns: .checkUntilAvailable() failed permanently for ${recordNameArg} with value ${recordTypeArg} - ${expectedValue}...`
|
||||||
|
);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -132,6 +135,7 @@ 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) {
|
||||||
@ -142,7 +146,7 @@ export class Smartdns {
|
|||||||
for (const recordKey in recordsArg) {
|
for (const recordKey in recordsArg) {
|
||||||
returnArray.push({
|
returnArray.push({
|
||||||
name: recordNameArg,
|
name: recordNameArg,
|
||||||
value: recordsArg[recordKey],
|
value: recordsArg[recordKey][0],
|
||||||
type: recordTypeArg,
|
type: recordTypeArg,
|
||||||
dnsSecEnabled: false
|
dnsSecEnabled: false
|
||||||
});
|
});
|
||||||
@ -169,14 +173,16 @@ export class Smartdns {
|
|||||||
* set the DNS provider
|
* set the DNS provider
|
||||||
*/
|
*/
|
||||||
public setNodeDnsProvider(dnsProvider: TDnsProvider) {
|
public setNodeDnsProvider(dnsProvider: TDnsProvider) {
|
||||||
|
if (!this.dnsServerIp) {
|
||||||
console.log(
|
console.log(
|
||||||
`Warning: Setting the nodejs dns authority to ${dnsProvider}. Only do this if you know what you are doing.`
|
`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.dnsServerIp = '8.8.8.8';
|
||||||
this.dnsServerPort = 53;
|
this.dnsServerPort = 53;
|
||||||
plugins.dns.setServers(['8.8.8.8', '8.8.4.4']);
|
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.dnsServerIp = '1.1.1.1';
|
||||||
this.dnsServerPort = 53;
|
this.dnsServerPort = 53;
|
||||||
plugins.dns.setServers(['1.1.1.1', '1.0.0.1']);
|
plugins.dns.setServers(['1.1.1.1', '1.0.0.1']);
|
||||||
|
Loading…
Reference in New Issue
Block a user