[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip plugins at runtime #2966

Merged
merged 8 commits into from
Sep 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
- tls: require secure and verified sockets for configured hosts/domains
- tls: add `no_starttls_ports` - an array of incoming ports where STARTTLS is not advertised
- outbound: add local_mx_ok config #2952
- skip plugins at runtime by pushing name into transaction.skip_plugins #2966

### Fixes

Expand Down
4 changes: 4 additions & 0 deletions docs/Plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,10 @@ Check the order that the plugins will run on each hook by running:

`haraka -o -c /path/to/config`

## Skipping Plugins

Plugins can be skipped at runtime by pushing the name of the plugin into the `skip_plugins` array in `transaction.notes`. This array is reset for every transaction and once a plugin is added to the list, it will not run any hooks in that plugin for the remainder of the transaction. For example, one could create a whitelist plugin that skipped `spamassassin` if the sender was in a whitelist.

## Logging

Plugins inherit all the logging methods of `logger.js`, which are:
Expand Down
5 changes: 5 additions & 0 deletions plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,11 @@ plugins.run_next_hook = (hook, object, params) => {
object.logdebug(`running ${hook} hook in ${item[0].name} plugin`);
}

if (object.transaction && object.transaction.notes.skip_plugins.includes(item[0].name)) {
object.logdebug(`skipping ${item[0].name}_${hook} by request in notes`);
return callback();
}

try {
object.current_hook = item;
object.hook = hook;
Expand Down
1 change: 1 addition & 0 deletions transaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class Transaction {
this.body = null;
this.parse_body = false;
this.notes = new Notes();
this.notes.skip_plugins = [];
this.header = new Header();
this.message_stream = new MessageStream(this.cfg, this.uuid, this.header.header_list);
this.discard_data = false;
Expand Down