From c58cd3009ae4dc2a612864ba3cc8c332440f6be5 Mon Sep 17 00:00:00 2001 From: PiBa-NL Date: Fri, 7 Aug 2015 21:17:24 +0200 Subject: spamd, allow configuring interface to listen/intercept on --- config/spamd/spamd.inc | 44 +++++++++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 15 deletions(-) (limited to 'config/spamd/spamd.inc') diff --git a/config/spamd/spamd.inc b/config/spamd/spamd.inc index 71f20106..fd09837c 100644 --- a/config/spamd/spamd.inc +++ b/config/spamd/spamd.inc @@ -199,21 +199,35 @@ function spamd_generate_rules($type) { switch($type) { case 'nat': $natrules .= "\n# spam table \n"; - $wanif = get_real_interface("wan"); - $natrules .= "table persist\n"; - $natrules .= "table persist\n"; - $natrules .= "table persist\n"; - if(file_exists("/var/db/whitelist.txt")) - $natrules .= "table persist file \"/var/db/whitelist.txt\"\n"; - $natrules .= "rdr pass on {$wanif} proto tcp from to port smtp -> 127.0.0.1 port spamd\n"; - $natrules .= "rdr pass on {$wanif} proto tcp from to port smtp -> 127.0.0.1 port spamd\n"; - $natrules .= "rdr pass on {$wanif} proto tcp from ! to port smtp -> 127.0.0.1 port spamd\n"; - if($config['installedpackages']['spamdsettings']['config']) - foreach($config['installedpackages']['spamdsettings']['config'] as $ss) - $nextmta = $ss['nextmta']; - if($nextmta <> "") { - $natrules .= "rdr pass on {$wanif} proto tcp from to port smtp -> {$nextmta} port smtp\n"; - } + $natrules .= "table persist\n"; + $natrules .= "table persist\n"; + $natrules .= "table persist\n"; + if(file_exists("/var/db/whitelist.txt")) + $natrules .= "table persist file \"/var/db/whitelist.txt\"\n"; + + if (is_array($config['installedpackages']['spamdsettings']['config'])) + $spamdconfig = $config['installedpackages']['spamdsettings']['config']['0']; + else + $spamdconfig = $config['installedpackages']['spamdsettings']['config']; + + if($spamdconfig) { + $nextmta = $spamdconfig['nextmta']; + $spamdbinds = explode(',', $spamdconfig['spamdbinds_array']); + if (is_array($spamdbinds)) { + foreach($spamdbinds as $interface) { + $wanif = get_real_interface($interface); + if (!isset($wanif)) + continue; + $natrules .= "rdr pass on {$wanif} proto tcp from to port smtp -> 127.0.0.1 port spamd\n"; + $natrules .= "rdr pass on {$wanif} proto tcp from to port smtp -> 127.0.0.1 port spamd\n"; + $natrules .= "rdr pass on {$wanif} proto tcp from ! to port smtp -> 127.0.0.1 port spamd\n"; + if($nextmta <> "") { + $natrules .= "rdr pass on {$wanif} proto tcp from to port smtp -> {$nextmta} port smtp\n"; + } + } + } + } + $natrules .= "\n"; break; } -- cgit v1.2.3