Skip to content

Commit

Permalink
helo: use valid_regexes from utils
Browse files Browse the repository at this point in the history
  • Loading branch information
msimerson committed Jun 27, 2014
1 parent 7f8d742 commit e849eb1
Showing 1 changed file with 2 additions and 17 deletions.
19 changes: 2 additions & 17 deletions plugins/helo.checks.js
@@ -1,6 +1,7 @@
// Check various bits of the HELO string
var dns = require('dns');
var net_utils = require('./net_utils');
var utils = require('./utils');

var checks = [
'init', // config loading, multiplicity detection
Expand Down Expand Up @@ -70,7 +71,7 @@ exports.register = function () {
load_config();

var load_re_file = function () {
var regex_list = plugin.valid_regexes(plugin.config.get('helo.checks.regexps', 'list', load_re_file));
var regex_list = utils.valid_regexes(plugin.config.get('helo.checks.regexps', 'list', load_re_file));
// pre-compile the regexes
plugin.cfg.list_re = new RegExp('^(' + regex_list.join('|') + ')$', 'i');
};
Expand Down Expand Up @@ -504,19 +505,3 @@ exports.get_a_records = function (host, cb) {
return cb(null, ips);
});
};

exports.valid_regexes = function (list, file) {
// accepts an array of regexes and a file name
var valid = [];
for (var i=0; i<list.length; i++) {
try {
new RegExp(list[i]);
}
catch (e) {
this.logerror(this, "invalid regex in " + file + ", " + list[i]);
continue;
}
valid.push(list[i]);
}
return valid; // returns a list of valid regexes
};

0 comments on commit e849eb1

Please sign in to comment.