forked from haraka/Haraka
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
787257f
commit cc7547f
Showing
3 changed files
with
55 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0 |
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,21 @@ | ||
tarpit | ||
====== | ||
|
||
This plugin is designed to introduce deliberate delays on the response | ||
of every hook in order to slow down a connection. It has no | ||
configuration and is designed to be used only by other plugins. | ||
|
||
It must be loaded early in config/plugins (e.g. before any plugins | ||
that accept recipients or that return OK) but must be loaded *after* | ||
any plugins that wish to use it. | ||
|
||
To use this plugin in another plugin set: | ||
|
||
connection.notes.tarpit = <seconds to delay>; | ||
|
||
or | ||
|
||
connection.transaction.notes.tarpit = <seconds to delay>; | ||
|
||
When tarpitting a command it will log 'tarpitting response for Ns' to | ||
the INFO facility where N is the number of seconds. |
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,33 @@ | ||
// tarpit | ||
|
||
exports.register = function () { | ||
// Register tarpit function last | ||
var self = this; | ||
['connect', 'helo', 'ehlo', 'mail', 'rcpt', 'rcpt_ok', 'data', | ||
'data_post', 'queue', 'unrecognized_command', 'vrfy', 'noop', | ||
'rset', 'quit'].forEach(function (hook) { | ||
self.register_hook(hook, 'tarpit'); | ||
}); | ||
} | ||
|
||
exports.tarpit = function (next, connection) { | ||
var transaction = connection.transaction; | ||
var conn_delay, trans_delay; | ||
if (transaction && transaction.notes) { | ||
trans_delay = transaction.notes.tarpit; | ||
} | ||
if (connection && connection.notes) { | ||
conn_delay = connection.notes.tarpit; | ||
} | ||
var delay = trans_delay || conn_delay; | ||
if (delay) { | ||
connection.loginfo(this, 'tarpitting response for ' + delay + 's'); | ||
setTimeout(function () { | ||
// Only return if we still have a connection... | ||
if (connection) return next(); | ||
}, (delay*1000)); | ||
} | ||
else { | ||
return next(); | ||
} | ||
} |