Git Product home page Git Product logo

haraka-net-utils's Introduction

Haraka - a Node.js Mail Server

Tests Coverage Status

Haraka is a highly scalable node.js email server with a modular plugin architecture. Haraka can serve thousands of concurrent connections and deliver thousands of messages per second. Haraka and plugins are written in asynchronous JS and are very fast.

Haraka has very good spam protection (see plugins) and works well as a filtering MTA. It also works well as a MSA running on port 587 with auth and dkim_sign plugins enabled.

Haraka makes no attempt to be a mail store (like Exchange or Postfix/Exim/Qmail), a LDA, nor an IMAP server (like Dovecot or Courier). Haraka is typically used with such systems.

Haraka has a scalable outbound mail delivery engine built in. Mail marked as relaying (such as via an auth plugin) is automatically queued for outbound delivery.

Getting Help

Screencast

Getting started with Haraka

Why Use Haraka?

Haraka's plugin architecture provides an easily extensible MTA that complements traditional MTAs that excel at managing mail stores but do not have sufficient filtering.

The plugin system makes it easy to code new features. A typical example is providing qmail-like extended addresses to an Exchange system, whereby you could receive mail as [email protected], and yet still have it correctly routed to [email protected]. This is a few lines of code in Haraka.

Plugins are provided for running mail through SpamAssassin, validating HELO names, checking DNS Blocklists, and many others.

Installing Haraka

Haraka requires node.js to run. Install Haraka with npm:

# If the second command gives "nobody" errors, uncomment & run the next command
# npm -g config set user root
npm install -g Haraka

After installation, use the haraka binary to set up the service.

Running Haraka

First, create the service:

haraka -i /path/to/haraka_test

That creates the directory haraka_test with config and plugin directories within. It also sets the host name used by Haraka to the output of hostname.

If hostname is not correct, edit config/host_list. For example, to receive mail addressed to [email protected], add domain.com to the config/host_list file.

Finally, start Haraka using root permissions:

haraka -c /path/to/haraka_test

And it will run.

Configure Haraka

To choose which plugins run, edit config/plugins. Plugins control the overall behaviour of Haraka. By default, only messages to domains listed in config/host_list will be accepted and then delivered via the smtp-forward plugin. Configure the destination in config/smtp_forward.ini.

Read the Fine Manual

haraka -h plugins/$name

The docs detail how each plugin is configured. After editing config/plugins, restart Haraka and enjoy!

Running from git

If you are unable to use npm to install Haraka, you can run from git by following these steps:

First clone the repository:

$ git clone https://github.com/haraka/Haraka.git
$ cd Haraka

Install Haraka's node.js dependencies locally:

$ npm install

Edit config/plugins and config/smtp.ini to specify the plugins and config you want.

Finally run Haraka:

$ node haraka.js

License and Author

Haraka is MIT licensed - see the LICENSE file for details.

Haraka is a project started by Matt Sergeant, a 10 year veteran of the email and anti-spam world. Previous projects have been the project leader for SpamAssassin and a hacker on Qpsmtpd.

haraka-net-utils's People

Contributors

baudehlo avatar dependabot[bot] avatar doobled avatar greenkeeper[bot] avatar juerd avatar lnedry avatar msimerson avatar olsonpm avatar typingartist avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

haraka-net-utils's Issues

openssl-wrapper dependency removal

openssl-wrapper is currently a dependency in this package. As part of the TLS revamping project I moved all the TLS functions out of this package and into Haraka/tls_socket.js. Unfortunately, I didn't move the openssl-wrapper dependency to Haraka's package.json. It worked fine because this is a Haraka dep but now there are published versions of Haraka that won't work unless openssl-wrapper is included in this package. I haven't thought of a "doesn't hurt someone" solution.

Version 10 of node.js has been released

Version 10 of Node.js (code name Dubnium) has been released! 🎊

To see what happens to your code in Node.js 10, Greenkeeper has created a branch with the following changes:

  • Added the new Node.js version to your .travis.yml

If you’re interested in upgrading this repo to Node.js 10, you can open a PR with these changes. Please note that this issue is just intended as a friendly reminder and the PR as a possible starting point for getting your code running on Node.js 10.

More information on this issue

Greenkeeper has checked the engines key in any package.json file, the .nvmrc file, and the .travis.yml file, if present.

  • engines was only updated if it defined a single version, not a range.
  • .nvmrc was updated to Node.js 10
  • .travis.yml was only changed if there was a root-level node_js that didn’t already include Node.js 10, such as node or lts/*. In this case, the new version was appended to the list. We didn’t touch job or matrix configurations because these tend to be quite specific and complex, and it’s difficult to infer what the intentions were.

For many simpler .travis.yml configurations, this PR should suffice as-is, but depending on what you’re doing it may require additional work or may not be applicable at all. We’re also aware that you may have good reasons to not update to Node.js 10, which is why this was sent as an issue and not a pull request. Feel free to delete it without comment, I’m a humble robot and won’t feel rejected 🤖


FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

STUN timeout fails

A STUN timeout does not end the test if Stun is not installed and running.

Haraka Haraka.js — Version: 3.0.2
Node v20.11.0
OS Linux mx 5.10.0-27-amd64 #1 SMP Debian 5.10.205-2 (2023-12-31) x86_64 GNU/Linux
openssl OpenSSL 1.1.1w 11 Sep 2023

This is a fresh install of Haraka on Debian 11. Stun is not installed.

With this command, I get four errors
# time npm test

  103 passing (8s)
  4 failing

  1) is_local_host
       127.0.0.1:
     Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (/etc/haraka/node_modules/haraka-net-utils/test/net_utils.js)
      at listOnTimeout (node:internal/timers:573:17)
      at process.processTimers (node:internal/timers:514:7)

  2) is_local_host
       self ip:
     Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (/etc/haraka/node_modules/haraka-net-utils/test/net_utils.js)
      at listOnTimeout (node:internal/timers:573:17)
      at process.processTimers (node:internal/timers:514:7)

  3) get_public_ip
       normal:
     Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (/etc/haraka/node_modules/haraka-net-utils/test/net_utils.js)
      at listOnTimeout (node:internal/timers:573:17)
      at process.processTimers (node:internal/timers:514:7)

  4) get_public_ip_async
       normal:
     Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (/etc/haraka/node_modules/haraka-net-utils/test/net_utils.js)
      at listOnTimeout (node:internal/timers:573:17)
      at process.processTimers (node:internal/timers:514:7)

After 10 seconds I get three STUN timeouts:

Error: STUN timeout
    at Timeout._onTimeout (/etc/haraka/node_modules/haraka-net-utils/index.js:327:15)
    at listOnTimeout (node:internal/timers:573:17)
    at process.processTimers (node:internal/timers:514:7)
Error: timeout
    at Timeout.<anonymous> (/etc/haraka/node_modules/haraka-net-utils/node_modules/@msimerson/stun/src/net/request.js:181:38)
    at listOnTimeout (node:internal/timers:573:17)
    at process.processTimers (node:internal/timers:514:7)
Error: timeout
    at Timeout.<anonymous> (/etc/haraka/node_modules/haraka-net-utils/node_modules/@msimerson/stun/src/net/request.js:181:38)
    at listOnTimeout (node:internal/timers:573:17)
    at process.processTimers (node:internal/timers:514:7)

After another 60 seconds the test run completes.

real	1m10.865s
user	0m1.801s
sys	0m0.358s

After installing and running stun, the tests run successfully.

net-utils: standardize & modernize

  • populate [files] in package.json. Delete .npmignore.
  • automated code linting. #3308
    • dep: eslint-plugin-haraka -> @haraka/eslint-config
    • update 'lint' script in package.json
    • verify 'lint' CI test config
  • lint: remove duplicate / stale rules from .eslintrc
  • automated code formatting (see also #3308)
  • automated CI testing.
    • mostly done, verify that local copy of ci.yml is up-to-date.
  • CONTRIBUTORS: see 3309
  • consistent naming of "special" files like CHANGELOG.md.
  • CHANGELOG: verify links at bottom (due to inconsistent tag naming)
    • latest .release does this, fixes most, and warns of errors it can't fix
  • verify GitHub repo About link points to npm package
  • convert test suites to mocha "style"
    • works great today and with node --test in v18+

1.0.13 breaks current stable Haraka (2.8.16)

Reported by EyePulp on IRC:

2018-01-25T21:34:36.566Z :: [CRIT] [-] [core] TypeError: net_utils.tls_ini_section_with_defaults is not a function
2018-01-25T21:34:36.567Z :: [CRIT] [-] [core] at Object.exports.get_tls_options (/var/projects/kaczynski/bin/haraka_installer/node_modules/Haraka/outbound/tls.js:10:35)
2018-01-25T21:34:36.568Z :: [CRIT] [-] [core] at pluggableStream. (/var/projects/kaczynski/bin/haraka_installer/node_modules/Haraka/outbound/hmail.js:774:51)
2018-01-25T21:34:36.569Z :: [CRIT] [-] [core] at emitOne (events.js:96:13)
2018-01-25T21:34:36.572Z :: [CRIT] [-] [core] at pluggableStream.emit (events.js:188:7)
2018-01-25T21:34:36.572Z :: [CRIT] [-] [core] at pluggableStream.socket.process_data (/var/projects/kaczynski/bin/haraka_installer/node_modules/Haraka/line_socket.js:24:20)
2018-01-25T21:34:36.573Z :: [CRIT] [-] [core] at pluggableStream. (/var/projects/kaczynski/bin/haraka_installer/node_modules/Haraka/line_socket.js:35:48)
2018-01-25T21:34:36.573Z :: [CRIT] [-] [core] at emitOne (events.js:96:13)
2018-01-25T21:34:36.573Z :: [CRIT] [-] [core] at pluggableStream.emit (events.js:188:7)
2018-01-25T21:34:36.574Z :: [CRIT] [-] [core] at Socket. (/var/projects/kaczynski/bin/haraka_installer/node_modules/Haraka/tls_socket.js:57:14)
2018-01-25T21:34:36.575Z :: [CRIT] [-] [core] at emitOne (events.js:96:13)

Because Haraka's package.json contains:

"dependencies": {
"haraka-net-utils" : ">=1.0.10",
},

And e1c8e8b breaks it.

Maybe we should pin versions for release in future to prevent things like this from happening?

Cc: @baudehlo

no GeoIP results for local_ip

After upgrading to the Haraka 2.8.24, haraka-plugin-geoip is now logging this error, "no GeoIP results for local_ip!"
I tracked it down to get_geoip() which calls net_utils.is_private_ip(), which calls net_utils.is_local_ip(), which returns true for my server's public IP address.

Get local ips list

Hi guys, I want to use the list of the local ips in some conditions inside a plugin that using the 'send_email' hook, is there any defined constant contain this info?

I could get the addresses using several ways, e.g :

var localAddresses = function(){
        var os = require('os');

        var interfaces = os.networkInterfaces();
        var addresses = [];
        for (var k in interfaces) {
            for (var k2 in interfaces[k]) {
                var address = interfaces[k][k2];
                if (address.family === 'IPv4' && !address.internal) {
                    addresses.push(address.address);
               	}
            }
        }

        return addresses;
}

But I think it will be better do define the list elsewhere so we don't have to retrieve the ips in every call of the plugin. (Define a global variable when the sever starting up for example).

If there's no variable contain this information, I'm not sure if the 'haraka-net-utils' is the right place to add this function.

get_ips_by_host 1.6 not working same as previous version

I've tracked down bug which hit me during dev

2024-04-19T13:12:58.833Z [DEBUG] [mail_from.is_resolvable] a.cz: MX 0 185.59.2.14 => queryAaaa ENOTFOUND 185.59.2.14
2024-04-19T13:12:58.833Z [INFO] [core] hook=mail plugin=mail_from.is_resolvable function=hook_mail params=<[email protected]> retval=DENY msg="MX without A/AAAA records"

Origin source is https://github.com/haraka/Haraka/blob/db8dbfa5cdce7fef3f6d39b1abf5c3a3f8aba60f/plugins/mail_from.is_resolvable.js#L107 - get_ips_by_host generate exactly two errors

  • queryA ENOTFOUND 185.59.2.14
  • queryAaaa ENOTFOUND 185.59.2.14

It seems that IP detection is missing somewhere

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.