mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-11-27 16:54:04 +00:00
Fixes issue with ::1 port 5300 requests
Now the address is wrapped in `[]` in order to prevent ::1 port 5300 being interpreted as ::1:5300. Wrapping the IPv4 address in `[]` does seem to have any effect on correct domain name resolution. In order to prevent issues if a user inputs an address with brackets, they are removed from the string if present before being re-added when it is passed to `setServers`. I have also removed the JSDoc comment as this will be added in a seperate PR Signed-off-by: Matthew Nickson <mnickson@sidingsmedia.com>
This commit is contained in:
parent
8c8eeaf627
commit
a680331dd7
1 changed files with 4 additions and 9 deletions
|
@ -88,17 +88,12 @@ exports.pingAsync = function (hostname, ipv6 = false) {
|
|||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Resolves a given record using the specified DNS server
|
||||
* @param {string} hostname The hostname of the record to lookup
|
||||
* @param {string} resolver_server The DNS server to use
|
||||
* @param {string} resolver_port The port the DNS server is listening on
|
||||
* @param {string} rrtype The type of record to request
|
||||
* @returns {Promise} Promise object represents DNS lookup result
|
||||
*/
|
||||
exports.dnsResolve = function (hostname, resolver_server, resolver_port, rrtype) {
|
||||
const resolver = new Resolver();
|
||||
resolver.setServers([`${resolver_server}:${resolver_port}`]);
|
||||
// Remove brackets from IPv6 addresses so we can re-add them to
|
||||
// prevent issues with ::1:5300 (::1 port 5300)
|
||||
resolver_server = resolver_server.replace("[", "").replace("]", "");
|
||||
resolver.setServers([`[${resolver_server}]:${resolver_port}`]);
|
||||
return new Promise((resolve, reject) => {
|
||||
if (rrtype == "PTR") {
|
||||
resolver.reverse(hostname, (err, records) => {
|
||||
|
|
Loading…
Reference in a new issue