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 +++++++++++++++++++++++++++-------------- config/spamd/spamd_db.php | 31 +++++++++++++++++------------ config/spamd/spamd_settings.xml | 10 ++++++++++ 3 files changed, 57 insertions(+), 28 deletions(-) (limited to 'config/spamd') 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; } diff --git a/config/spamd/spamd_db.php b/config/spamd/spamd_db.php index e1d004f7..dab599b8 100644 --- a/config/spamd/spamd_db.php +++ b/config/spamd/spamd_db.php @@ -324,6 +324,11 @@ if (typeof getURL == 'undefined') { " . date("H:i:s", $dt); +} + if($filter) { if($not) { $fd = fopen("/tmp/spamdb", "w"); @@ -387,9 +392,9 @@ if (typeof getURL == 'undefined') { switch($pkgdb_split[0]) { case "SPAMTRAP": $recordtype = htmlentities($pkgdb_split[0]); - $srcip = htmlentities($pkgdb_split[1]); - $fromaddress = htmlentities($pkgdb_split[3]); - $toaddress = htmlentities($pkgdb_split[4]); + $srcip = ""; + $fromaddress = htmlentities($pkgdb_split[1]); + $toaddress = ""; $first = ""; $pass = ""; $expire = ""; @@ -402,7 +407,7 @@ if (typeof getURL == 'undefined') { $toaddress = ""; $first = ""; $pass = ""; - $expire = htmlentities($pkgdb_split[2]); + $expire = formatspamddatetime($pkgdb_split[2]); $attempts = ""; break; case "GREY": @@ -410,9 +415,9 @@ if (typeof getURL == 'undefined') { $srcip = htmlentities($pkgdb_split[1]); $fromaddress = htmlentities($pkgdb_split[3]); $toaddress = htmlentities($pkgdb_split[4]); - $first = htmlentities($pkgdb_split[5]); - $pass = htmlentities($pkgdb_split[6]); - $expire = htmlentities($pkgdb_split[7]); + $first = formatspamddatetime($pkgdb_split[5]); + $pass = formatspamddatetime($pkgdb_split[6]); + $expire = formatspamddatetime($pkgdb_split[7]); $attempts = htmlentities($pkgdb_split[8]); break; case "WHITE": @@ -420,9 +425,9 @@ if (typeof getURL == 'undefined') { $srcip = htmlentities($pkgdb_split[1]); $fromaddress = ""; $toaddress = ""; - $first = htmlentities($pkgdb_split[4]); - $pass = htmlentities($pkgdb_split[5]); - $expire = htmlentities($pkgdb_split[6]); + $first = formatspamddatetime($pkgdb_split[4]); + $pass = formatspamddatetime($pkgdb_split[5]); + $expire = formatspamddatetime($pkgdb_split[6]); $attempts = htmlentities($pkgdb_split[8]); break; } @@ -433,9 +438,9 @@ if (typeof getURL == 'undefined') { echo "{$srcip}"; echo "{$fromaddress}"; echo "{$toaddress}"; - echo "" . date("Y-m-d", $first) . "
" . date("H:i:s", $first) . "
"; - echo "" . date("Y-m-d", $pass) . "
" . date("H:i:s", $pass) . "
"; - echo "" . date("Y-m-d", $expire) . "
" . date("H:i:s", $expire) . "
"; + echo "" . $first . ""; + echo "" . $pass . ""; + echo "" . $expire . ""; echo "{$attempts}"; echo ""; $rowtext = "\"Add "; diff --git a/config/spamd/spamd_settings.xml b/config/spamd/spamd_settings.xml index 3fdab415..225ef4a6 100644 --- a/config/spamd/spamd_settings.xml +++ b/config/spamd/spamd_settings.xml @@ -82,6 +82,16 @@ + + Intercept on interfaces + spamdbinds_array + + + + interfaces_selection + true + loopback + Identifier identifier -- cgit v1.2.3 From 1cebd0dec21d51ee214770e0f581c02a1bfb615b Mon Sep 17 00:00:00 2001 From: PiBa-NL Date: Sat, 8 Aug 2015 19:27:07 +0200 Subject: spamd, following the coding guidelines more closely. --- config/spamd/spamd.inc | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'config/spamd') diff --git a/config/spamd/spamd.inc b/config/spamd/spamd.inc index fd09837c..dffdb461 100644 --- a/config/spamd/spamd.inc +++ b/config/spamd/spamd.inc @@ -202,13 +202,15 @@ function spamd_generate_rules($type) { $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(file_exists("/var/db/whitelist.txt")) { + $natrules .= "table persist file \"/var/db/whitelist.txt\"\n"; + } - if (is_array($config['installedpackages']['spamdsettings']['config'])) + if (is_array($config['installedpackages']['spamdsettings']['config'])) { $spamdconfig = $config['installedpackages']['spamdsettings']['config']['0']; - else + } else { $spamdconfig = $config['installedpackages']['spamdsettings']['config']; + } if($spamdconfig) { $nextmta = $spamdconfig['nextmta']; @@ -216,8 +218,9 @@ function spamd_generate_rules($type) { if (is_array($spamdbinds)) { foreach($spamdbinds as $interface) { $wanif = get_real_interface($interface); - if (!isset($wanif)) + 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"; -- cgit v1.2.3 From 3b12fa7aec920d072592c8801d1da4a84aac6056 Mon Sep 17 00:00:00 2001 From: PiBa-NL Date: Sun, 9 Aug 2015 00:27:56 +0200 Subject: spamd, coding style, add some more spaces --- config/spamd/spamd.inc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'config/spamd') diff --git a/config/spamd/spamd.inc b/config/spamd/spamd.inc index dffdb461..7dc1ecdc 100644 --- a/config/spamd/spamd.inc +++ b/config/spamd/spamd.inc @@ -202,7 +202,7 @@ function spamd_generate_rules($type) { $natrules .= "table persist\n"; $natrules .= "table persist\n"; $natrules .= "table persist\n"; - if(file_exists("/var/db/whitelist.txt")) { + if (file_exists("/var/db/whitelist.txt")) { $natrules .= "table persist file \"/var/db/whitelist.txt\"\n"; } @@ -212,11 +212,11 @@ function spamd_generate_rules($type) { $spamdconfig = $config['installedpackages']['spamdsettings']['config']; } - if($spamdconfig) { + if ($spamdconfig) { $nextmta = $spamdconfig['nextmta']; $spamdbinds = explode(',', $spamdconfig['spamdbinds_array']); if (is_array($spamdbinds)) { - foreach($spamdbinds as $interface) { + foreach ($spamdbinds as $interface) { $wanif = get_real_interface($interface); if (!isset($wanif)) { continue; @@ -224,7 +224,7 @@ function spamd_generate_rules($type) { $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 <> "") { + if ($nextmta <> "") { $natrules .= "rdr pass on {$wanif} proto tcp from to port smtp -> {$nextmta} port smtp\n"; } } -- cgit v1.2.3