Skip to content

Commit

Permalink
Reduce log noise from same_ipv4_network (#35)
Browse files Browse the repository at this point in the history
The net_utils.same_ipv4_network function calls console.error if given a
non-ipv4 address:

        same_ipv4_network, IP in list is not IPv4!'

The ip_list input to that function comes from get_ips_by_host, whose
output is the result of both resolve4 and resolve6. So for
same_ipv4_network not to generate log noise, we need to filter its
input.

Co-authored-by: Kevin M. Goess <[email protected]>
Co-authored-by: Matt Simerson <[email protected]>
  • Loading branch information
3 people authored Apr 7, 2022
1 parent 4d4e407 commit 10cb5af
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

// build in node modules
const dns = require('dns')
const net = require('net')

// NPM modules
const constants = require('haraka-constants')
Expand Down Expand Up @@ -249,7 +250,8 @@ exports.ptr_compare = function (ip_list, connection, domain) {
connection.results.push(plugin, {fcrdns: domain})
return true
}
if (net_utils.same_ipv4_network(connection.remote.ip, ip_list)) {
const ip_list_ipv4 = ip_list.filter(net.isIPv4)
if (ip_list_ipv4.length && net_utils.same_ipv4_network(connection.remote.ip, ip_list_ipv4)) {
connection.results.add(plugin, {pass: 'fcrdns(net)' })
connection.results.push(plugin, {fcrdns: domain})
return true
Expand Down

0 comments on commit 10cb5af

Please sign in to comment.