mirror of
https://github.com/thelounge/thelounge
synced 2024-11-22 20:13:07 +00:00
parent
257ce5d0a8
commit
d3a98a523f
1 changed files with 16 additions and 4 deletions
|
@ -744,11 +744,23 @@ function performAuthentication(data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function reverseDnsLookup(ip, callback) {
|
function reverseDnsLookup(ip, callback) {
|
||||||
dns.reverse(ip, (err, hostnames) => {
|
dns.reverse(ip, (reverseErr, hostnames) => {
|
||||||
if (!err && hostnames.length) {
|
if (reverseErr || hostnames.length < 1) {
|
||||||
return callback(hostnames[0]);
|
return callback(ip);
|
||||||
}
|
}
|
||||||
|
|
||||||
callback(ip);
|
dns.resolve(hostnames[0], net.isIP(ip) === 6 ? "AAAA" : "A", (resolveErr, resolvedIps) => {
|
||||||
|
if (resolveErr || resolvedIps.length < 1) {
|
||||||
|
return callback(ip);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const resolvedIp of resolvedIps) {
|
||||||
|
if (ip === resolvedIp) {
|
||||||
|
return callback(hostnames[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return callback(ip);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue