-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- index: make separate if blocks in cascading list - necessary, to prevent * rule from always matching - fixes #11 - fix: wildcard + domain matches before domain. Fixes #15 - fix: rename config/aliases to config/aliases.json - lint: remove duplicate / stale rules from .eslintrc - dep: eslint-plugin-haraka -> @haraka/eslint-config - deps: bump to latest versions - chore: populate [files] in package.json - doc(CHANGELOG) renamed from Changes - doc(CONTRIBUTORS): added - ci: update to shared GHA workflows - added the option to alias all emails with \* (#12)
- Loading branch information
Showing
20 changed files
with
640 additions
and
459 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,22 @@ | ||
name: CI | ||
|
||
on: [ push ] | ||
on: [push, pull_request] | ||
|
||
env: | ||
CI: true | ||
|
||
jobs: | ||
|
||
lint: | ||
uses: haraka/.github/.github/workflows/lint.yml@master | ||
|
||
# coverage: | ||
# uses: haraka/.github/.github/workflows/coverage.yml@master | ||
# secrets: inherit | ||
|
||
test: | ||
needs: lint | ||
runs-on: ${{ matrix.os }} | ||
|
||
strategy: | ||
matrix: | ||
os: [ ubuntu-latest, windows-latest ] | ||
node-version: [ 14, 16, 18 ] | ||
fail-fast: false | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- uses: actions/setup-node@v3 | ||
name: Node ${{ matrix.node-version }} on ${{ matrix.os }} | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
|
||
- run: npm install | ||
ubuntu: | ||
needs: [lint] | ||
uses: haraka/.github/.github/workflows/ubuntu.yml@master | ||
|
||
- run: npm test | ||
windows: | ||
needs: [lint] | ||
uses: haraka/.github/.github/workflows/windows.yml@master |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule ".release"] | ||
path = .release | ||
url = [email protected]:msimerson/.release.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
singleQuote: true | ||
semi: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Changelog | ||
|
||
The format is based on [Keep a Changelog](https://keepachangelog.com/). | ||
|
||
### Unreleased | ||
|
||
### [1.0.2] - 2024-04-29 | ||
|
||
- fix: log when doing operations. Fixes #14 | ||
- index: make separate if blocks in cascading list | ||
- fix: rename config/aliases to config/aliases.json | ||
- fix: wildcard + domain matches before domain. Fixes #15 | ||
- lint: remove duplicate / stale rules from .eslintrc | ||
- dep: eslint-plugin-haraka -> @haraka/eslint-config | ||
- deps: bump to latest versions | ||
- chore: populate [files] in package.json | ||
- doc(CHANGELOG) renamed from Changes | ||
- doc(CONTRIBUTORS): added | ||
- doc(README): fix URL for CI tests | ||
- ci: update to shared GHA workflows | ||
- added the option to alias all emails with \* (#12) | ||
|
||
### 1.0.1 - 2022-05-26 | ||
|
||
- synced from Haraka/plugins/aliases | ||
- dep(eslint): 3 -> 8 | ||
- chore(ci): add github workflows, codeql, ci, publish | ||
- chore(ci): delete travis and appveyor configs | ||
- chore: ignore package-lock.json | ||
- chore(test): replaced nodeunit with mocha | ||
- lint: use shorthand in tests | ||
|
||
### 1.0.0 - 2017-09-01 | ||
|
||
- imported from haraka | ||
|
||
[1.0.2]: https://github.com/haraka/haraka-plugin-aliases/releases/tag/v1.0.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Contributors | ||
|
||
This handcrafted artisinal software is brought to you by: | ||
|
||
| <img height="80" src="https://avatars.githubusercontent.com/u/261635?v=4"><br><a href="https://github.com/msimerson">msimerson</a> (<a href="https://github.com/haraka/haraka-plugin-aliases/commits?author=msimerson">7</a>) | <img height="80" src="https://avatars.githubusercontent.com/u/38138252?v=4"><br><a href="https://github.com/TimoKoole">TimoKoole</a> (<a href="https://github.com/haraka/haraka-plugin-aliases/commits?author=TimoKoole">1</a>) | | ||
| :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | | ||
|
||
<sub>this file is maintained by [.release](https://github.com/msimerson/.release)</sub> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,14 +4,11 @@ | |
|
||
# haraka-plugin-aliases | ||
|
||
This plugin allows the configuration of aliases that perform an action or | ||
change the RCPT address. Aliases are specified in a JSON formatted config file, | ||
and must have an action. Syntax errors found in the JSON config will stop the server. | ||
This plugin allows the configuration of aliases that perform an action or change the RCPT address. Aliases are specified in a JSON formatted config file, and must have an action. Syntax errors found in the JSON config will stop the server. | ||
|
||
IMPORTANT: this plugin must appear in `config/plugins` before other plugins | ||
that run on hook_rcpt | ||
IMPORTANT: this plugin must appear in `config/plugins` before other plugins that run on hook_rcpt | ||
|
||
WARNING: DO NOT USE THIS PLUGIN WITH queue/smtp\_proxy. | ||
WARNING: DO NOT USE THIS PLUGIN WITH queue/smtp_proxy. | ||
|
||
## Configuration | ||
|
||
|
@@ -20,13 +17,13 @@ WARNING: DO NOT USE THIS PLUGIN WITH queue/smtp\_proxy. | |
JSON formatted config file that contains keys to match against RCPT addresses, and values that are objects with an "action" : "<action>" property. Example: | ||
|
||
```json | ||
{ "test1" : { "action" : "drop" } } | ||
{ "test1": { "action": "drop" } } | ||
``` | ||
|
||
In the above example the "test1" alias will drop any message that matches test1, test1-*, or test1+* (wildcard '-' or '+', see below). Actions may have 0 or more options listed like so: | ||
In the above example the "test1" alias will drop any message that matches test1, test1-_, or test1+_ (wildcard '-' or '+', see below). Actions may have 0 or more options listed like so: | ||
|
||
```json | ||
{ "test3" : { "action" : "alias", "to" : "test3-works" } } | ||
{ "test3": { "action": "alias", "to": "test3-works" } } | ||
``` | ||
|
||
In the above example the "test3" alias has an action of "alias" and a mandatory "to" field. If "to" were missing the alias would fail and an error would be emitted. | ||
|
@@ -44,101 +41,107 @@ Aliases of 'user', '@host' and 'user@host' possible: | |
Aliases may be expanded to multiple recipients: | ||
|
||
```json | ||
{ "[email protected]": { "action": "alias", "to": ["[email protected]", "[email protected]"] } } | ||
{ | ||
"[email protected]": { | ||
"action": "alias", | ||
"to": ["[email protected]", "[email protected]"] | ||
} | ||
} | ||
``` | ||
|
||
### wildcard notation | ||
|
||
This plugin supports wildcard matching of aliases against the right most string of a RCPT address. The characters '-' and '+' are commonly used for subaddressing and this plugin can alias the "user" part of the address. | ||
This plugin supports wildcard matching of aliases against the right most string of a RCPT address. The characters '-' and '+' are commonly used for subaddressing and this plugin can alias the "user" part of the address. | ||
|
||
If the address were [email protected] (or [email protected]), the below alias would match: | ||
|
||
```json | ||
{ "test2" : { "action" : "drop" } } | ||
{ "test2": { "action": "drop" } } | ||
``` | ||
|
||
Larger and more specific aliases match first when using wildcard '-' notation. If the above RCPT was evaluated with this alias config, it would alias: | ||
Larger and more specific aliases match first when using wildcard '-' notation. If the above RCPT was evaluated with this alias config, it would alias: | ||
|
||
```json | ||
{ | ||
"test2" : { "action" : "drop" }, | ||
"test2-testing" : { "action" : "alias", "to" : "[email protected]" } | ||
"test2": { "action": "drop" }, | ||
"test2-testing": { "action": "alias", "to": "[email protected]" } | ||
} | ||
``` | ||
|
||
It also allows you to route all emails to a certain domain: | ||
|
||
```json | ||
{ | ||
"*" : { "action" : "alias", "to" : "[email protected]" } | ||
"*": { "action": "alias", "to": "[email protected]" } | ||
} | ||
``` | ||
|
||
#### chaining and circuits | ||
|
||
Alias chaining is not supported. As a side-effect, we enjoy protections against alias circuits. | ||
|
||
* optional one line formatting | ||
- optional one line formatting | ||
|
||
Any valid JSON will due. Please consider keeping each alias on its own line so that others that wish to grep the aliases file have an easier time finding the full configuration for an alias. | ||
|
||
* nondeterministic duplicate matches | ||
- nondeterministic duplicate matches | ||
|
||
This plugin was written with speed in mind. That means every lookup hashes into the alias file for its match. While the act of doing so is fast, it does mean that any duplicate alias entries will match nondeterministically. That is, we cannot predict what will happen here: | ||
This plugin was written with speed in mind. That means every lookup hashes into the alias file for its match. While the act of doing so is fast, it does mean that any duplicate alias entries will match nondeterministically. That is, we cannot predict what will happen here: | ||
|
||
```json | ||
{ | ||
"coinflip" : { "action" : "alias", "to" : "[email protected]" }, | ||
"coinflip" : { "action" : "alias", "to" : "[email protected]" } | ||
"coinflip": { "action": "alias", "to": "[email protected]" }, | ||
"coinflip": { "action": "alias", "to": "[email protected]" } | ||
} | ||
``` | ||
|
||
Due to node.js implementation, one result will likely always be chosen over the other, so this is not exactly a coinflip. We simply cannot say what the language implementation will do and it could change. | ||
Due to node.js implementation, one result will likely always be chosen over the other, so this is not exactly a coinflip. We simply cannot say what the language implementation will do and it could change. | ||
|
||
## action (required) | ||
|
||
The following is a list of supported actions and their options. | ||
|
||
* drop | ||
- drop | ||
|
||
Drops a message while pretending everything was okay to the sender. This acts like an alias to /dev/null. | ||
Drops a message while pretending everything was okay to the sender. This acts like an alias to /dev/null. | ||
|
||
* alias | ||
- alias | ||
|
||
Maps the alias key to the address specified in the "to" option. A note about matching in addition to the note about wildcard '-' above. When we match an alias, we store the hostname of the match for a shortcut substitution syntax later. | ||
Maps the alias key to the address specified in the "to" option. A note about matching in addition to the note about wildcard '-' above. When we match an alias, we store the hostname of the match for a shortcut substitution syntax later. | ||
|
||
* to (required) | ||
- to (required) | ||
|
||
This option is the full address, or local part at matched hostname that the RCPT address will be re-written to. For an example of an alias to a full address consider the following: | ||
This option is the full address, or local part at matched hostname that the RCPT address will be re-written to. For an example of an alias to a full address consider the following: | ||
|
||
```json | ||
{ "test5" : { "action" : "alias", "to" : "[email protected]" } } | ||
``` | ||
```json | ||
{ "test5": { "action": "alias", "to": "[email protected]" } } | ||
``` | ||
|
||
This maps RCPT matches for "test5" to "[email protected]". This would map "[email protected]" to "[email protected]" every time. Compare this notation with its shortcut counterpart, best used when the "to" address is at the same domain as the match: | ||
This maps RCPT matches for "test5" to "[email protected]". This would map "[email protected]" to "[email protected]" every time. Compare this notation with its shortcut counterpart, best used when the "to" address is at the same domain as the match: | ||
|
||
```json | ||
{ "test4" : { "action" : "alias", "to" : "test4" } } | ||
``` | ||
```json | ||
{ "test4": { "action": "alias", "to": "test4" } } | ||
``` | ||
|
||
This notation is more compact. Mail to "[email protected]" will map to "[email protected]". This notation enables lots of aliases on a single domain to map to other local parts at the same domain. | ||
This notation is more compact. Mail to "[email protected]" will map to "[email protected]". This notation enables lots of aliases on a single domain to map to other local parts at the same domain. | ||
|
||
## Example Configuration | ||
|
||
```json | ||
{ | ||
"test1" : { "action" : "drop" }, | ||
"test2" : { "action" : "drop" }, | ||
"test3" : { "action" : "alias", "to" : "test3-works" }, | ||
"test4" : { "action" : "alias", "to" : "test4" }, | ||
"test5" : { "action" : "alias", "to" : "[email protected]" }, | ||
"test6" : { "action" : "alias", "to" : "[email protected]" } | ||
"test1": { "action": "drop" }, | ||
"test2": { "action": "drop" }, | ||
"test3": { "action": "alias", "to": "test3-works" }, | ||
"test4": { "action": "alias", "to": "test4" }, | ||
"test5": { "action": "alias", "to": "[email protected]" }, | ||
"test6": { "action": "alias", "to": "[email protected]" } | ||
} | ||
``` | ||
|
||
<!-- leave these buried at the bottom of the document --> | ||
[ci-img]: https://travis-ci.org/haraka/haraka-plugin-aliases.svg | ||
[ci-url]: https://travis-ci.org/haraka/haraka-plugin-aliases | ||
|
||
[ci-img]: https://github.com/haraka/haraka-plugin-aliases/actions/workflows/ci.yml/badge.svg | ||
[ci-url]: https://github.com/haraka/haraka-plugin-aliases/actions/workflows/ci.yml | ||
[cov-img]: https://codecov.io/github/haraka/haraka-plugin-aliases/coverage.svg | ||
[cov-url]: https://codecov.io/github/haraka/haraka-plugin-aliases | ||
[clim-img]: https://codeclimate.com/github/haraka/haraka-plugin-aliases/badges/gpa.svg | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
Oops, something went wrong.