Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

haraka-plugin-geoip

haraka11.5kMIT1.1.1

provide geographic information about mail senders.

haraka, email, geoip, smtp, mta

readme

Build Status Code Climate

haraka-plugin-geoip

provide geographic information about mail senders.

SYNOPSIS

Use MaxMind's GeoIP databases to report geographic information about senders.

This Haraka plugin supports two geoip modules:

Plugin geoip module
haraka-plugin-geoip maxmind
haraka-plugin-geoip-lite geoip-lite

INSTALL (lite)

Install the npm geoip-lite module and update the DBs:

npm install -g geoip-lite
cd node_modules/geoip-lite && npm run-script updatedb license_key=YOUR_LICENSE_KEY

INSTALL (maxmind)

The maxmind module requires the manual download of the GeoIP databases. The npm module maxmind-geolite-mirror will download the files for you and also keep them up-to-date if you run it periodically.

mkdir -p /usr/local/share/GeoIP
npm install -g maxmind-geolite-mirror
/usr/local/bin/maxmind-geolite-mirror

DESCRIPTION

GeoIP results are stored in connection.notes.geoip and the haraka-results object at connection.results.get(geoip). The following information is typically available:

continent: NA,
country:   US,

If the GeoIP city database is available, the following may also be available:

region:   CA,
city:     San Francisco,
ll:       [37.7484, -122.4156],
distance: 1539    // in kilometers
range:    [ 3479299040, 3479299071 ],

This module also adds entries like this to your logs:

[geoip] US
[geoip] US, WA
[geoip] US, WA, Seattle
[geoip] US, WA, Seattle, 1319km

Calculating the distance requires the public IP of this mail server. See config.distance.

CONFIG

  • distance

Performs geodesic distance calculations. Calculates the distance "as the crow flies" from the remote mail server.

This calculation requires a 'from' IP address. This will typically be the public IP of your mail server. If Haraka is bound to a private IP, net_utils will attempt to determine your public IP using STUN. If that doesn't work, edit config/smtp.ini and set public_ip.

  • show.city

show city data in logs and headers. City data is less accurate than country.

  • show.region in logs and headers. Regional data are US states, Canadian provinces and such.

Set a connection result to true if the distance exceeds this many kilometers.

  • too_far=4000

SPAM PREDICTION WITH DISTANCE

Spatio-temporal Network-level Automatic Reputation Engine

"For ham, 90% of the messages travel about 4,000 km or less. On the
other hand, for spam, only 28% of messages stay within this range."

Observations in 2014-2016 suggest that geodesic distance continues to be highly correlated with spam.

LIMITATIONS

The distance calculations are more concerned with being fast than accurate. The MaxMind location data is collected from whois and is of limited accuracy. MaxMind offers more accurate data for a fee.

For distance calculations, the earth is considered a perfect sphere. In reality, it is not. Accuracy should be within 1%.

SEE ALSO

changelog

Changelog

The format is based on Keep a Changelog.

Unreleased

1.1.1 - 2025-01-26

  • deps(builtins): prefix with 'node:'
  • deps(all): bump to latest
  • dep(eslint): upgrade to v9
  • doc(CONTRIBUTORS): added
  • populate [files] in package.json. Delete .npmignore.
  • style: automated formatting with prettier
  • index.received_header: refactor with es6

1.1.0 - 2024-04-02

  • index: turn off watchForUpdates
  • index: reset regex index to zero after each call to exec #58
  • deps: bump and pin versions
  • ci: add trigger to run tests on PR #60
  • test: add received_header #61
  • test: use async where possible
  • test: remove done when superfluous

1.0.17 - 2022-11-14

  • dep(node-maxmind): bump to 4.3.8
  • ci workflow updates, #56
  • ci(codeql): Add workflow for GitHub code scanning, #55

1.0.16 - 2022-05-22

  • only use 'plugin = this' where needed
  • dep(maxmind): 4.1 -> 4.3

1.0.15 - 2020-09-03

  • revert plugin rename from #44
  • update tests to make it easier to sync

1.0.14 - 2020-09-01

  • fix connection result access since plugin rename #44
  • bump maxmind version to 4.1
  • wrap city & country lookups in a try

1.0.13 - 2020-01-28

  • properly continue loop when one of database file missing

1.0.12 - 2019-11-10

  • bump maxmind to v4
  • revert exported arrow functions, they break the plugin
  • include DBs and remove test conditionals that masked broken tests

1.0.11 - 2019-10-13

  • bump maxmind version to 3.1.2
  • switch tests from nodeunit to mocha

1.0.10 - 2019-07-16

  • move from maxmind.openSync to async maxmind.open, #35

1.0.9 - 2019-07-09

  • drop node 6 testing
  • use maxmind v3

1.0.8 - 2018-09-03

  • add missing 'c' in iso_code.
  • safely access country.iso_code

1.0.7 - 2018-01-19

  • code climate updates #25
  • missing iso_code #24
  • replace string concatenations with template literals #23
  • add tests for latitude == 0, #22
  • Fix issue with latitude == 0, #21

1.0.6 - 2017-10-21

  • fix lookup exception #18
  • eslint no-var updates #17
  • replace node 4 with node 8 testing #15

1.0.5 - 2017-06-16

  • compat with eslint 4

1.0.4 - 2016-02-07

  • aggregate results before emitting
  • README link cleanups