Permalink
Browse files

changes all logging calls in plugins

  • Loading branch information...
1 parent 6a8aa2e commit 130162b80a4cc4c686ceb8e09517c4dcc6b62710 Joshua Thayer committed Dec 1, 2011
View
2 plugins/auth/auth_base.js
@@ -158,7 +158,7 @@ exports.auth_cram_md5 = function(next, connection, params) {
var ticket = '<' + hexi(Math.floor(Math.random() * 1000000)) + '.' +
hexi(Date.now()) + '@' + this.config.get('me') + '>';
- connection.loginfo("[auth/auth_base] ticket: " + ticket);
+ connection.loginfo(this, "ticket: " + ticket);
connection.respond(334, base64(ticket));
connection.notes.auth_ticket = ticket;
return next(OK);
View
26 plugins/auth/auth_proxy.js
@@ -22,14 +22,14 @@ exports.check_plain_passwd = function (connection, user, passwd, cb) {
var domain = domain[1].toLowerCase();
} else {
// AUTH user not in user@domain.com format
- connection.logerror('[auth/auth_proxy] AUTH user="' + user + '" error="not in required format"');
+ connection.logerror(this, 'AUTH user="' + user + '" error="not in required format"');
return cb(false);
}
// Check if domain exists in configuration file
var config = this.config.get('auth_proxy.ini');
if (!config.domains[domain]) {
- connection.logerror('[auth/auth_proxy] AUTH user="' + user + '" error="domain \'' + domain + '\' is not defined"');
+ connection.logerror(this, 'AUTH user="' + user + '" error="domain \'' + domain + '\' is not defined"');
return cb(false);
}
@@ -52,7 +52,7 @@ exports.try_auth_proxy = function (connection, hosts, user, passwd, cb) {
var hostport = host.split(/:/)
var socket = sock.connect(((hostport[1]) ? hostport[1] : 25), hostport[0]);
- connection.logdebug('[auth/auth_proxy] attempting connection to host=' + hostport[0] + ' port=' + ((hostport[1]) ? hostport[1] : 25));
+ connection.logdebug(self, 'attempting connection to host=' + hostport[0] + ' port=' + ((hostport[1]) ? hostport[1] : 25));
socket.setTimeout(30 * 1000);
socket.on('connect', function () {
});
@@ -61,40 +61,40 @@ exports.try_auth_proxy = function (connection, hosts, user, passwd, cb) {
// Try next host
return self.try_auth_proxy(connection, hosts, user, passwd, cb);
}
- connection.loginfo('[auth/auth_proxy] AUTH user="' + user + '" host="' + host + '" success=' + auth_success);
+ connection.loginfo(self, 'AUTH user="' + user + '" host="' + host + '" success=' + auth_success);
return cb(auth_success);
});
socket.on('timeout', function () {
- connection.logerror("[auth/auth_proxy] connection timed out");
+ connection.logerror(self, "connection timed out");
socket.end();
// Try next host
return self.try_auth_proxy(connection, hosts, user, passwd, cb);
});
socket.on('error', function (err) {
- connection.logerror("[auth/auth_proxy] connection failed to host " + host + ": " + err);
+ connection.logerror(self, "connection failed to host " + host + ": " + err);
return self.try_auth_proxy(connection, hosts, user, passwd, cb);
});
socket.send_command = function (cmd, data) {
var line = cmd + (data ? (' ' + data) : '');
if (cmd === 'dot') {
line = '.';
}
- connection.logprotocol("[auth/auth_proxy] C: " + line);
+ connection.logprotocol(self, "C: " + line);
command = cmd.toLowerCase();
this.write(line + "\r\n");
// Clear response buffer from previous command
response = [];
};
socket.on('line', function (line) {
var matches;
- connection.logprotocol("[auth/auth_proxy] S: " + line);
+ connection.logprotocol(self, "S: " + line);
if (matches = smtp_regexp.exec(line)) {
var code = matches[1],
cont = matches[2],
rest = matches[3];
response.push(rest);
if (cont === ' ') {
- connection.logdebug('[auth/auth_proxy] command state: ' + command);
+ connection.logdebug(self, 'command state: ' + command);
if (command === 'ehlo') {
if (code.match(/^5/)) {
// EHLO command rejected; we have to abort
@@ -120,7 +120,7 @@ exports.try_auth_proxy = function (connection, hosts, user, passwd, cb) {
// Parse supported AUTH methods
var parse = /^AUTH (.+)$/.exec(response[i]);
methods = parse[1].split(/\s+/);
- connection.logdebug('[auth/auth_proxy] found supported AUTH methods: ' + methods);
+ connection.logdebug(self, 'found supported AUTH methods: ' + methods);
// Prefer PLAIN as it's easiest
if (methods.indexOf('PLAIN') !== -1) {
socket.send_command('AUTH','PLAIN ' + self.base64("\0" + user + "\0" + passwd));
@@ -132,7 +132,7 @@ exports.try_auth_proxy = function (connection, hosts, user, passwd, cb) {
}
else {
// No compatible methods; abort...
- connection.logdebug('[auth/auth_proxy] no compatible AUTH methods');
+ connection.logdebug(self, 'no compatible AUTH methods');
socket.send_command('QUIT');
return;
}
@@ -170,7 +170,7 @@ exports.try_auth_proxy = function (connection, hosts, user, passwd, cb) {
}
if (/^[345]/.test(code)) {
// Got an unhandled error
- connection.logdebug('[auth/auth_proxy] error: ' + line);
+ connection.logdebug(self, 'error: ' + line);
socket.send_command('QUIT');
return;
}
@@ -200,7 +200,7 @@ exports.try_auth_proxy = function (connection, hosts, user, passwd, cb) {
}
else {
// Unrecognised response.
- connection.logerror("[auth/auth_proxy] unrecognised response: " + line);
+ connection.logerror(self, "unrecognised response: " + line);
socket.end();
return;
}
View
8 plugins/block_me.js
@@ -19,6 +19,8 @@ exports.hook_data_post = function (next, connection) {
var recip = (this.config.get('block_me.recipient') || '').toLowerCase();
var senders = this.config.get('block_me.senders', 'list');
+
+ var self = this;
// Make sure only 1 recipient
if (connection.transaction.rcpt_to.length != 1) {
@@ -39,11 +41,11 @@ exports.hook_data_post = function (next, connection) {
// Now extract the "From" from the body...
var to_block = extract_from_line(connection.transaction.body);
if (!to_block) {
- connection.logerror("[block_me] No sender found in email");
+ connection.logerror(this, "No sender found in email");
return next();
}
- connection.loginfo("[block_me] Blocking new sender: " + to_block);
+ connection.loginfo(this, "Blocking new sender: " + to_block);
connection.transaction.notes.block_me = 1;
@@ -55,7 +57,7 @@ exports.hook_data_post = function (next, connection) {
});
}
else {
- connection.logerror("[block_me] Unable to append to mail_from.blocklist: " + err);
+ connection.logerror(self, "Unable to append to mail_from.blocklist: " + err);
}
});
View
20 plugins/clamd.js
@@ -20,7 +20,7 @@ exports.hook_data = function (next, connection) {
var transaction = connection.transaction;
transaction.parse_body = 1;
transaction.attachment_hooks(function (ctype, filename, body) {
- connection.logdebug('[clamd] found ctype=' + ctype + ', filename=' + filename);
+ connection.logdebug(plugin, 'found ctype=' + ctype + ', filename=' + filename);
transaction.notes.clamd_found_attachment = 1;
});
}
@@ -41,13 +41,13 @@ exports.hook_data_post = function (next, connection) {
if (config.main['only_with_attachments'] &&
!transaction.notes.clamd_found_attachment)
{
- connection.logdebug('[clamd] skipping: no attachments found');
+ connection.logdebug(plugin, 'skipping: no attachments found');
return next();
}
// Limit message size
if (transaction.data_bytes > config.main.max_size) {
- connection.logdebug('[clamd] skipping: message too big');
+ connection.logdebug(plugin, 'skipping: message too big');
return next();
}
@@ -92,30 +92,30 @@ exports.hook_data_post = function (next, connection) {
};
socket.on('drain', function () {
- connection.logdebug('[clamd] drain');
+ connection.logdebug(plugin, 'drain');
send_data();
});
socket.on('timeout', function () {
- connection.logerror("[clamd] connection timed out");
+ connection.logerror(plugin, "connection timed out");
socket.destroy();
return next(DENYSOFT,'Virus scanner timed out');
});
socket.on('error', function (err) {
- connection.logerror("[clamd] connection failed: " + err);
+ connection.logerror(plugin, "connection failed: " + err);
socket.destroy();
return next(DENYSOFT,'Error connecting to virus scanner');
});
socket.on('connect', function () {
var hp = socket.address();
- connection.loginfo('[clamd] connected to host: ' + hp.address + ':' + hp.port);
+ connection.loginfo(plugin, 'connected to host: ' + hp.address + ':' + hp.port);
socket.write("zINSTREAM\0", function () {
send_data();
});
});
var result = "";
socket.on('line', function (line) {
- connection.logprotocol('[clamd] C:' + line);
+ connection.logprotocol(plugin, 'C:' + line);
result = line.replace(/\r?\n/, '');
});
@@ -134,13 +134,13 @@ exports.hook_data_post = function (next, connection) {
(virus || 'UNKNOWN'));
}
else if (/size limit exceeded/.test(result)) {
- connection.loginfo('[clamd] INSTREAM size limit exceeded. ' +
+ connection.loginfo(plugin, 'INSTREAM size limit exceeded. ' +
'Check StreamMaxLength in clamd.conf');
// Continue as StreamMaxLength default is 25Mb
return next();
} else {
// Unknown result
- connection.logerror('[clamd] unknown result: ' + result);
+ connection.logerror(plugin, 'unknown result: ' + result);
return next(DENYSOFT, 'Error running virus scanner');
}
return next();
View
26 plugins/connect.rdns_access.js
@@ -28,45 +28,45 @@ exports.rdns_access = function(next, connection) {
// IP whitelist checks
if (connection.remote_ip) {
- connection.logdebug('[rdns_access] checking ' + connection.remote_ip +
+ connection.logdebug(plugin, 'checking ' + connection.remote_ip +
' against connect.rdns_access.whitelist');
- if (_in_whitelist(plugin, connection.remote_ip)) {
- connection.logdebug("[rdns_access] Allowing " + connection.remote_ip);
+ if (_in_whitelist(connection, plugin, connection.remote_ip)) {
+ connection.logdebug(plugin, "Allowing " + connection.remote_ip);
return next();
}
}
// hostname whitelist checks
if (connection.remote_host) {
- connection.logdebug('[rdns_access] checking ' + connection.remote_host +
+ connection.logdebug(plugin, 'checking ' + connection.remote_host +
' against connect.rdns_access.whitelist');
if (_in_whitelist(connection, plugin, connection.remote_host.toLowerCase())) {
- connection.logdebug("[rdns_access] Allowing " + connection.remote_host);
+ connection.logdebug(plugin, "Allowing " + connection.remote_host);
return next();
}
}
// IP blacklist checks
if (connection.remote_ip) {
- connection.logdebug('[rdns_access] checking ' + connection.remote_ip +
+ connection.logdebug(plugin, 'checking ' + connection.remote_ip +
' against connect.rdns_access.blacklist');
if (_in_blacklist(connection, plugin, connection.remote_ip)) {
- connection.logdebug("[rdns_access] Rejecting, matched: " + connection.remote_ip);
+ connection.logdebug(plugin, "Rejecting, matched: " + connection.remote_ip);
return next(DENY, connection.remote_host.toLowerCase() + ' [' +
connection.remote_ip + '] ' + plugin.deny_msg);
}
}
// hostname blacklist checks
if (connection.remote_host) {
- connection.logdebug('[rdns_access] checking ' + connection.remote_host +
+ connection.logdebug(plugin, 'checking ' + connection.remote_host +
' against connect.rdns_access.blacklist');
if (_in_blacklist(connection, plugin, connection.remote_host.toLowerCase())) {
- connection.logdebug("[rdns_access] Rejecting, matched: " + connection.remote_host);
+ connection.logdebug(plugin, "Rejecting, matched: " + connection.remote_host);
return next(DENY, connection.remote_host.toLowerCase() + ' [' +
connection.remote_ip + '] ' + plugin.deny_msg);
}
@@ -78,15 +78,15 @@ exports.rdns_access = function(next, connection) {
function _in_whitelist(connection, plugin, host) {
var i;
for (i in plugin.wl) {
- connection.logdebug('[rdns_access] checking ' + host + ' against ' + plugin.wl[i]);
+ connection.logdebug(plugin, 'checking ' + host + ' against ' + plugin.wl[i]);
if (plugin.wl[i].toLowerCase() === host) {
return 1;
}
}
if (plugin.wlregex) {
- connection.logdebug('[rdns_access] checking ' + host + ' against ' +
+ connection.logdebug(plugin, 'checking ' + host + ' against ' +
plugin.wlregex.source);
if (host.match(plugin.wlregex)) {
@@ -100,15 +100,15 @@ function _in_whitelist(connection, plugin, host) {
function _in_blacklist(connection, plugin, host) {
var i;
for (i in plugin.bl) {
- connection.logdebug('[rdns_access] checking ' + host + ' against ' + plugin.bl[i]);
+ connection.logdebug(plugin, 'checking ' + host + ' against ' + plugin.bl[i]);
if (plugin.bl[i].toLowerCase() === host) {
return 1;
}
}
if (plugin.blregex) {
- connection.logdebug('[rdns_access] checking ' + host + ' against ' +
+ connection.logdebug(plugin, 'checking ' + host + ' against ' +
plugin.blregex.source);
if (host.match(plugin.blregex)) {
View
28 plugins/data.uribl.js
@@ -60,35 +60,37 @@ exports.load_uri_config = function (next) {
}
exports.do_lookups = function (connection, next, hosts, type) {
+ var plugin = this;
+
if (typeof hosts === 'string') {
hosts = [ hosts ];
}
if (!hosts || (hosts && !hosts.length)) {
- connection.logdebug('[uribl] (' + type + ') no items found for lookup');
+ connection.logdebug(plugin, '(' + type + ') no items found for lookup');
return next();
}
else {
- connection.logdebug('[uribl] (' + type + ') found ' + hosts.length + ' items for lookup');
+ connection.logdebug(plugin, '(' + type + ') found ' + hosts.length + ' items for lookup');
}
var queries = {};
for (var i=0; i < hosts.length; i++) {
var host = hosts[i].toLowerCase();
- connection.logdebug('[uribl] (' + type + ') checking: ' + host);
+ connection.logdebug(plugin, '(' + type + ') checking: ' + host);
// Make sure we have a valid TLD
if (!isIPv4(host) && !net_utils.top_level_tlds[(host.split('\.').reverse())[0]]) {
continue;
}
// Check the exclusion list
if (check_excludes_list(host)) {
- connection.logdebug('[uribl] skipping excluded domain:' + host);
+ connection.logdebug(plugin, 'skipping excluded domain:' + host);
continue;
}
// Loop through the zones
for (var j=0; j < zones.length; j++) {
var zone = zones[j];
if (zone === 'main') continue; // skip config
if (!lists[zone] || (lists[zone] && !/^(?:1|true|yes|enabled|on)$/i.test(lists[zone][type]))) {
- connection.logdebug('[uribl] skipping zone ' + zone + ' as it does not support lookup type ' + type);
+ connection.logdebug(plugin, 'skipping zone ' + zone + ' as it does not support lookup type ' + type);
continue;
}
// Convert in-addr.arpa into bare IPv4 lookup
@@ -100,7 +102,7 @@ exports.do_lookups = function (connection, next, hosts, type) {
// Handle zones that do not allow IP queries (e.g. Spamhaus DBL)
if (isIPv4(host)) {
if (/^(?:1|true|yes|enabled|on)$/i.test(lists[zone].no_ip_lookups)) {
- connection.logdebug('[uribl] skipping IP lookup (' + host + ') for zone ' + zone);
+ connection.logdebug(plugin, 'skipping IP lookup (' + host + ') for zone ' + zone);
continue;
}
// Skip any private IPs
@@ -119,7 +121,7 @@ exports.do_lookups = function (connection, next, hosts, type) {
if (!lookup) continue;
if (!queries[zone]) queries[zone] = {};
if (Object.keys(queries[zone]).length > lists.main.max_uris_per_list) {
- connection.logwarn('[uribl] discarding lookup ' + lookup + ' for zone ' +
+ connection.logwarn(plugin, 'discarding lookup ' + lookup + ' for zone ' +
zone + ' maximum query limit reached');
continue;
}
@@ -148,7 +150,7 @@ exports.do_lookups = function (connection, next, hosts, type) {
var called_next = false;
var timer = setTimeout(function () {
- connection.logdebug('[uribl] timeout');
+ connection.logdebug(plugin, 'timeout');
if (!called_next) {
called_next = true;
return next();
@@ -165,7 +167,7 @@ exports.do_lookups = function (connection, next, hosts, type) {
pending_queries++;
dns.resolve4(lookup, function(err, addrs) {
pending_queries--;
- connection.logdebug('[uribl] ' + lookup + ' => ' + ((err) ? err : addrs.join(', ')));
+ connection.logdebug(plugin, lookup + ' => ' + ((err) ? err : addrs.join(', ')));
if (!err && !called_next) {
var skip = false;
var do_reject = function (msg) {
@@ -186,7 +188,7 @@ exports.do_lookups = function (connection, next, hosts, type) {
if (lists[query[1]] && lists[query[1]].validate) {
var re = new RegExp(lists[query[1]].validate);
if (!re.test(addrs[0])) {
- connection.logdebug('[uribl] ignoring result (' + addrs[0] + ') for: ' +
+ connection.logdebug(plugin, 'ignoring result (' + addrs[0] + ') for: ' +
lookup + ' as it did not match validation rule');
var skip = true;
}
@@ -198,17 +200,17 @@ exports.do_lookups = function (connection, next, hosts, type) {
var last_octet = new Number((addrs[0].split('.'))[3]);
var bitmask = new Number(lists[query[1]].bitmask);
if ((last_octet & bitmask) > 0) {
- connection.loginfo('[uribl] found ' + query[0] + ' in zone ' + query[1] +
+ connection.loginfo(plugin, 'found ' + query[0] + ' in zone ' + query[1] +
' (' + addrs.join(',') + '; bitmask=' + bitmask + ')');
do_reject();
} else {
- connection.logdebug('[uribl] ignoring result (' + addrs[0] + ') for: ' +
+ connection.logdebug(plugin, 'ignoring result (' + addrs[0] + ') for: ' +
lookup + ' as the bitmask did not match');
var skip = true;
}
}
else {
- connection.loginfo('[uribl] found ' + query[0] + ' in zone ' + query[1] +
+ connection.loginfo(plugin, 'found ' + query[0] + ' in zone ' + query[1] +
' (' + addrs.join(',') + ')');
do_reject();
}
View
8 plugins/dnsbl.js
@@ -8,21 +8,21 @@ exports.register = function() {
}
exports.check_ip = function(next, connection) {
- connection.logdebug("[dnsbl] check_ip: " + connection.remote_ip);
+ connection.logdebug(this, "check_ip: " + connection.remote_ip);
var ip = new String(connection.remote_ip);
var reverse_ip = ip.split('.').reverse().join('.');
if (!this.zones || !this.zones.length) {
- connection.logerror("[dnsbl] No zones");
+ connection.logerror(this, "No zones");
return next();
}
var remaining_zones = [];
var self = this;
this.zones.forEach(function(zone) {
- connection.logdebug("[dnsbl] Querying: " + reverse_ip + "." + zone);
+ connection.logdebug(self, "Querying: " + reverse_ip + "." + zone);
dns.resolve(reverse_ip + "." + zone, "TXT", function (err, value) {
if (!remaining_zones.length) return;
remaining_zones.pop(); // we don't care about order really
@@ -33,7 +33,7 @@ exports.check_ip = function(next, connection) {
case 'ENOTFOUND':
break;
default:
- connection.loginfo("[dnsbl] DNS error: " + err);
+ connection.loginfo(self, "DNS error: " + err);
}
if (remaining_zones.length === 0) {
// only call declined if no more results are pending
View
16 plugins/lookup_rdns.strict.js
@@ -7,14 +7,14 @@ var dns = require('dns');
function _dns_error(connection, next, err, host, plugin, nxdomain, dnserror) {
switch (err.code) {
case dns.NXDOMAIN:
- connection.loginfo('[lookup_rdns.strict] could not find a address for ' + host +
+ connection.loginfo(plugin, 'could not find a address for ' + host +
'. Disconnecting.');
next(DENYDISCONNECT, 'Sorry we could not find address for ' +
host + '. ' + nxdomain);
break;
default:
- connection.loginfo('[lookup_rdns.strict] encountered an error when looking up ' +
+ connection.loginfo(plugin, 'encountered an error when looking up ' +
host + '. Disconnecting.');
next(DENYDISCONNECT, 'Sorry we encountered an error when ' +
'looking up ' + host + '. ' + dnserror);
@@ -29,26 +29,26 @@ function _in_whitelist(connection, plugin, address) {
var host_list_regex =
plugin.config.get('lookup_rdns.strict.whitelist_regex', 'list');
- connection.loginfo("[lookup_rdns.strict] Checking if " + address + " is in the " +
+ connection.loginfo(plugin, "Checking if " + address + " is in the " +
"lookup_rdns.strict.whitelist files");
var i;
for (i in host_list) {
- connection.logdebug("[lookup_rdns.strict] checking " + domain + " against " + host_list[i]);
+ connection.logdebug(plugin, "checking " + domain + " against " + host_list[i]);
if (host_list[i].toLowerCase() === domain) {
- connection.logdebug("[lookup_rdns.strict] Allowing " + domain);
+ connection.logdebug(plugin, "Allowing " + domain);
return 1;
}
}
if (host_list_regex.length) {
var regex = new RegExp ('^(?:' + host_list_regex.join('|') + ')$', 'i');
- connection.logdebug("[lookup_rdns.strict] checking " + domain + " against " + regex.source);
+ connection.logdebug(plugin, "checking " + domain + " against " + regex.source);
if (domain.match(regex)) {
- connection.logdebug("[lookup_rdns.strict] Allowing " + domain);
+ connection.logdebug(plugin, "Allowing " + domain);
return 1;
}
}
@@ -73,7 +73,7 @@ exports.hook_lookup_rdns = function (next, connection) {
timeout_id = setTimeout(function () {
if (!called_next) {
- connection.loginfo('[lookup_rdns.strict] timed out when looking up ' +
+ connection.loginfo(plugin, 'timed out when looking up ' +
connection.remote_ip + '. Disconnecting.');
called_next++;
View
20 plugins/mail_from.is_resolvable.js
@@ -17,7 +17,7 @@ exports.hook_mail = function(next, connection, params) {
// Just in case DNS never comes back (UDP), we should DENYSOFT.
var timeout_id = setTimeout(function () {
- connection.loginfo('[mail_from.is_resolvable] timed out when looking up MX for ' + domain);
+ connection.loginfo(plugin, 'timed out when looking up MX for ' + domain);
called_next++;
return next(DENYSOFT, 'Temporary resolver error (timeout)');
}, ((config.main.timeout) ? config.main.timeout : 30) * 1000);
@@ -32,7 +32,7 @@ exports.hook_mail = function(next, connection, params) {
dns.resolveMx(domain, function(err, addresses) {
if (err) {
- connection.logdebug('[mail_from.is_resolvable] ' + domain + ': MX => ' + err.message);
+ connection.logdebug(plugin, domain + ': MX => ' + err.message);
switch (err.code) {
case dns.NXDOMAIN:
case 'ENOTFOUND':
@@ -53,7 +53,7 @@ exports.hook_mail = function(next, connection, params) {
var check_results = function () {
a_records = Object.keys(a_records);
if (a_records && a_records.length) {
- connection.logdebug('[mail_from.is_resolvable] ' + domain + ': ' + a_records);
+ connection.logdebug(plugin, domain + ': ' + a_records);
return cb();
}
return cb(((config.main.reject_no_mx) ? DENY : DENYSOFT),
@@ -64,7 +64,7 @@ exports.hook_mail = function(next, connection, params) {
// Handle MX records that are IP addresses
// This is invalid - but a lot of MTAs allow it.
if (/^\d+\.\d+\.\d+\.\d+$/.test(addr.exchange)) {
- connection.logwarn('[mail_from.is_resolvable] ' + domain + ': invalid MX ' + addr.exchange)
+ connection.logwarn(plugin, domain + ': invalid MX ' + addr.exchange)
if (config.main.allow_mx_ip) {
a_records[addr.exchange] = 1;
}
@@ -74,16 +74,16 @@ exports.hook_mail = function(next, connection, params) {
dns.resolve(addr.exchange, function(err, addresses) {
pending_queries--;
if (err) {
- connection.logdebug('[mail_from.is_resolvable] ' + domain + ': MX ' + addr.priority + ' '
+ connection.logdebug(plugin, domain + ': MX ' + addr.priority + ' '
+ addr.exchange + ' => ' + err.message);
}
else {
- connection.logdebug('[mail_from.is_resolvable] ' + domain + ': MX ' + addr.priority + ' '
+ connection.logdebug(plugin, domain + ': MX ' + addr.priority + ' '
+ addr.exchange + ' => ' + addresses);
for (var i=0; i < addresses.length; i++) {
// Ignore anything obviously bogus
if (re_bogus_ip.test(addresses[i])) {
- connection.logdebug('[mail_from.is_resolvable] ' + addr.exchange + ': discarding ' + addresses[i]);
+ connection.logdebug(plugin, addr.exchange + ': discarding ' + addresses[i]);
continue;
}
a_records[addresses[i]] = 1;
@@ -103,7 +103,7 @@ exports.hook_mail = function(next, connection, params) {
// Check for implicit MX 0 record
dns.resolve(domain, function(err, addresses) {
if (err) {
- connection.logdebug('[mail_from.is_resolvable] ' + domain + ': A => ' + err.message);
+ connection.logdebug(plugin, domain + ': A => ' + err.message);
switch (err.code) {
case dns.NXDOMAIN:
case 'ENOTFOUND':
@@ -117,12 +117,12 @@ exports.hook_mail = function(next, connection, params) {
}
}
if (addresses && addresses.length) {
- connection.logdebug('[mail_from.is_resolvable] ' + domain + ': A => ' + addresses);
+ connection.logdebug(plugin, domain + ': A => ' + addresses);
var a_records = {};
for (var i=0; i < addresses.length; i++) {
// Ignore anything obviously bogus
if (re_bogus_ip.test(addresses[i])) {
- connection.logdebug('[mail_from.is_resolvable] ' + domain + ': discarding ' + addresses[i]);
+ connection.logdebug(plugin, domain + ': discarding ' + addresses[i]);
continue;
}
a_records[addresses[i]] = 1;
View
4 plugins/max_unrecognized_commands.js
@@ -8,11 +8,11 @@ exports.hook_connect = function(next, connection) {
};
exports.hook_unrecognized_command = function(next, connection, cmd) {
- connection.loginfo("[max_unrecognized_commands] Unrecognized command: " + cmd);
+ connection.loginfo(this, "Unrecognized command: " + cmd);
connection.notes.unrecognized_command_count++;
if (connection.notes.unrecognized_command_count >= connection.notes.unrecognized_command_max) {
- connection.loginfo("[max_unrecognized_commands] Closing connection. Too many bad commands.");
+ connection.loginfo(this, "Closing connection. Too many bad commands.");
return next(DENYDISCONNECT, "Too many bad commands");
}
next();
View
2 plugins/queue/discard.js
@@ -9,7 +9,7 @@ exports.discard = function (next, connection) {
if (connection.notes.discard ||
transaction.notes.discard)
{
- connection.loginfo('[queue/discard] discarding message');
+ connection.loginfo(this, 'discarding message');
// Pretend we delivered the message
return next(OK);
}
View
2 plugins/queue/qmail-queue.js
@@ -28,7 +28,7 @@ exports.hook_queue = function (next, connection) {
fs.close(messagePipe[0]);
fs.close(envelopePipe[0]);
if (code !== 0) {
- connection.logerror("[queue/qmail-queue] Unable to queue message to qmail-queue: " + code);
+ connection.logerror(plugin, "Unable to queue message to qmail-queue: " + code);
next();
}
else {
View
6 plugins/queue/quarantine.js
@@ -96,17 +96,17 @@ exports.quarantine = function (next, connection) {
fs.writeFile([ base_dir, 'tmp', transaction.uuid ].join('/'), lines.join(''),
function(err) {
if (err) {
- connection.logerror('[queue/quarantine] Error writing quarantine file: ' + err);
+ connection.logerror(plugin, 'Error writing quarantine file: ' + err);
}
else {
fs.link([ base_dir, 'tmp', transaction.uuid ].join('/'),
[ base_dir, dir, transaction.uuid ].join('/'),
function (err) {
if (err) {
- connection.logerror('[queue/quarantine] Error writing quarantine file: ' + err);
+ connection.logerror(plugin, 'Error writing quarantine file: ' + err);
}
else {
- connection.loginfo('[queue/quarantine] Stored copy of message in quarantine: ' +
+ connection.loginfo(plugin, 'Stored copy of message in quarantine: ' +
[ base_dir, dir, transaction.uuid ].join('/'));
// Now delete the temporary file
fs.unlink([ base_dir, 'tmp', transaction.uuid ].join('/'));
View
16 plugins/queue/smtp_forward.js
@@ -9,7 +9,7 @@ var smtp_regexp = /^([0-9]{3})([ -])(.*)/;
exports.smtp_forward = function (next, connection) {
var smtp_config = this.config.get('smtp_forward.ini');
- connection.loginfo("[queue/smtp_forward] forwarding to " + smtp_config.main.host + ":" + smtp_config.main.port);
+ connection.loginfo(this, "forwarding to " + smtp_config.main.host + ":" + smtp_config.main.port);
var socket = sock.connect(smtp_config.main.port, smtp_config.main.host);
socket.setTimeout(300 * 1000);
var self = this;
@@ -40,7 +40,7 @@ exports.smtp_forward = function (next, connection) {
if (cmd === 'dot') {
line = '.';
}
- connection.logprotocol("[queue/smtp_forward] C: " + line);
+ connection.logprotocol(self, "C: " + line);
// Set this before we write() in case 'drain' is called
// to stop send_data() form calling 'dot' twice.
command = cmd.toLowerCase();
@@ -50,27 +50,27 @@ exports.smtp_forward = function (next, connection) {
};
socket.on('timeout', function () {
- connection.logerror("[queue/smtp_forward] Ongoing connection timed out");
+ connection.logerror(self, "Ongoing connection timed out");
socket.end();
next();
});
socket.on('error', function (err) {
- connection.logerror("[queue/smtp_forward] Ongoing connection failed: " + err);
+ connection.logerror(self, "Ongoing connection failed: " + err);
// we don't deny on error - maybe another plugin can deliver
next();
});
socket.on('connect', function () {
});
socket.on('line', function (line) {
var matches;
- connection.logprotocol("[queue/smtp_forward] S: " + line);
+ connection.logprotocol(self, "S: " + line);
if (matches = smtp_regexp.exec(line)) {
var code = matches[1],
cont = matches[2],
rest = matches[3];
response.push(rest);
if (cont === ' ') {
- connection.logdebug('[queue/smtp_forward] command state: ' + command);
+ connection.logdebug(self, 'command state: ' + command);
// Handle fallback to HELO if EHLO is rejected
if (command === 'ehlo') {
if (code.match(/^5/)) {
@@ -167,13 +167,13 @@ exports.smtp_forward = function (next, connection) {
}
else {
// Unrecognised response.
- connection.logerror("[queue/smtp_forward] Unrecognised response from upstream server: " + line);
+ connection.logerror(self, "Unrecognised response from upstream server: " + line);
socket.end();
return next();
}
});
socket.on('drain', function() {
- connection.logdebug("[queue/smtp_forward] Drained");
+ connection.logdebug(self, "Drained");
if (got_data_response && dot_pending && command === 'data') {
process.nextTick(function () { send_data() });
}
View
36 plugins/queue/smtp_proxy.js
@@ -12,7 +12,7 @@ function _get_smtp_proxy(self, next, connection) {
if (connection.server.notes.smtp_proxy_pool &&
connection.server.notes.smtp_proxy_pool.length) {
- connection.logdebug("[queue/smtp_proxy] using connection from the pool: (" +
+ connection.logdebug(self, "using connection from the pool: (" +
connection.server.notes.smtp_proxy_pool.length + ")");
smtp_proxy = connection.server.notes.smtp_proxy_pool.shift();
@@ -54,7 +54,7 @@ function _get_smtp_proxy(self, next, connection) {
connection.server.notes.active_proxy_conections = 1;
}
- connection.logdebug("[queue/smtp_proxy] active proxy connections: (" +
+ connection.logdebug(self, "active proxy connections: (" +
connection.server.notes.active_proxy_conections + ")");
return smtp_proxy;
@@ -66,7 +66,7 @@ function _destroy_smtp_proxy(self, connection, smtp_proxy) {
var index;
if (smtp_proxy && smtp_proxy.socket) {
- connection.logdebug("[queue/smtp_proxy] destroying proxy connection");
+ connection.logdebug(self, "destroying proxy connection");
smtp_proxy.socket.destroySoon();
smtp_proxy.socket = 0;
reset_active_connections = 1;
@@ -87,15 +87,15 @@ function _destroy_smtp_proxy(self, connection, smtp_proxy) {
// acttive. This means we do not want to reset it.
reset_active_connections = 0;
connection.server.notes.smtp_proxy_pool.splice(index, 1);
- connection.logdebug("[queue/smtp_proxy] pulling dead proxy connection from pool: (" +
+ connection.logdebug(self, "pulling dead proxy connection from pool: (" +
connection.server.notes.smtp_proxy_pool.length + ")");
}
}
if (reset_active_connections &&
connection.server.notes.active_proxy_conections) {
connection.server.notes.active_proxy_conections--;
- connection.logdebug("[queue/smtp_proxy] active proxy connections: (" +
+ connection.logdebug(self, "active proxy connections: (" +
connection.server.notes.active_proxy_conections + ")");
}
@@ -117,9 +117,9 @@ function _smtp_proxy_idle(self, connection) {
connection.server.notes.active_proxy_conections--;
- connection.logdebug("[queue/smtp_proxy] putting proxy connection back in pool: (" +
+ connection.logdebug(self, "putting proxy connection back in pool: (" +
connection.server.notes.smtp_proxy_pool.length + ")");
- connection.logdebug("[queue/smtp_proxy] active proxy connections: (" +
+ connection.logdebug(self, "active proxy connections: (" +
connection.server.notes.active_proxy_conections + ")");
// Unlink this connection from the proxy now that it is back
@@ -132,7 +132,7 @@ function _smtp_proxy_idle(self, connection) {
}
exports.hook_mail = function (next, connection, params) {
- connection.loginfo("[queue/smtp_proxy] proxying");
+ connection.loginfo(this, "proxying");
var self = this;
var mail_from = params[0];
var data_marker = 0;
@@ -145,7 +145,7 @@ exports.hook_mail = function (next, connection, params) {
while (wrote_all && (data_marker < connection.transaction.data_lines.length)) {
var line = connection.transaction.data_lines[data_marker];
data_marker++;
- connection.logdata("[queue/smtp_proxy] C: " + line);
+ connection.logdata(self, "C: " + line);
// this protection is due to bug #
in_write = true;
wrote_all = smtp_proxy.socket.write(line.replace(/^\./, '..').replace(/\r?\n/g, '\r\n'));
@@ -171,18 +171,18 @@ exports.hook_mail = function (next, connection, params) {
});
smtp_proxy.socket.on('error', function (err) {
- connection.logdebug("[queue/smtp_proxy] Ongoing connection failed: " + err);
+ connection.logdebug(self, "Ongoing connection failed: " + err);
_destroy_smtp_proxy(self, connection, smtp_proxy);
return next(DENYSOFT,'Proxy connection failed');
});
smtp_proxy.socket.on('timeout', function () {
- connection.logdebug("[queue/smtp_proxy] Ongoing connection timed out");
+ connection.logdebug(self, "Ongoing connection timed out");
_destroy_smtp_proxy(self, connection, smtp_proxy);
});
smtp_proxy.socket.on('close', function (had_error) {
- connection.logdebug("[queue/smtp_proxy] Ongoing connection closed");
+ connection.logdebug(self, "Ongoing connection closed");
_destroy_smtp_proxy(self, connection, smtp_proxy);
});
@@ -193,15 +193,15 @@ exports.hook_mail = function (next, connection, params) {
if (cmd === 'dot') {
line = '.';
}
- connection.logprotocol("[queue/smtp_proxy] C: " + line);
+ connection.logprotocol(self, "C: " + line);
this.write(line + "\r\n");
smtp_proxy.command = cmd.toLowerCase();
smtp_proxy.response = [];
};
smtp_proxy.socket.on('line', function (line) {
var matches;
- connection.logprotocol("[queue/smtp_proxy] S: " + line);
+ connection.logprotocol(self, "S: " + line);
if (matches = smtp_regexp.exec(line)) {
var code = matches[1],
cont = matches[2],
@@ -252,7 +252,7 @@ exports.hook_mail = function (next, connection, params) {
// errors are OK for rcpt, but nothing else
// this can also happen if the destination server
// times out, but that is okay.
- connection.loginfo("[queue/smtp_proxy] message denied, proxying failed");
+ connection.loginfo(self, "message denied, proxying failed");
smtp_proxy.socket.send_command('RSET');
}
return smtp_proxy.next(code.match(/^4/) ?
@@ -287,7 +287,7 @@ exports.hook_mail = function (next, connection, params) {
smtp_proxy.next();
break;
case 'dot':
- connection.loginfo("[queue/smtp_proxy] message delivered, proxying complete");
+ connection.loginfo(self, "message delivered, proxying complete");
smtp_proxy.next(OK, smtp_proxy.response + ' (' + connection.transaction.uuid + ')');
smtp_proxy.socket.send_command('RSET');
break;
@@ -304,8 +304,8 @@ exports.hook_mail = function (next, connection, params) {
}
else {
// Unrecognised response.
- connection.logerror("[queue/smtp_proxy] Unrecognised response from upstream server: " + line);
- connection.loginfo("[queue/smtp_proxy] message denied, proxying failed");
+ connection.logerror(self, "Unrecognised response from upstream server: " + line);
+ connection.loginfo(self, "message denied, proxying failed");
smtp_proxy.socket.send_command('RSET');
return smtp_proxy.next(DENYSOFT);
}
View
10 plugins/rcpt_to.in_host_list.js
@@ -7,31 +7,31 @@ exports.hook_rcpt = function(next, connection, params) {
return next();
}
- connection.loginfo("[rcpt_to.in_host_list] Checking if " + rcpt + " host is in host_lists");
+ connection.loginfo(this, "Checking if " + rcpt + " host is in host_lists");
var domain = rcpt.host.toLowerCase();
var host_list = this.config.get('host_list', 'list');
var host_list_regex = this.config.get('host_list_regex', 'list');
var i = 0;
for (i in host_list) {
- connection.logdebug("[rcpt_to.in_host_list] checking " + domain + " against " + host_list[i]);
+ connection.logdebug(this, "checking " + domain + " against " + host_list[i]);
// normal matches
if (host_list[i].toLowerCase() === domain) {
- connection.logdebug("[rcpt_to.in_host_list] Allowing " + domain);
+ connection.logdebug(this, "Allowing " + domain);
return next(OK);
}
}
if (host_list_regex.length) {
var regex = new RegExp ('^(?:' + host_list_regex.join('|') + ')$', 'i');
- connection.logdebug("[rcpt_to.in_host_list] checking " + domain + " against regexp " + regex.source);
+ connection.logdebug(this, "checking " + domain + " against regexp " + regex.source);
// regex matches
if (domain.match(regex)) {
- connection.logdebug("[rcpt_to.in_host_list] Allowing " + domain);
+ connection.logdebug(this, "Allowing " + domain);
return next(OK);
}
}
View
4 plugins/rdns.regexp.js
@@ -16,13 +16,13 @@ exports.hook_connect = function (next, connection) {
for (var i=0,l=allow_list.length; i < l; i++) {
var re = new RegExp(allow_list[i]);
if (re.test(connection.remote_host)) {
- connection.loginfo("[rdns.regexp] rdns matched: " + allow_list[i] +
+ connection.loginfo(this, "rdns matched: " + allow_list[i] +
", allowing");
return next();
}
}
- connection.loginfo("[rdns.regexp] rdns matched: " + deny_list[i] + ", blocking");
+ connection.loginfo(this, "rdns matched: " + deny_list[i] + ", blocking");
return next(DENY, "Connection from a known bad host");
}
}
View
2 plugins/relay_all.js
@@ -6,7 +6,7 @@ exports.register = function() {
exports.confirm_all = function(next, connection, params) {
var recipient = params.shift();
- connection.loginfo("[relay_all] confirming recipient " + recipient);
+ connection.loginfo(this, "confirming recipient " + recipient);
connection.relaying = 1;
next(OK);
};
View
8 plugins/spamassassin.js
@@ -81,12 +81,12 @@ exports.hook_data_post = function (next, connection) {
};
socket.on('timeout', function () {
- connection.logerror("[spamassassin] spamd connection timed out");
+ connection.logerror(plugin, "spamd connection timed out");
socket.end();
next();
});
socket.on('error', function (err) {
- connection.logerror("[spamassassin] spamd connection failed: " + err);
+ connection.logerror(plugin, "spamd connection failed: " + err);
// we don't deny on error - maybe another plugin can deliver
next();
});
@@ -107,7 +107,7 @@ exports.hook_data_post = function (next, connection) {
var state = 'line0';
socket.on('line', function (line) {
- connection.logprotocol("[spamassassin] Spamd C: " + line);
+ connection.logprotocol(plugin, "Spamd C: " + line);
line = line.replace(/\r?\n/, '');
if (state === 'line0') {
spamd_response.line0 = line;
@@ -154,7 +154,7 @@ exports.hook_data_post = function (next, connection) {
}
connection.transaction.add_header('X-Spam-Level', stars_string);
- connection.loginfo("[spamassassin] spamassassin returned: " + spamd_response.flag + ', ' +
+ connection.loginfo(plugin, "spamassassin returned: " + spamd_response.flag + ', ' +
spamd_response.hits + '/' + spamd_response.reqd +
" Reject at: " + config.main.reject_threshold);
View
8 plugins/xclient.js
@@ -24,7 +24,7 @@ exports.hook_unrecognized_command = function (next, connection, params) {
var config = this.config.get('xclient.hosts','list');
var found;
for (var i in config) {
- connection.logdebug('[xclient] Checking ' + connection.remote_ip + ' == ' + config[i]);
+ connection.logdebug(this, 'Checking ' + connection.remote_ip + ' == ' + config[i]);
// TODO: handle ip/mask here.
if (connection.remote_ip === config[i]) {
found = true;
@@ -42,7 +42,7 @@ exports.hook_unrecognized_command = function (next, connection, params) {
for (var a=0; a < args.length; a++) {
var match = /^([^=]+)=([^ ]+)/.exec(args[a]);
if (match) {
- connection.logdebug('[xclient] found key=' + match[1] + ' value=' + match[2]);
+ connection.logdebug(this, 'found key=' + match[1] + ' value=' + match[2]);
switch(match[1]) {
case 'addr':
// IPv6 is prefixed in the XCLIENT protocol
@@ -74,11 +74,11 @@ exports.hook_unrecognized_command = function (next, connection, params) {
}
break;
default:
- connection.logwarn('[xclient] unknown argument: ' + args[a]);
+ connection.logwarn(this, 'unknown argument: ' + args[a]);
}
}
else {
- connection.logwarn('[xclient] unknown argument: ' + args[a]);
+ connection.logwarn(this, 'unknown argument: ' + args[a]);
}
}

0 comments on commit 130162b

Please sign in to comment.