Skip to content

Commit

Permalink
Merge pull request #16 from haraka/already_matched
Browse files Browse the repository at this point in the history
already_matched: add missing context
  • Loading branch information
msimerson authored Mar 16, 2019
2 parents 9f5b365 + 58a1565 commit 53cf0e9
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 17 deletions.
6 changes: 3 additions & 3 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
engines:
engines:
eslint:
enabled: true
channel: "eslint-3"
channel: "eslint-4"
config:
config: ".eslintrc.json"
config: ".eslintrc.yaml"

ratings:
paths:
Expand Down
6 changes: 5 additions & 1 deletion Changes.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@

# 1.0.7 - 2019-03-16

- assure already_matched has 'this' in context.
- add some es6 interpoled strings

# 1.0.6 - 2018-12-06

- move declarations up to restore `var` variable hoisting behavior
Expand All @@ -21,4 +26,3 @@
# 1.0.2 - 2016-02-06

- inherit from haraka-plugin-redis (vs redis)

2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
environment:
nodejs_version: "6"
nodejs_version: "8"

install:
- ps: Install-Product node $env:nodejs_version
Expand Down
22 changes: 11 additions & 11 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ exports.update_sender = function (next, connection, params) {
return next();
}
for (let i = 0; i < rcpt_domains.length; i++) {
connection.loginfo(plugin, 'saved ' + sender_od + ' : ' + rcpt_domains[i] + ' : ' + replies[i]);
connection.loginfo(plugin, `saved ${sender_od} : ${rcpt_domains[i]} : ${replies[i]}`);
}
next(null, null, sender_od, rcpt_domains);
});
Expand All @@ -89,7 +89,7 @@ exports.get_sender_domain_by_txn = function (txn) {
if (!txn.mail_from.host) return;
const sender_od = tlds.get_organizational_domain(txn.mail_from.host);
if (txn.mail_from.host !== sender_od) {
plugin.logdebug('sender: ' + txn.mail_from.host + ' -> ' + sender_od);
plugin.logdebug(`sender: ${txn.mail_from.host} -> ${sender_od}`);
}
return sender_od;
}
Expand Down Expand Up @@ -134,19 +134,19 @@ exports.is_authenticated = function (next, connection, params) {
const sender_od = plugin.get_sender_domain_by_txn(connection.transaction);

if (plugin.has_fcrdns_match(sender_od, connection)) {
connection.logdebug(plugin, '+fcrdns: ' + sender_od);
connection.logdebug(plugin, `+fcrdns: ${sender_od}`);
return next(null, null, sender_od);
}
if (plugin.has_spf_match(sender_od, connection)) {
connection.logdebug(plugin, '+spf: ' + sender_od);
connection.logdebug(plugin, `+spf: ${sender_od}`);
return next(null, null, sender_od);
}

// Maybe: TLS verified domain?
if (connection.tls.verified) {
// TODO: get the CN and Subject Alternative Names of the cert
// then look for match with sender_od
connection.logdebug(plugin, '+tls: ' + sender_od);
connection.logdebug(plugin, `+tls: ${sender_od}`);
// return next(null, null, sender_od);
}

Expand All @@ -173,7 +173,7 @@ exports.get_rcpt_ods = function (connection) {
return txn_r.rcpt_ods;
}

function already_matched (connection) {
exports.already_matched = function (connection) {
const res = connection.transaction.results.get(this);
if (!res) return false;
return (res.pass && res.pass.length) ? true : false;
Expand Down Expand Up @@ -210,7 +210,7 @@ exports.check_recipient = function (next, connection, rcpt) {
plugin.logerror(err);
return next();
}
connection.logdebug(plugin, rcpt_od + ' : ' + sender_od + ' : ' + reply);
connection.logdebug(plugin, `${rcpt_od} : ${sender_od} : ${reply}`);
if (reply) {
connection.transaction.results.add(plugin, { pass: rcpt_od, count: reply });
}
Expand All @@ -225,15 +225,15 @@ exports.is_dkim_authenticated = function (next, connection) {
let rcpt_ods = [];

function errNext (err) {
connection.logerror(plugin, 'is_dkim_authenticated: ' + err);
connection.logerror(plugin, `is_dkim_authenticated: ${err}`);
return next(null, null, rcpt_ods);
}
function infoNext (err) {
connection.loginfo(plugin, 'is_dkim_authenticated: ' + err);
function infoNext (msg) {
connection.loginfo(plugin, `is_dkim_authenticated: ${msg}`);
return next(null, null, rcpt_ods);
}

if (already_matched(connection)) return errNext('already matched');
if (plugin.already_matched(connection)) return errNext('already matched');

const sender_od = plugin.get_validated_sender_od(connection);
if (!sender_od) return errNext('no sender_od');
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "haraka-plugin-known-senders",
"version": "1.0.6",
"version": "1.0.7",
"description": "Increase the reputation of recognized sender domains.",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 53cf0e9

Please sign in to comment.