haraka / haraka-plugin-geoip

provide geographic information about mail senders
https://www.npmjs.com/package/haraka-plugin-geoip
MIT License
4 stars 11 forks source link

Fixed issue with latitude == 0 #21

Closed lnedry closed 6 years ago

lnedry commented 6 years ago

Emails from an IP address in the Congo where latitude was equal to zero caused this plugin to throw an exception.

msimerson commented 6 years ago

I don't understand how this fixes it, since 0 is still finite:

$ node
> isFinite(0)
true
lnedry commented 6 years ago

Yes, 0 is finite but also false. Currently if latitude == 0 an exception will end up being thrown (see below). Testing latitude with isFinite() will appropriately return true for this case. I think isFinite is more appropriate than !isNaN.

Plugin geoip failed: TypeError: Cannot read property '0' of undefined at cb (/usr/lib/node_modules/Haraka/node_modules/haraka-plugin-geoip/index.js:228:62) at Plugin.exports.calculate_distance (/usr/lib/node_modules/Haraka/node_modules/haraka-plugin-geoip/index.js:240:31) at Plugin.exports.lookup_maxmind (/usr/lib/node_modules/Haraka/node_modules/haraka-plugin-geoip/index.js:120:10) at Object.plugins.run_next_hook (/usr/lib/node_modules/Haraka/plugins.js:506:28) at Object.plugins.run_hooks (/usr/lib/node_modules/Haraka/plugins.js:421:13) at Connection.rdns_response (/usr/lib/node_modules/Haraka/connection.js:776:13) at /usr/lib/node_modules/Haraka/connection.js:754:22 at QueryReqWrap.asyncCallback [as callback] (dns.js:62:16) at QueryReqWrap.onresolve [as oncomplete] (dns.js:219:10)