num-client
Advanced tools
Comparing version 1.0.26 to 1.0.27
@@ -5,3 +5,6 @@ import { AxiosProxy } from './axiosproxy'; | ||
readonly url: string; | ||
activeFrom: number; | ||
constructor(name: string, url: string); | ||
isActive(): boolean; | ||
disableForSeconds(n: number): void; | ||
} | ||
@@ -8,0 +11,0 @@ export declare class Question { |
@@ -52,3 +52,10 @@ "use strict"; | ||
this.url = url; | ||
this.activeFrom = Date.now(); | ||
} | ||
DoHResolver.prototype.isActive = function () { | ||
return this.activeFrom <= Date.now(); | ||
}; | ||
DoHResolver.prototype.disableForSeconds = function (n) { | ||
this.activeFrom = Date.now() + 1000 * n; | ||
}; | ||
return DoHResolver; | ||
@@ -55,0 +62,0 @@ }()); |
@@ -136,2 +136,3 @@ "use strict"; | ||
question = new dnsclient_1.Question(query, 'TXT', checkDnsSecValidity); | ||
dohIndex = this.findActiveResolver(dohIndex); | ||
loglevel_1.default.debug("Using DoH: " + this.dnsClients[dohIndex].getResolver().name); | ||
@@ -151,3 +152,5 @@ return [2, this.dnsClients[dohIndex] | ||
} | ||
dohIndex = (dohIndex + 1) % _this.dnsClients.length; | ||
loglevel_1.default.info("The current resolver failed so disable it for a while: " + _this.dnsClients[dohIndex].getResolver().name); | ||
_this.dnsClients[dohIndex].getResolver().disableForSeconds(5); | ||
dohIndex = _this.findActiveResolver(dohIndex); | ||
loglevel_1.default.warn("Switching to DoH: " + _this.dnsClients[dohIndex].getResolver().name + " due to " + JSON.stringify(e)); | ||
@@ -159,4 +162,18 @@ return _this._getRecordFromDns(query, checkDnsSecValidity, attempts - 1, dohIndex); | ||
}; | ||
DnsServicesImpl.prototype.findActiveResolver = function (dohIndex) { | ||
for (var i = 0; i < this.dnsClients.length; i++) { | ||
dohIndex = (dohIndex + 1) % this.dnsClients.length; | ||
if (this.dnsClients[dohIndex].getResolver().isActive()) { | ||
loglevel_1.default.info("Found an active resolver: " + this.dnsClients[dohIndex].getResolver().name); | ||
break; | ||
} | ||
} | ||
if (!this.dnsClients[dohIndex].getResolver().isActive()) { | ||
loglevel_1.default.info("Can't find an active resolver so re-using this one: " + this.dnsClients[dohIndex].getResolver().name); | ||
this.dnsClients[dohIndex].getResolver().activeFrom = Date.now(); | ||
} | ||
return dohIndex; | ||
}; | ||
return DnsServicesImpl; | ||
}()); | ||
//# sourceMappingURL=dnsservices.js.map |
{ | ||
"name": "num-client", | ||
"version": "1.0.26", | ||
"version": "1.0.27", | ||
"description": "A NUM Protocol Client in TypeScript", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
521256
2916