Permalink
Browse files

Change around so config is loaded when changed

  • Loading branch information...
1 parent e520a33 commit b2fb0e989f5e76838766b4a36572155d9c1b0847 Matt Sergeant committed Dec 3, 2013
Showing with 7 additions and 12 deletions.
  1. +7 −12 plugins/relay_force_routing.js
@@ -2,30 +2,25 @@
// documentation via: haraka -h plugins/relay_force_routing
-exports.register = function() {
- this.register_hook('get_mx', 'force_routing');
- this.domain_ini = this.config.get('relay_dest_domains.ini', 'ini');
-};
-
-exports.force_routing = function (next, hmail, domain) {
- var force_route = lookup_routing(this, this.domain_ini['domains'], domain);
+exports.hook_get_mx = function (next, hmail, domain) {
+ var domain_ini = this.config.get('relay_dest_domains.ini', 'ini');
+ var force_route = lookup_routing(domain_ini['domains'], domain);
if (force_route != "NOTFOUND" ){
- this.logdebug(this, 'using ' + force_route + ' for ' + domain);
+ this.logdebug('using ' + force_route + ' for: ' + domain);
next(OK, force_route);
} else {
- this.logdebug(this, 'using normal MX lookup' + ' for ' + domain);
+ this.logdebug('using normal MX lookup for: ' + domain);
next(CONT);
}
-};
+}
/**
* @return {string}
*/
-function lookup_routing (plugin, domains_ini, domain) {
+function lookup_routing (domains_ini, domain) {
if (domain in domains_ini) {
var config = JSON.parse(domains_ini[domain]);
- plugin.logdebug(plugin, 'found config for' + domain + ': ' + domains_ini['nexthop']);
return config['nexthop'];
}
return "NOTFOUND";

0 comments on commit b2fb0e9

Please sign in to comment.