Skip to content

Commit 1b0fea4

Browse files
committed
rspam: add fields to set redis servers and password
1 parent 4191a7d commit 1b0fea4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

39 files changed

+384
-47
lines changed

install/lib/installer_base.lib.php

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1825,33 +1825,48 @@ public function configure_rspamd() {
18251825
fclose($fps);
18261826
unset($dkim_domains);
18271827

1828-
# local.d templates with template tags
1829-
$tpl = new tpl();
1830-
$tpl->newTemplate('rspamd_dkim_signing.conf.master');
1831-
$tpl->setVar('dkim_path', $mail_config['dkim_path']);
1832-
wf('/etc/rspamd/local.d/dkim_signing.conf', $tpl->grab());
1833-
1834-
$tpl = new tpl();
1835-
$tpl->newTemplate('rspamd_options.inc.master');
1836-
1828+
# look up values for use in template tags
18371829
$local_addrs = array();
18381830
$ips = $this->db->queryAllRecords('SELECT `ip_address`, `ip_type` FROM ?? WHERE `server_id` = ?', $conf['mysql']['database'].'.server_ip', $conf['server_id']);
18391831
if(is_array($ips) && !empty($ips)){
18401832
foreach($ips as $ip){
1841-
$local_addrs[] = array('quoted_ip' => "\"".$ip['ip_address']."\",\n");
1833+
$local_addrs[] = array(
1834+
'ip' => $ip['ip_address'],
1835+
'quoted_ip' => "\"".$ip['ip_address']."\",\n"
1836+
);
18421837
}
18431838
}
1844-
$tpl->setLoop('local_addrs', $local_addrs);
1845-
wf('/etc/rspamd/local.d/options.inc', $tpl->grab());
1839+
1840+
# local.d templates with template tags
1841+
# note: ensure these template files are in server/conf/ and symlinked in install/tpl/
1842+
$local_d = array(
1843+
'dkim_signing.conf',
1844+
'options.inc',
1845+
'redis.conf',
1846+
'classifier-bayes.conf',
1847+
);
1848+
foreach ($local_d as $f) {
1849+
$tpl = new tpl();
1850+
$tpl->newTemplate("rspamd_${f}.master");
1851+
1852+
$tpl->setVar('dkim_path', $mail_config['dkim_path']);
1853+
$tpl->setVar('rspamd_redis_servers', $mail_config['rspamd_redis_servers']);
1854+
$tpl->setVar('rspamd_redis_password', $mail_config['rspamd_redis_password']);
1855+
$tpl->setVar('rspamd_redis_bayes_servers', $mail_config['rspamd_redis_bayes_servers']);
1856+
$tpl->setVar('rspamd_redis_bayes_password', $mail_config['rspamd_redis_bayes_password']);
1857+
if(count($local_addrs) > 0) {
1858+
$tpl->setLoop('local_addrs', $local_addrs);
1859+
}
1860+
1861+
wf("/etc/rspamd/local.d/${f}", $tpl->grab());
1862+
}
1863+
18461864

18471865
# local.d templates without template tags
18481866
$local_d = array(
18491867
'groups.conf',
18501868
'antivirus.conf',
1851-
'classifier-bayes.conf',
1852-
'greylist.conf',
18531869
'mx_check.conf',
1854-
'redis.conf',
18551870
'milter_headers.conf',
18561871
'neural.conf',
18571872
'neural_group.conf',
@@ -1894,6 +1909,11 @@ public function configure_rspamd() {
18941909
}
18951910
}
18961911

1912+
# rename rspamd templates we no longer use
1913+
if(file_exists("/etc/rspamd/local.d/greylist.conf")) {
1914+
rename("/etc/rspamd/local.d/greylist.conf", "/etc/rspamd/local.d/greylist.old");
1915+
}
1916+
18971917

18981918
exec('chmod a+r /etc/rspamd/local.d/* /etc/rspamd/local.d/maps.d/* /etc/rspamd/override.d/*');
18991919

install/tpl/rspamd_classifier-bayes.conf.master

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../server/conf/rspamd_classifier-bayes.conf.master

install/tpl/rspamd_dkim_signing.conf.master

Lines changed: 0 additions & 4 deletions
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../server/conf/rspamd_dkim_signing.conf.master

install/tpl/rspamd_greylist.conf.master

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
enabled = true;
2-
servers = "localhost";
32
key_prefix = "rmx";
43
symbol_bad_mx = "MX_INVALID";
54
symbol_no_mx = "MX_MISSING";
65
symbol_good_mx = "MX_GOOD";
76
expire = 86400;
87
expire_novalid = 7200;
9-
greylist_invalid = false;
8+
greylist_invalid = false;

install/tpl/rspamd_neural.conf.master

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
servers = 127.0.0.1:6379;
21
enabled = true;
32

43
rules {
@@ -28,4 +27,4 @@ rules {
2827
symbol_ham = "NEURAL_HAM_SHORT";
2928
ann_expire = 1d;
3029
}
31-
}
30+
}

install/tpl/rspamd_redis.conf.master

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../server/conf/rspamd_redis.conf.master

0 commit comments

Comments
 (0)