diff --git a/data/conf/rspamd/dynmaps/settings.php b/data/conf/rspamd/dynmaps/settings.php index eb68c910..c87f6682 100644 --- a/data/conf/rspamd/dynmaps/settings.php +++ b/data/conf/rspamd/dynmaps/settings.php @@ -31,19 +31,52 @@ catch (PDOException $e) { ?> settings { -query("SELECT `host` FROM `forwarding_hosts`"); + $stmt = $pdo->query("SELECT `host` FROM `forwarding_hosts` WHERE `filter_spam` = 1"); $rows = $stmt->fetchAll(PDO::FETCH_COLUMN); } catch (PDOException $e) { $rows = array(); } + +if (!empty($rows)) { +?> + whitelist_forwarding_hosts_with_spam_filter { + priority = high; + + ip = ""; + + apply "default" { + actions { + reject = 999.9; + greylist = 999.8; + } + } + symbols [ + "WHITELIST_FORWARDING_HOST" + ] + } +query("SELECT `host` FROM `forwarding_hosts` WHERE `filter_spam` = 0"); + $rows = $stmt->fetchAll(PDO::FETCH_COLUMN); +} +catch (PDOException $e) { + $rows = array(); +} + if (!empty($rows)) { ?> whitelist_forwarding_hosts { diff --git a/data/web/admin.php b/data/web/admin.php index 6c7033e5..371cb8d5 100644 --- a/data/web/admin.php +++ b/data/web/admin.php @@ -276,6 +276,7 @@ $tfa_data = get_tfa(); + @@ -284,15 +285,14 @@ $tfa_data = get_tfa(); $forwarding_hosts = get_forwarding_hosts(); if ($forwarding_hosts) { foreach ($forwarding_hosts as $host) { - $source = $host->source; - $host = $host->host; ?> - - + host));?> + source));?> + filter_spam ? "✔" : "✘";?>
- +
@@ -319,6 +319,13 @@ $tfa_data = get_tfa(); +
+
+
+ +
+
+
diff --git a/data/web/inc/functions.inc.php b/data/web/inc/functions.inc.php index d4f7dcc5..97a06b8d 100644 --- a/data/web/inc/functions.inc.php +++ b/data/web/inc/functions.inc.php @@ -5094,7 +5094,7 @@ function get_u2f_registrations($username) { } function get_forwarding_hosts() { global $pdo; - $sel = $pdo->prepare("SELECT host, source FROM `forwarding_hosts`"); + $sel = $pdo->prepare("SELECT * FROM `forwarding_hosts`"); $sel->execute(); return $sel->fetchAll(PDO::FETCH_OBJ); } @@ -5111,6 +5111,7 @@ function add_forwarding_host($postarray) { } $source = $postarray['hostname']; $host = $postarray['hostname']; + $filter_spam = !empty($postarray['filter_spam']); $hosts = array(); if (preg_match('/^[0-9a-fA-F:\/]+$/', $host)) { // IPv6 address $hosts = array($host); @@ -5133,10 +5134,15 @@ function add_forwarding_host($postarray) { if ($source == $host) $source = ''; try { - $stmt = $pdo->prepare("INSERT IGNORE INTO `forwarding_hosts` (`host`, `source`) VALUES (:host, :source)"); + if ($filter_spam) { // if the host already exists, REPLACE it with the spam filter turned on + $stmt = $pdo->prepare("REPLACE INTO `forwarding_hosts` (`host`, `source`, `filter_spam`) VALUES (:host, :source, :filter_spam)"); + } else { // if the host already exists, IGNORE it no matter whether the spam filter is already turned on + $stmt = $pdo->prepare("INSERT IGNORE INTO `forwarding_hosts` (`host`, `source`, `filter_spam`) VALUES (:host, :source, :filter_spam)"); + } $stmt->execute(array( ':host' => $host, ':source' => $source, + ':filter_spam' => $filter_spam ? 1 : 0, )); } catch (PDOException $e) { diff --git a/data/web/inc/init_db.inc.php b/data/web/inc/init_db.inc.php index 81c9be2a..a93680ed 100644 --- a/data/web/inc/init_db.inc.php +++ b/data/web/inc/init_db.inc.php @@ -3,7 +3,7 @@ function init_db_schema() { try { global $pdo; - $db_version = "01052017_1702"; + $db_version = "07052017_0824"; $stmt = $pdo->query("SHOW TABLES LIKE 'versions'"); $num_results = count($stmt->fetchAll(PDO::FETCH_ASSOC)); @@ -268,7 +268,8 @@ function init_db_schema() { "forwarding_hosts" => array( "cols" => array( "host" => "VARCHAR(255) NOT NULL", - "source" => "VARCHAR(255) NOT NULL" + "source" => "VARCHAR(255) NOT NULL", + "filter_spam" => "TINYINT(1) NOT NULL DEFAULT '0'" ), "keys" => array( "primary" => array( diff --git a/data/web/lang/lang.de.php b/data/web/lang/lang.de.php index 947bb267..58fc9ba2 100644 --- a/data/web/lang/lang.de.php +++ b/data/web/lang/lang.de.php @@ -472,7 +472,7 @@ $lang['admin']['no_record'] = 'Kein Eintrag'; $lang['admin']['filter_table'] = 'Tabelle Filtern'; $lang['admin']['empty'] = 'Keine Einträge vorhanden'; $lang['admin']['forwarding_hosts'] = 'Weiterleitungs-Hosts'; -$lang['admin']['forwarding_hosts_hint'] = 'Eingehende Nachrichten werden von den hier gelisteten Hosts bedingungslos akzeptiert. Diese Hosts werden dann nicht mit DNSBLs abgeglichen oder Greylisting unterworfen. Von ihnen empfangener Spam wird nie abgelehnt und immer in den Spam-Ordner einsortiert. Die übliche Verwendung für diese Funktion ist, um Mailserver anzugeben, auf denen eine Weiterleitung zu Ihrem Mailcow-Server eingerichtet wurde.'; +$lang['admin']['forwarding_hosts_hint'] = 'Eingehende Nachrichten werden von den hier gelisteten Hosts bedingungslos akzeptiert. Diese Hosts werden dann nicht mit DNSBLs abgeglichen oder Greylisting unterworfen. Von ihnen empfangener Spam wird nie abgelehnt, optional kann er aber in den Spam-Ordner einsortiert werden. Die übliche Verwendung für diese Funktion ist, um Mailserver anzugeben, auf denen eine Weiterleitung zu Ihrem Mailcow-Server eingerichtet wurde.'; $lang['admin']['forwarding_hosts_add_hint'] = 'Sie können entweder IPv4/IPv6-Adressen, Netzwerke in CIDR-Notation, Hostnamen (die zu IP-Adressen aufgelöst werden), oder Domainnamen (die zu IP-Adressen aufgelöst werden, indem ihr SPF-Record abgefragt wird oder, in dessen Abwesenheit, ihre MX-Records) angeben.'; $lang['edit']['host'] = 'Host'; $lang['edit']['source'] = 'Quelle'; diff --git a/data/web/lang/lang.en.php b/data/web/lang/lang.en.php index ea573f49..df6c93e8 100644 --- a/data/web/lang/lang.en.php +++ b/data/web/lang/lang.en.php @@ -484,7 +484,7 @@ $lang['admin']['no_record'] = 'No record'; $lang['admin']['filter_table'] = 'Filter table'; $lang['admin']['empty'] = 'No results'; $lang['admin']['forwarding_hosts'] = 'Forwarding Hosts'; -$lang['admin']['forwarding_hosts_hint'] = 'Incoming messages are unconditionally accepted from any hosts listed here. These hosts are then not checked against DNSBLs or subjected to greylisting. Spam received from them is never rejected and always filed into the Junk folder. The most common use for this is to specify mail servers on which you have set up a rule that forwards incoming emails to your Mailcow server.'; +$lang['admin']['forwarding_hosts_hint'] = 'Incoming messages are unconditionally accepted from any hosts listed here. These hosts are then not checked against DNSBLs or subjected to greylisting. Spam received from them is never rejected, but optionally it can be filed into the Junk folder. The most common use for this is to specify mail servers on which you have set up a rule that forwards incoming emails to your Mailcow server.'; $lang['admin']['forwarding_hosts_add_hint'] = 'You can either specify IPv4/IPv6 addresses, networks in CIDR notation, host names (which will be resolved to IP addresses), or domain names (which will be resolved to IP addresses by querying SPF records or, in their absence, MX records).'; $lang['edit']['host'] = 'Host'; $lang['edit']['source'] = 'Source';