Skip to content

Commit 282e5ec

Browse files
committed
rspamd: server ips in local_addrs
1 parent b59dc3f commit 282e5ec

File tree

5 files changed

+21
-23
lines changed

5 files changed

+21
-23
lines changed

install/lib/installer_base.lib.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1834,8 +1834,6 @@ public function configure_rspamd() {
18341834
$tpl = new tpl();
18351835
$tpl->newTemplate('rspamd_options.inc.master');
18361836

1837-
echo "\nDEBUGGING local_addrs LOOP\n\n";
1838-
sleep(1);
18391837
$local_addrs = array();
18401838
$ips = $this->db->queryAllRecords('SELECT `ip_address`, `ip_type` FROM ?? WHERE `server_id` = ?', $conf['mysql']['database'].'.server_ip', $conf['server_id']);
18411839
if(is_array($ips) && !empty($ips)){
@@ -1890,9 +1888,9 @@ public function configure_rspamd() {
18901888
);
18911889
foreach ($maps_d as $f) {
18921890
if(file_exists($conf['ispconfig_install_dir']."/server/conf-custom/install/rspamd_${f}.master")) {
1893-
exec('cp '.$conf['ispconfig_install_dir']."/server/conf-custom/install/rspamd_${f}.master /etc/rspamd/local.d/maps.d/");
1891+
exec('cp '.$conf['ispconfig_install_dir']."/server/conf-custom/install/rspamd_${f}.master /etc/rspamd/local.d/maps.d/${f}");
18941892
} else {
1895-
exec("cp tpl/rspamd_${f}.master /etc/rspamd/local.d/maps.d/");
1893+
exec("cp tpl/rspamd_${f}.master /etc/rspamd/local.d/maps.d/${f}");
18961894
}
18971895
}
18981896

install/tpl/rspamd_options.inc.master

Lines changed: 0 additions & 12 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_options.inc.master

install/tpl/rspamd_users.conf.master

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Addrs local to this server.
2+
local_addrs = [
3+
"127.0.0.0/8",
4+
"::1",
5+
<tmpl_loop name="local_addrs"> <tmpl_var name='quoted_ip'></tmpl_loop>];
6+
7+
# This list is generated by ISPConfig, place custom addresses/networks in local_networks.inc.
8+
local_networks = "/etc/rspamd/local.d/local_networks.inc";
9+
10+
dns {
11+
nameserver = ["127.0.0.1:53:10"];
12+
}

server/plugins-available/rspamd_plugin.inc.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -459,17 +459,17 @@ function server_ip($event_name, $data) {
459459

460460
if(is_dir('/etc/rspamd')) {
461461
$tpl = new tpl();
462-
$tpl->newTemplate('rspamd_users.conf.master');
462+
$tpl->newTemplate('rspamd_options.inc.master');
463463

464-
$whitelist_ips = array();
465-
$ips = $app->db->queryAllRecords("SELECT * FROM server_ip WHERE server_id = ?", $conf['server_id']);
464+
$local_addrs = array();
465+
$ips = $app->db->queryAllRecords('SELECT `ip_address`, `ip_type` FROM ?? WHERE `server_id` = ?', $conf['mysql']['database'].'.server_ip', $conf['server_id']);
466466
if(is_array($ips) && !empty($ips)){
467467
foreach($ips as $ip){
468-
$whitelist_ips[] = array('ip' => $ip['ip_address']);
468+
$local_addrs[] = array('quoted_ip' => "\"".$ip['ip_address']."\",\n");
469469
}
470470
}
471-
$tpl->setLoop('whitelist_ips', $whitelist_ips);
472-
$app->system->file_put_contents('/etc/rspamd/local.d/users.conf', $tpl->grab());
471+
$tpl->setLoop('local_addrs', $local_addrs);
472+
$app->system->file_put_contents('/etc/rspamd/local.d/options.inc', $tpl->grab());
473473

474474
if($mail_config['content_filter'] == 'rspamd'){
475475
$app->services->restartServiceDelayed('rspamd', 'reload');

0 commit comments

Comments
 (0)