Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
// Reverse IP for lookup
lookup = host.split(/\./).reverse().join('.');
}
if (net.isIPv6(host)) {
if (/^(?:1|true|yes|enabled|on)$/i.test(lists[zone].not_ipv6_compatible) || /^(?:1|true|yes|enabled|on)$/i.test(lists[zone].no_ip_lookups)) {
results.add(plugin, {skip: `IP (${host}) not supported for ${zone}` });
continue;
}
// Skip any private IPs
if (net_utils.is_private_ip(host)) {
results.add(plugin, {skip: 'private IP' });
continue;
}
// Reverse IP for lookup
lookup = net_utils.ipv6_reverse(host);
}
// Handle zones that require host to be stripped to a domain boundary
else if (/^(?:1|true|yes|enabled|on)$/i.test(lists[zone].strip_to_domain)) {
lookup = (tlds.split_hostname(host, 3))[1];
}
// Anything else..
else {
lookup = host;
}
if (!lookup) continue;
if (!queries[zone]) queries[zone] = {};
if (Object.keys(queries[zone]).length > lists.main.max_uris_per_list) {
connection.logwarn(plugin, `discarding lookup ${lookup} for zone ${zone} maximum query limit reached`);
results.add(plugin, {skip: `max query limit for ${zone}` });
continue;
}
exports.lookup = function (lookup, zone, cb) {
const self = this;
if (!lookup || !zone) {
return setImmediate(() => cb(new Error('missing data')));
}
if (this.enable_stats) { this.init_redis(); }
// Reverse lookup if IPv4 address
if (net.isIPv4(lookup)) {
lookup = lookup.split('.').reverse().join('.');
}
else if (net.isIPv6(lookup)) {
lookup = net_utils.ipv6_reverse(lookup);
}
let start;
if (this.enable_stats) {
start = new Date().getTime();
}
// Build the query, adding the root dot if missing
let query = [lookup, zone].join('.');
if (query[query.length - 1] !== '.') {
query += '.';
}
this.logdebug('looking up: ' + query);
// IS: IPv6 compatible (maybe; only if BL return IPv4 answers)
dns.resolve(query, 'A', (err, a) => {
self.stats_incr_zone(err, zone, start); // Statistics